Skip to content

Commit 5267f14

Browse files
committed
proxy: fix memory corruption from bad set uploads
Double-freeing of an rctx was possible if the data format from a set was corrupt (missing final \r\n)
1 parent 28f4abf commit 5267f14

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

proto_proxy.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -689,6 +689,7 @@ void complete_nread_proxy(conn *c) {
689689

690690
assert(c->proxy_rctx);
691691
mcp_rcontext_t *rctx = c->proxy_rctx;
692+
c->proxy_rctx = NULL;
692693
mcp_request_t *rq = rctx->request;
693694

694695
if (strncmp((char *)c->item + rq->pr.vlen - 2, "\r\n", 2) != 0) {
@@ -707,7 +708,6 @@ void complete_nread_proxy(conn *c) {
707708
rq->pr.vbuf = c->item;
708709
c->item = NULL;
709710
c->item_malloced = false;
710-
c->proxy_rctx = NULL;
711711
pthread_mutex_lock(&thr->proxy_limit_lock);
712712
thr->proxy_buffer_memory_used += rq->pr.vlen;
713713
pthread_mutex_unlock(&thr->proxy_limit_lock);

0 commit comments

Comments
 (0)