From: Jason Ish Date: Thu, 28 Nov 2024 15:20:18 +0000 (-0600) Subject: util-buffer: expand by multiples of 4k X-Git-Tag: suricata-7.0.8~29 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=093397f6b399b075738b4a86f2b67cfb103136ee;p=thirdparty%2Fsuricata.git util-buffer: expand by multiples of 4k (cherry picked from commit 287d8360e7a7263e23194470ed59e08982f76e31) --- diff --git a/src/util-buffer.c b/src/util-buffer.c index 05b3658258..cfc190087e 100644 --- a/src/util-buffer.c +++ b/src/util-buffer.c @@ -65,6 +65,11 @@ int MemBufferExpand(MemBuffer **buffer, uint32_t expand_by) { return -1; } + /* Adjust expand_by to next multiple of 4k. */ + if (expand_by % 4096 != 0) { + expand_by = expand_by - (expand_by % 4096) + 4096; + } + size_t total_size = (*buffer)->size + sizeof(MemBuffer) + expand_by; MemBuffer *tbuffer = SCRealloc(*buffer, total_size);