From 89bc677a40f65941436958a10a7f7ac4635c1fda Mon Sep 17 00:00:00 2001 From: Payden Sutherland Date: Thu, 15 Nov 2012 19:16:17 -0500 Subject: [PATCH] Bugfixes Modifying payload_len_small in libwsclient_send by OR'ing with 0x80 Just set the frame byte appropriately without modifying payload_len_small Also move setting payload_sz back to WS_HELPER_RECV_BUF size *before* memsetting.. overflowing my bounds there. Woops. --- wsclient.c | 8 ++++---- wsclient.h | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/wsclient.c b/wsclient.c index 1a9f64e..0cdf1f9 100644 --- a/wsclient.c +++ b/wsclient.c @@ -404,8 +404,9 @@ void *libwsclient_helper_socket_thread(void *ptr) { } payload_idx = 0; payload = (char *)malloc(HELPER_RECV_BUF_SIZE); - memset(payload, 0, payload_sz); payload_sz = HELPER_RECV_BUF_SIZE; + memset(payload, 0, payload_sz); + do { memset(recv_buf, 0, HELPER_RECV_BUF_SIZE); n = recv(remote_sock, recv_buf, HELPER_RECV_BUF_SIZE - 1, 0); @@ -846,9 +847,8 @@ int libwsclient_send(wsclient *client, char *strdata) { return -1; } memset(data, 0, frame_size); - payload_len_small |= 0x80; - memcpy(data, &finNopcode, 1); - memcpy(data+1, &payload_len_small, 1); //mask bit on, 7 bit payload len + *data = finNopcode; + *(data+1) = payload_len_small | 0x80; //payload length with mask bit on if(payload_len_small == 126) { payload_len &= 0xffff; len_size = 2; diff --git a/wsclient.h b/wsclient.h index f6de600..3bb3bd9 100644 --- a/wsclient.h +++ b/wsclient.h @@ -119,7 +119,7 @@ char *errors[] = { "Unknown error occured", "Error while getting address info", "Could connect to any address returned by getaddrinfo", - "Error sending data in client run thread", + "Error receiving data in client run thread", "Error during libwsclient_close", "Error sending while handling control frame", "Received masked frame from server",