wireshark/CVE-2023-4513-1.patch

40 lines
1.4 KiB
Diff

From 863f6c3dc760ab770a7b31b33e9c769868e4289b Mon Sep 17 00:00:00 2001
From: John Thacker <johnthacker@gmail.com>
Date: Thu, 10 Aug 2023 01:19:21 -0400
Subject: [PATCH] wmem: Fix leak in block_fast when realloc'ing jumbo blocks
In block fast wmem_allocator is used, keep the double linked
list of jumbo blocks accurate by pointing the prev pointer of
the old head (if it exists) to the newly allocated jumbo block.
This prevents a leak if a jumbo block which is not the most
recently added jumbo block is realloc'ed. If the prev pointer
isn't set properly, then all the jumbo blocks added afterwards
will be lost from the list and leaked.
Fix #19259
(cherry picked from commit d086f2733bc611eb310aafec51bd28d44166fa42)
---
wsutil/wmem/wmem_allocator_block_fast.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/wsutil/wmem/wmem_allocator_block_fast.c b/wsutil/wmem/wmem_allocator_block_fast.c
index bdb8c2f75dc..117e9df6193 100644
--- a/wsutil/wmem/wmem_allocator_block_fast.c
+++ b/wsutil/wmem/wmem_allocator_block_fast.c
@@ -97,6 +97,9 @@ wmem_block_fast_alloc(void *private_data, const size_t size)
size + WMEM_JUMBO_HEADER_SIZE + WMEM_CHUNK_HEADER_SIZE);
block->next = allocator->jumbo_list;
+ if (block->next) {
+ block->next->prev = block;
+ }
block->prev = NULL;
allocator->jumbo_list = block;
--
GitLab