act on fatal parse problems 15/3015/1
authorAndy Green <andy.green@linaro.org>
Mon, 4 Feb 2013 00:55:42 +0000 (08:55 +0800)
committerKevron Rees <kevron_m_rees@linux.intel.com>
Thu, 7 Mar 2013 21:01:31 +0000 (13:01 -0800)
Signed-off-by: Andy Green <andy.green@linaro.org>
lib/client-parser.c
lib/client.c
lib/handshake.c

index bb96e9b..3131f50 100644 (file)
 
 #include "private-libwebsockets.h"
 
-#ifdef WIN32
-#include <io.h>
-#endif
-
 int libwebsocket_client_rx_sm(struct libwebsocket *wsi, unsigned char c)
 {
        int n;
index c92bc49..ef17ca8 100644 (file)
@@ -288,7 +288,10 @@ int lws_client_socket_service(struct libwebsocket_context *context, struct libwe
                        if (len < 0)
                                goto bail3;
 
-                       libwebsocket_parse(wsi, c);
+                       if (libwebsocket_parse(wsi, c)) {
+                               /* problems */
+                               goto bail3;
+                       }
                }
 
                /*
index 7cb2799..763aa4d 100644 (file)
@@ -88,8 +88,10 @@ libwebsocket_read(struct libwebsocket_context *context,
                case LWS_CONNMODE_WS_CLIENT_WAITING_EXTENSION_CONNECT:
                case LWS_CONNMODE_WS_CLIENT:
                        for (n = 0; n < len; n++)
-                               libwebsocket_client_rx_sm(wsi, *buf++);
-
+                               if (libwebsocket_client_rx_sm(wsi, *buf++)) {
+                                       lwsl_info("libwebsocket_client_rx_sm failed\n");
+                                       goto bail;
+                               }
                        return 0;
                default:
                        break;
@@ -99,13 +101,14 @@ libwebsocket_read(struct libwebsocket_context *context,
                /* LWS_CONNMODE_WS_SERVING */
 
                for (n = 0; n < len; n++)
-                       libwebsocket_parse(wsi, *buf++);
+                       if (libwebsocket_parse(wsi, *buf++)) {
+                               lwsl_info("libwebsocket_parse failed\n");
+                               goto bail;
+                       }
 
                if (wsi->u.hdr.parser_state != WSI_PARSING_COMPLETE)
                        break;
 
-               lwsl_parser("seem to be serving, mode is %d\n", wsi->mode);
-
                lwsl_parser("libwebsocket_parse sees parsing complete\n");
 
                /* is this websocket protocol or normal http 1.0? */
@@ -115,9 +118,10 @@ libwebsocket_read(struct libwebsocket_context *context,
                        wsi->state = WSI_STATE_HTTP;
                        if (wsi->protocol->callback)
                                if (wsi->protocol->callback(context, wsi,
-                                                               LWS_CALLBACK_HTTP, wsi->user_space,
-                                                               wsi->utf8_token[WSI_TOKEN_GET_URI].token,
-                                                               wsi->utf8_token[WSI_TOKEN_GET_URI].token_len)) {
+                                               LWS_CALLBACK_HTTP,
+                                               wsi->user_space,
+                                               wsi->utf8_token[WSI_TOKEN_GET_URI].token,
+                                               wsi->utf8_token[WSI_TOKEN_GET_URI].token_len)) {
                                        lwsl_info("LWS_CALLBACK_HTTP wanted to close\n");
                                        goto bail;
                                }