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-8.0.0-beta1~681 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=287d8360e7a7263e23194470ed59e08982f76e31;p=thirdparty%2Fsuricata.git util-buffer: expand by multiples of 4k --- diff --git a/src/util-buffer.c b/src/util-buffer.c index 677805b400..6caaf97b52 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);