From: Andy Green Date: Mon, 28 Dec 2015 08:51:08 +0000 (+0800) Subject: autobahn detect disordered continuation X-Git-Tag: upstream/1.7.3~152 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=977734ee07d75832c160e5ec2b3c9c717a239e55;p=platform%2Fupstream%2Flibwebsockets.git autobahn detect disordered continuation Signed-off-by: Andy Green --- diff --git a/lib/client-parser.c b/lib/client-parser.c index cfe90a3..4157e08 100644 --- a/lib/client-parser.c +++ b/lib/client-parser.c @@ -36,6 +36,16 @@ int lws_client_rx_sm(struct lws *wsi, unsigned char c) wsi->u.ws.opcode = c & 0xf; /* revisit if an extension wants them... */ switch (wsi->u.ws.opcode) { + case LWSWSOPC_TEXT_FRAME: + case LWSWSOPC_BINARY_FRAME: + wsi->u.ws.continuation_possible = 1; + break; + case LWSWSOPC_CONTINUATION: + if (!wsi->u.ws.continuation_possible) { + lwsl_info("disordered continuation\n"); + return -1; + } + break; case 3: case 4: case 5: @@ -62,6 +72,9 @@ int lws_client_rx_sm(struct lws *wsi, unsigned char c) return -1; } wsi->u.ws.final = !!((c >> 7) & 1); + if (wsi->u.ws.final) + wsi->u.ws.continuation_possible = 0; + if ((wsi->u.ws.opcode & 8) && !wsi->u.ws.final) { lwsl_info("control message cannot be fragmented\n"); return -1; diff --git a/lib/private-libwebsockets.h b/lib/private-libwebsockets.h index b91417f..15b6f84 100644 --- a/lib/private-libwebsockets.h +++ b/lib/private-libwebsockets.h @@ -856,6 +856,7 @@ struct _lws_websocket_related { unsigned int clean_buffer:1; /* buffer not rewritten by extension */ unsigned int payload_is_close:1; /* process as PONG, but it is close */ unsigned int ping_pending_flag:1; + unsigned int continuation_possible:1; }; struct lws {