mirror of
https://github.com/warmcat/libwebsockets.git
synced 2025-03-09 00:00:04 +01:00
fix-user-pointer-bug.patch
Signed-off-by: Andy Green <andy@warmcat.com>
This commit is contained in:
parent
05464c6b7b
commit
47943ae82d
4 changed files with 23 additions and 9 deletions
|
@ -96,7 +96,7 @@ libwebsocket_read(struct libwebsocket *wsi, unsigned char * buf, size_t len)
|
|||
!wsi->utf8_token[WSI_TOKEN_CONNECTION].token_len) {
|
||||
if (wsi->protocol->callback)
|
||||
(wsi->protocol->callback)(wsi, LWS_CALLBACK_HTTP,
|
||||
&wsi->user_space,
|
||||
wsi->user_space,
|
||||
wsi->utf8_token[WSI_TOKEN_GET_URI].token, 0);
|
||||
wsi->state = WSI_STATE_HTTP;
|
||||
return 0;
|
||||
|
@ -145,6 +145,9 @@ libwebsocket_read(struct libwebsocket *wsi, unsigned char * buf, size_t len)
|
|||
|
||||
wsi->protocol++;
|
||||
}
|
||||
|
||||
/* we didn't find a protocol he wanted? */
|
||||
|
||||
if (wsi->protocol->callback == NULL) {
|
||||
if (wsi->utf8_token[WSI_TOKEN_PROTOCOL].token == NULL)
|
||||
fprintf(stderr, "[no protocol] "
|
||||
|
@ -166,7 +169,9 @@ libwebsocket_read(struct libwebsocket *wsi, unsigned char * buf, size_t len)
|
|||
"conn user space\n");
|
||||
goto bail;
|
||||
}
|
||||
}
|
||||
fprintf(stderr, "user allocated %d at %p for wsi %p\n", wsi->protocol->per_session_data_size, wsi->user_space, wsi);
|
||||
} else
|
||||
wsi->user_space = NULL;
|
||||
|
||||
/* create the response packet */
|
||||
|
||||
|
@ -275,7 +280,7 @@ libwebsocket_read(struct libwebsocket *wsi, unsigned char * buf, size_t len)
|
|||
|
||||
if (wsi->protocol->callback)
|
||||
wsi->protocol->callback(wsi, LWS_CALLBACK_ESTABLISHED,
|
||||
&wsi->user_space, NULL, 0);
|
||||
wsi->user_space, NULL, 0);
|
||||
break;
|
||||
|
||||
case WSI_STATE_ESTABLISHED:
|
||||
|
|
|
@ -82,7 +82,7 @@ libwebsocket_close_and_free_session(struct libwebsocket *wsi)
|
|||
wsi->state = WSI_STATE_DEAD_SOCKET;
|
||||
|
||||
if (wsi->protocol->callback && n == WSI_STATE_ESTABLISHED)
|
||||
wsi->protocol->callback(wsi, LWS_CALLBACK_CLOSED, &wsi->user_space,
|
||||
wsi->protocol->callback(wsi, LWS_CALLBACK_CLOSED, wsi->user_space,
|
||||
NULL, 0);
|
||||
|
||||
for (n = 0; n < WSI_TOKEN_COUNT; n++)
|
||||
|
@ -444,7 +444,7 @@ poll_out:
|
|||
continue;
|
||||
|
||||
wsi[client]->protocol->callback(wsi[client], LWS_CALLBACK_SEND,
|
||||
&wsi[client]->user_space, NULL, 0);
|
||||
wsi[client]->user_space, NULL, 0);
|
||||
}
|
||||
|
||||
continue;
|
||||
|
|
|
@ -212,7 +212,7 @@ static int libwebsocket_rx_sm(struct libwebsocket *wsi, unsigned char c)
|
|||
issue:
|
||||
if (wsi->protocol->callback)
|
||||
wsi->protocol->callback(wsi, LWS_CALLBACK_RECEIVE,
|
||||
&wsi->user_space,
|
||||
wsi->user_space,
|
||||
&wsi->rx_user_buffer[LWS_SEND_BUFFER_PRE_PADDING],
|
||||
wsi->rx_user_buffer_head);
|
||||
wsi->rx_user_buffer_head = 0;
|
||||
|
|
|
@ -93,14 +93,23 @@ else ignored
|
|||
</dl>
|
||||
<h3>Description</h3>
|
||||
<blockquote>
|
||||
This function forks to create the listening socket and takes care
|
||||
This function creates the listening socket and takes care
|
||||
of all initialization in one step.
|
||||
<p>
|
||||
The callback function is called for a handful of events including
|
||||
http requests coming in, websocket connections becoming
|
||||
It does not return since it sits in a service loop and operates via the
|
||||
callbacks given in <tt><b>protocol</b></tt>. User code should fork before calling
|
||||
<b>libwebsocket_create_server</b> if it wants to do other things in
|
||||
parallel other than serve websockets.
|
||||
<p>
|
||||
The protocol callback functions are called for a handful of events
|
||||
including http requests coming in, websocket connections becoming
|
||||
established, and data arriving; it's also called periodically to allow
|
||||
async transmission.
|
||||
<p>
|
||||
HTTP requests are sent always to the FIRST protocol in <tt><b>protocol</b></tt>, since
|
||||
at that time websocket protocol has not been negotiated. Other
|
||||
protocols after the first one never see any HTTP callack activity.
|
||||
<p>
|
||||
The server created is a simple http server by default; part of the
|
||||
websocket standard is upgrading this http connection to a websocket one.
|
||||
<p>
|
||||
|
|
Loading…
Add table
Reference in a new issue