Skip to content

Commit

Permalink
Fixed a bug with tcp/mqtt or tcp/websocket/mqtt messages longer than …
Browse files Browse the repository at this point in the history
…sock_buf length
  • Loading branch information
homewsn committed Apr 8, 2016
1 parent 5f7d010 commit 701d6b9
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/thread_tcp.c
Original file line number Diff line number Diff line change
Expand Up @@ -663,8 +663,8 @@ static int ws_frame_parse(list_tcp_conn_t *conn, unsigned char *recv_buf, size_t
memcpy(&ws_frame->key, ws_frame->hdr_buf + offset, sizeof(ws_frame->key));

conn->recv_buf = (unsigned char *)malloc(ws_frame->pld_size);
memcpy(conn->recv_buf, pld_buf, ws_frame->pld_size);
conn->recv_cnt = ws_frame->pld_size;
conn->recv_cnt = pld_size < ws_frame->pld_size? pld_size : ws_frame->pld_size;
memcpy(conn->recv_buf, pld_buf, conn->recv_cnt);

if (ws_frame->pld_size > pld_size)
// it's only the first part of the frame
Expand Down

0 comments on commit 701d6b9

Please sign in to comment.