parse-and-reject-extensions-header.patch
authorAndy Green <andy.green@linaro.org>
Wed, 9 Feb 2011 08:58:42 +0000 (08:58 +0000)
committerAndy Green <andy@linaro.org>
Wed, 9 Feb 2011 08:58:42 +0000 (08:58 +0000)
Signed-off-by: Andy Green <andy@linaro.org>
lib/handshake.c
lib/parsers.c
lib/private-libwebsockets.h

index 2a4ebb6..e42aae5 100644 (file)
@@ -248,6 +248,11 @@ handshake_0405(struct libwebsocket *wsi)
                goto bail;
        }
 
+       if (wsi->utf8_token[WSI_TOKEN_EXTENSIONS].token_len) {
+               fprintf(stderr, "extensions not supported\n");
+               goto bail;
+       }
+
        if (wsi->utf8_token[WSI_TOKEN_KEY].token_len >=
                                                     MAX_WEBSOCKET_04_KEY_LEN) {
                fprintf(stderr, "Client sent handshake key longer "
index 7551f14..45a64f4 100644 (file)
@@ -29,6 +29,7 @@ const struct lws_tokens lws_tokens[WSI_TOKEN_COUNT] = {
        [WSI_TOKEN_KEY2]        = { "Sec-WebSocket-Key2:",      19 },
        [WSI_TOKEN_PROTOCOL]    = { "Sec-WebSocket-Protocol:",  23 },
        [WSI_TOKEN_UPGRADE]     = { "Upgrade:",                  8 },
+       [WSI_TOKEN_EXTENSIONS]  = { "Sec-WebSocket-Extensions:", 25 },
        [WSI_TOKEN_ORIGIN]      = { "Origin:",                   7 },
        [WSI_TOKEN_DRAFT]       = { "Sec-WebSocket-Draft:",     20 },
        [WSI_TOKEN_CHALLENGE]   = { "\x0d\x0a",                  2 },
@@ -63,6 +64,7 @@ int libwebsocket_parse(struct libwebsocket *wsi, unsigned char c)
        case WSI_TOKEN_VERSION:
        case WSI_TOKEN_ACCEPT:
        case WSI_TOKEN_NONCE:
+       case WSI_TOKEN_EXTENSIONS:
        case WSI_TOKEN_HTTP:
                debug("WSI_TOKEN_(%d) '%c'\n", wsi->parser_state, c);
 
index 14d4fb5..5c8de5d 100644 (file)
@@ -115,6 +115,9 @@ enum lws_token_indexes {
        WSI_TOKEN_VERSION,
        WSI_TOKEN_SWORIGIN,
 
+       /* new for 05 */
+       WSI_TOKEN_EXTENSIONS,
+
        /* client receives these */
        WSI_TOKEN_ACCEPT,
        WSI_TOKEN_NONCE,