]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
util-buffer: expand by multiples of 4k 12204/head 12207/head
authorJason Ish <jason.ish@oisf.net>
Thu, 28 Nov 2024 15:20:18 +0000 (09:20 -0600)
committerJason Ish <jason.ish@oisf.net>
Mon, 2 Dec 2024 16:32:23 +0000 (10:32 -0600)
(cherry picked from commit 287d8360e7a7263e23194470ed59e08982f76e31)

src/util-buffer.c

index 05b365825818893d99155a92d836606b02629a2d..cfc190087ee7820dcde73e5c465999d9df822e0e 100644 (file)
@@ -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);