From: Mark Wielaard Date: Mon, 18 May 2026 18:14:44 +0000 (+0200) Subject: elfcompress: Fix off-by-one sanity check X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ee195c3516aa64a9df1d2f096b1f56bb3fb1a7d9;p=thirdparty%2Felfutils.git elfcompress: Fix off-by-one sanity check The elf ndx should not be bigger than, or equal to shnum. This really should never trigger unless elf_ndx and/or elf_getshdrnum is buggy. * src/elfcompress.c (process_file): Check ndx >= shnum. Signed-off-by: Mark Wielaard --- diff --git a/src/elfcompress.c b/src/elfcompress.c index 630eb54d..25ebd1be 100644 --- a/src/elfcompress.c +++ b/src/elfcompress.c @@ -483,7 +483,7 @@ process_file (const char *fname) while ((scn = elf_nextscn (elf, scn)) != NULL) { size_t ndx = elf_ndxscn (scn); - if (ndx > shnum) + if (ndx >= shnum) { error (0, 0, "Unexpected section number %zd, expected only %zd", ndx, shnum);