1
0
Fork 0
mirror of https://github.com/warmcat/libwebsockets.git synced 2025-03-09 00:00:04 +01:00

use context service buffer instead of stack for clent_connect

Signed-off-by: Andy Green <andy.green@linaro.org>
This commit is contained in:
Andy Green 2013-02-10 15:34:59 +08:00
parent f54a94b494
commit e48ba315b8
3 changed files with 11 additions and 17 deletions

View file

@ -20,7 +20,7 @@ struct libwebsocket *__libwebsocket_client_connect_2(
*/
if (context->http_proxy_port) {
plen = sprintf(context->service_buffer,
plen = sprintf((char *)context->service_buffer,
"CONNECT %s:%u HTTP/1.0\x0d\x0a"
"User-agent: libwebsockets\x0d\x0a"
/*Proxy-authorization: basic aGVsbG86d29ybGQ= */

View file

@ -45,9 +45,6 @@ int lws_client_socket_service(struct libwebsocket_context *context, struct libwe
char *p = (char *)&context->service_buffer[0];
int len;
char c;
#ifdef LWS_OPENSSL_SUPPORT
char ssl_err_buf[512];
#endif
switch (wsi->mode) {
@ -177,7 +174,7 @@ int lws_client_socket_service(struct libwebsocket_context *context, struct libwe
lwsl_err("SSL connect error %s\n",
ERR_error_string(ERR_get_error(),
ssl_err_buf));
(char *)context->service_buffer));
return 0;
}

View file

@ -32,9 +32,6 @@
int
handshake_0405(struct libwebsocket_context *context, struct libwebsocket *wsi)
{
static const char *websocket_magic_guid_04 =
"258EAFA5-E914-47DA-95CA-C5AB0DC85B11";
char accept_buf[MAX_WEBSOCKET_04_KEY_LEN + 37];
unsigned char hash[20];
int n;
char *response;
@ -62,16 +59,16 @@ handshake_0405(struct libwebsocket_context *context, struct libwebsocket *wsi)
goto bail;
}
strcpy(accept_buf, wsi->u.hdr.hdrs[WSI_TOKEN_KEY].token);
strcpy(accept_buf + wsi->u.hdr.hdrs[WSI_TOKEN_KEY].token_len,
websocket_magic_guid_04);
n = snprintf((char *)context->service_buffer,
sizeof context->service_buffer,
"%s258EAFA5-E914-47DA-95CA-C5AB0DC85B11",
wsi->u.hdr.hdrs[WSI_TOKEN_KEY].token);
SHA1((unsigned char *)accept_buf,
wsi->u.hdr.hdrs[WSI_TOKEN_KEY].token_len +
strlen(websocket_magic_guid_04), hash);
SHA1(context->service_buffer, n, hash);
accept_len = lws_b64_encode_string((char *)hash, 20, accept_buf,
sizeof accept_buf);
accept_len = lws_b64_encode_string((char *)hash, 20,
(char *)context->service_buffer,
sizeof context->service_buffer);
if (accept_len < 0) {
lwsl_warn("Base64 encoded hash too long\n");
goto bail;
@ -100,7 +97,7 @@ handshake_0405(struct libwebsocket_context *context, struct libwebsocket *wsi)
"Upgrade: WebSocket\x0d\x0a"
"Connection: Upgrade\x0d\x0a"
"Sec-WebSocket-Accept: ");
strcpy(p, accept_buf);
strcpy(p, (char *)context->service_buffer);
p += accept_len;
if (wsi->u.hdr.hdrs[WSI_TOKEN_PROTOCOL].token) {