mirror of
https://github.com/warmcat/libwebsockets.git
synced 2025-03-30 00:00:16 +01:00
act on fatal parse problems
Signed-off-by: Andy Green <andy.green@linaro.org>
This commit is contained in:
parent
c5dc32ab48
commit
3455e676d8
3 changed files with 16 additions and 13 deletions
|
@ -21,10 +21,6 @@
|
||||||
|
|
||||||
#include "private-libwebsockets.h"
|
#include "private-libwebsockets.h"
|
||||||
|
|
||||||
#ifdef WIN32
|
|
||||||
#include <io.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
int libwebsocket_client_rx_sm(struct libwebsocket *wsi, unsigned char c)
|
int libwebsocket_client_rx_sm(struct libwebsocket *wsi, unsigned char c)
|
||||||
{
|
{
|
||||||
int n;
|
int n;
|
||||||
|
|
|
@ -288,7 +288,10 @@ int lws_client_socket_service(struct libwebsocket_context *context, struct libwe
|
||||||
if (len < 0)
|
if (len < 0)
|
||||||
goto bail3;
|
goto bail3;
|
||||||
|
|
||||||
libwebsocket_parse(wsi, c);
|
if (libwebsocket_parse(wsi, c)) {
|
||||||
|
/* problems */
|
||||||
|
goto bail3;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -88,8 +88,10 @@ libwebsocket_read(struct libwebsocket_context *context,
|
||||||
case LWS_CONNMODE_WS_CLIENT_WAITING_EXTENSION_CONNECT:
|
case LWS_CONNMODE_WS_CLIENT_WAITING_EXTENSION_CONNECT:
|
||||||
case LWS_CONNMODE_WS_CLIENT:
|
case LWS_CONNMODE_WS_CLIENT:
|
||||||
for (n = 0; n < len; n++)
|
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;
|
return 0;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
@ -99,13 +101,14 @@ libwebsocket_read(struct libwebsocket_context *context,
|
||||||
/* LWS_CONNMODE_WS_SERVING */
|
/* LWS_CONNMODE_WS_SERVING */
|
||||||
|
|
||||||
for (n = 0; n < len; n++)
|
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)
|
if (wsi->u.hdr.parser_state != WSI_PARSING_COMPLETE)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
lwsl_parser("seem to be serving, mode is %d\n", wsi->mode);
|
|
||||||
|
|
||||||
lwsl_parser("libwebsocket_parse sees parsing complete\n");
|
lwsl_parser("libwebsocket_parse sees parsing complete\n");
|
||||||
|
|
||||||
/* is this websocket protocol or normal http 1.0? */
|
/* is this websocket protocol or normal http 1.0? */
|
||||||
|
@ -115,9 +118,10 @@ libwebsocket_read(struct libwebsocket_context *context,
|
||||||
wsi->state = WSI_STATE_HTTP;
|
wsi->state = WSI_STATE_HTTP;
|
||||||
if (wsi->protocol->callback)
|
if (wsi->protocol->callback)
|
||||||
if (wsi->protocol->callback(context, wsi,
|
if (wsi->protocol->callback(context, wsi,
|
||||||
LWS_CALLBACK_HTTP, wsi->user_space,
|
LWS_CALLBACK_HTTP,
|
||||||
wsi->utf8_token[WSI_TOKEN_GET_URI].token,
|
wsi->user_space,
|
||||||
wsi->utf8_token[WSI_TOKEN_GET_URI].token_len)) {
|
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");
|
lwsl_info("LWS_CALLBACK_HTTP wanted to close\n");
|
||||||
goto bail;
|
goto bail;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue