Skip to content

Commit

Permalink
Fix buffer overflow and prevent recv() of 0 byte
Browse files Browse the repository at this point in the history
  • Loading branch information
feihu-stripe authored and dormando committed Mar 8, 2022
1 parent 1d825ef commit 046c4bb
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions proxy_network.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 046c4bb

Please sign in to comment.