Bladeren bron

Fix warning for 32 bit code

bel2125 8 jaren geleden
bovenliggende
commit
cffc66e72c
1 gewijzigde bestanden met toevoegingen van 6 en 4 verwijderingen
  1. 6 4
      src/civetweb.c

+ 6 - 4
src/civetweb.c

@@ -10859,8 +10859,8 @@ read_websocket(struct mg_connection *conn,
 	 * len is the length of the current message
 	 * len is the length of the current message
 	 * data_len is the length of the current message's data payload
 	 * data_len is the length of the current message's data payload
 	 * header_len is the length of the current message's header */
 	 * header_len is the length of the current message's header */
-	size_t i, mask_len = 0, header_len, body_len;
-	uint64_t len, data_len = 0;
+	size_t i, len, mask_len = 0, header_len, body_len;
+	uint64_t data_len = 0;
 
 
 	/* "The masking key is a 32-bit value chosen at random by the client."
 	/* "The masking key is a 32-bit value chosen at random by the client."
 	 * http://tools.ietf.org/html/draft-ietf-hybi-thewebsocketprotocol-17#section-5
 	 * http://tools.ietf.org/html/draft-ietf-hybi-thewebsocketprotocol-17#section-5
@@ -10972,8 +10972,10 @@ read_websocket(struct mg_connection *conn,
 				mop = buf[0]; /* current mask and opcode, overwritten by
 				mop = buf[0]; /* current mask and opcode, overwritten by
 				               * memmove() */
 				               * memmove() */
 				/* Length of the message being read at the front of the
 				/* Length of the message being read at the front of the
-				 * queue */
-				len = data_len + header_len;
+				                 * queue. Cast to 31 bit is OK, since we limited
+				 * data_len
+				                 * before. */
+				len = (size_t)data_len + header_len;
 
 
 				/* Copy the data payload into the data pointer for the
 				/* Copy the data payload into the data pointer for the
 				 * callback */
 				 * callback */