]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
libelf: Correct the size of the in memory datastructure (off-by-one)
authorMark Wielaard <mark@klomp.org>
Fri, 3 Jul 2026 14:01:32 +0000 (16:01 +0200)
committerMark Wielaard <mark@klomp.org>
Fri, 3 Jul 2026 14:08:17 +0000 (16:08 +0200)
Fix the u64 and u32 variable length array bounds. We state they are
[n], but there is actually room for [n+1] symbols. We don't actually
use the [n+1] entry, but we the undefined sanitizer warns about this.

Found by a new testcase by Kane Wang <wangqiang1@kylinos.cn>

* libelf/elf_getarsym.c (elf_getarsym): Mark (*u64) and (*u32)
as [n+1] arrays.

Signed-off-by: Mark Wielaard <mark@klomp.org>
libelf/elf_getarsym.c

index ec05c684abb6160901926865b4d2e3d335c0ad49..03381059d8f95322f975d6b4019acf9a00159cdb 100644 (file)
@@ -261,8 +261,8 @@ elf_getarsym (Elf *elf, size_t *ptr)
 
          /* Now we can build the data structure.  */
          Elf_Arsym *arsym = elf->state.ar.ar_sym;
-         uint64_t (*u64)[n] = file_data;
-         uint32_t (*u32)[n] = file_data;
+         uint64_t (*u64)[n+1] = file_data;
+         uint32_t (*u32)[n+1] = file_data;
          for (size_t cnt = 0; cnt < n; ++cnt)
            {
              arsym[cnt].as_name = str_data;