From: Mark Wielaard Date: Mon, 18 May 2026 17:33:26 +0000 (+0200) Subject: elfcompress: Don't over allocate sections bitmap X-Git-Url: http://git.ipfire.org/gitweb/index.cgi?a=commitdiff_plain;h=59b47e80cc60a5a5aede4b7d468de00490700fa5;p=thirdparty%2Felfutils.git elfcompress: Don't over allocate sections bitmap In process_file we allocate a bitmap sections to track which sections we want to (de)compress. This allocates shnum / 8 + 1 unsigned ints. But an unsigned int can contain more bits than just 8. In all other places we use WORD_BITS defined as 8U * sizeof (unsigned int). Also use WORD_BITS to calculate how many unsigned ints we need for the sections bitmap. * src/elfcompress.c (process_file): Use shnum / WORD_BITS + 1 to allocate sections. Signed-off-by: Mark Wielaard --- diff --git a/src/elfcompress.c b/src/elfcompress.c index f771b92a..630eb54d 100644 --- a/src/elfcompress.c +++ b/src/elfcompress.c @@ -424,7 +424,7 @@ process_file (const char *fname) goto cleanup; } - sections = xcalloc (shnum / 8 + 1, sizeof (unsigned int)); + sections = xcalloc (shnum / WORD_BITS + 1, sizeof (unsigned int)); size_t phnum; if (elf_getphdrnum (elf, &phnum) != 0)