Commit 8065439f authored by Deomid Ryabkov's avatar Deomid Ryabkov Committed by Cesanta Bot

Acquire lock when manipulating rx in SSL recv path

PUBLISHED_FROM=a34cfa3ebc12daf75d7f24c8d3f3707dcc33d9a2
parent 62c896a8
...@@ -15465,6 +15465,7 @@ int ssl_socket_recv(void *ctx, unsigned char *buf, size_t len) { ...@@ -15465,6 +15465,7 @@ int ssl_socket_recv(void *ctx, unsigned char *buf, size_t len) {
} }
size_t seg_len = (seg->len - cs->rx_offset); size_t seg_len = (seg->len - cs->rx_offset);
DBG(("%u %u %u %u", len, cs->rx_chain->len, seg_len, cs->rx_chain->tot_len)); DBG(("%u %u %u %u", len, cs->rx_chain->len, seg_len, cs->rx_chain->tot_len));
mgos_lock();
len = MIN(len, seg_len); len = MIN(len, seg_len);
pbuf_copy_partial(seg, buf, len, cs->rx_offset); pbuf_copy_partial(seg, buf, len, cs->rx_offset);
cs->rx_offset += len; cs->rx_offset += len;
...@@ -15476,6 +15477,7 @@ int ssl_socket_recv(void *ctx, unsigned char *buf, size_t len) { ...@@ -15476,6 +15477,7 @@ int ssl_socket_recv(void *ctx, unsigned char *buf, size_t len) {
pbuf_free(seg); pbuf_free(seg);
cs->rx_offset = 0; cs->rx_offset = 0;
} }
mgos_unlock();
LOG(LL_DEBUG, ("%p <- %d", nc, (int) len)); LOG(LL_DEBUG, ("%p <- %d", nc, (int) len));
return len; return len;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment