From 47e9fa981e56a7a232f3219fe8a40525c79d748b Mon Sep 17 00:00:00 2001 From: Evan Hunt Date: Tue, 16 Aug 2022 16:26:02 -0700 Subject: [PATCH] compression buffer was not reused correctly when the compression buffer was reused for multiple statistics requests, responses could grow beyond the correct size. this was because the buffer was not cleared before reuse; compressed data was still written to the beginning of the buffer, but then the size of used region was increased by the amount written, rather than set to the amount written. this caused responses to grow larger and larger, potentially reading past the end of the allocated buffer. --- lib/isc/httpd.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/isc/httpd.c b/lib/isc/httpd.c index e4c7d71699..9e2ea2ea38 100644 --- a/lib/isc/httpd.c +++ b/lib/isc/httpd.c @@ -202,6 +202,8 @@ free_buffer(isc_mem_t *mctx, isc_buffer_t *buffer) { if (r.base != NULL) { isc_mem_put(mctx, r.base, r.length); } + + isc_buffer_initnull(buffer); } isc_result_t @@ -864,6 +866,7 @@ httpd_compress(isc_httpd_t *httpd) { inputlen = isc_buffer_usedlength(&httpd->bodybuffer); alloc_compspace(httpd, inputlen); + isc_buffer_clear(&httpd->compbuffer); isc_buffer_region(&httpd->compbuffer, &r); /*