Skip to content

Commit

Permalink
Fix cached request body size limitation with chunked TE
Browse files Browse the repository at this point in the history
With varnishcache#3809 in place, VFP_END is now signalled opportunistically.

Thus, if we see VFP_OK with a full buffer, we still need one extra
read to ensure that it does not return VFP_END.
  • Loading branch information
nigoroll committed Jun 24, 2022
1 parent c6d8c5d commit 390e72e
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion bin/varnishd/cache/cache_req_body.c
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ vrb_pull(struct req *req, ssize_t maxsize, unsigned partial,
const struct stevedore *stv;
ssize_t req_bodybytes = 0;
uint64_t oa_len;
char c;

CHECK_OBJ_NOTNULL(req, REQ_MAGIC);

Expand Down Expand Up @@ -201,7 +202,15 @@ vrb_pull(struct req *req, ssize_t maxsize, unsigned partial,
} while (vfps == VFP_OK && (maxsize < 0 || req_bodybytes < maxsize));

if (!partial) {
if (maxsize >= 0 && req_bodybytes > maxsize)
/* VFP_END means that the body fit into the given size, but we
* might need one extra read to see it if a chunked encoding
* zero chunk is delayed
*/
if (vfps == VFP_OK) {
l = 1;
vfps = VFP_Suck(vfc, &c, &l);
}
if (vfps == VFP_OK)
(void)VFP_Error(vfc, "Request body too big to cache");

req->acct.req_bodybytes += VFP_Close(vfc);
Expand Down

0 comments on commit 390e72e

Please sign in to comment.