mirror of
https://github.com/nginx/nginx.git
synced 2026-10-24 22:57:43 -05:00
Image filter: fixed reading past the received data
The size parser and the image decoders used ctx->length, which is the allocation size (set to image_filter_buffer when the upstream response omits Content-Length), as the amount of valid data, so a truncated response without Content-Length could be parsed or decoded past the received bytes into uninitialized buffer memory. The length is now adjusted to the actually-read size once the response body has been read. Reported by dukesp69 and YLChen-007.
This commit is contained in:
1 parent
be0f12efa0
commit
d09fc7da21
1 file changed
+1
@@ -510,6 +510,7 @@ ngx_http_image_read(ngx_http_request_t *r, ngx_chain_t *in)
|
||||
|
||||
if (b->last_buf) {
|
||||
ctx->last = p;
|
||||
ctx->length = p - ctx->image;
|
||||
return NGX_OK;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user