Browse Source

Cast to size_t rather than int

The result of the bit shift is assigned to a size_t data_len so we should
do the shift in size_t space.
Matt Clarkson 10 năm trước cách đây
mục cha
commit
0dc73824a2
1 tập tin đã thay đổi với 1 bổ sung1 xóa
  1. 1 1
      src/civetweb.c

+ 1 - 1
src/civetweb.c

@@ -7133,7 +7133,7 @@ static void read_websocket(struct mg_connection *conn,
 				header_len = 2 + mask_len;
 			} else if (len == 126 && body_len >= 4 + mask_len) {
 				header_len = 4 + mask_len;
-				data_len = ((((int)buf[2]) << 8) + buf[3]);
+				data_len = ((((size_t)buf[2]) << 8) + buf[3]);
 			} else if (body_len >= 10 + mask_len) {
 				header_len = 10 + mask_len;
 				data_len = (((uint64_t)ntohl(*(uint32_t *)&buf[2])) << 32) +