fix failure to limit 7bit lengths
authorAndy Green <andy@warmcat.com>
Sun, 25 Sep 2011 09:46:31 +0000 (10:46 +0100)
committerAndy Green <andy@warmcat.com>
Sun, 25 Sep 2011 09:46:31 +0000 (10:46 +0100)
Reported-by: Tran Le Hung <tranhung44@gmail.com>
Reported-by: Tobias Maier <tobias.maier@netplace.com>
Signed-off-by: Andy Green <andy@warmcat.com>
lib/parsers.c

index 52f1b7d..01d360b 100644 (file)
@@ -495,7 +495,7 @@ handle_first:
 
                wsi->this_frame_masked = !!(c & 0x80);
 
-               switch (c) {
+               switch (c & 0x7f) {
                case 126:
                        /* control frames are not allowed to have big lengths */
                        if (wsi->opcode & 8)
@@ -959,7 +959,7 @@ int libwebsocket_client_rx_sm(struct libwebsocket *wsi, unsigned char c)
 
                wsi->this_frame_masked = !!(c & 0x80);
 
-               switch (c) {
+               switch (c & 0x7f) {
                case 126:
                        /* control frames are not allowed to have big lengths */
                        if (wsi->opcode & 8)