summaryrefslogtreecommitdiff
path: root/proxy_network.c
diff options
context:
space:
mode:
authorFei Hu <feihu@stripe.com>2022-03-02 07:12:12 -0800
committerdormando <dormando@rydia.net>2022-03-07 17:29:46 -0800
commit046c4bb5d8498420c13e5357c8299b60952b2595 (patch)
treea17f8691d7cb55c6edf85b024311ec02644d42c1 /proxy_network.c
parent1d825ef0a539e03db69984a89a6d47ee5d4d27ee (diff)
downloadmemcached-046c4bb5d8498420c13e5357c8299b60952b2595.tar.gz
Fix buffer overflow and prevent recv() of 0 byte1.6.15
Diffstat (limited to 'proxy_network.c')
-rw-r--r--proxy_network.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/proxy_network.c b/proxy_network.c
index d3cde20..3454164 100644
--- a/proxy_network.c
+++ b/proxy_network.c
@@ -540,10 +540,8 @@ static int proxy_backend_drive_machine(mcp_backend_t *be, int bread, char **rbuf
if (r->status != MCMC_OK) {
P_DEBUG("%s: mcmc_read failed [%d]\n", __func__, r->status);
if (r->status == MCMC_WANT_READ) {
- flags |= EV_READ;
- be->state = mcp_backend_read;
- stop = true;
- break;
+ *rbuf = mcmc_read_prep(be->client, be->rbuf, READ_BUFFER_SIZE, toread);
+ return EV_READ;
} else {
flags = -1;
stop = true;
@@ -649,6 +647,7 @@ static int proxy_backend_drive_machine(mcp_backend_t *be, int bread, char **rbuf
// if not, the stack is desynced and we lose it.
r->status = mcmc_parse_buf(be->client, be->rbuf, bread, &tmp_resp);
+ bread = 0;
P_DEBUG("%s [read_end]: r->status: %d, bread: %d resp.type:%d\n", __func__, r->status, bread, tmp_resp.type);
if (r->status != MCMC_OK) {
if (r->status == MCMC_WANT_READ) {