[binutils-gdb] ld/pdb: Zero-initialize section array in handle_debugs_section
Jan Beulich
jbeulich@sourceware.org
Fri Nov 6 13:16:30 GMT 2026
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=a729341631f5ddea915cebe722e4ec198ff96c38
commit a729341631f5ddea915cebe722e4ec198ff96c38
Author: Oleg Tolmatcev <oleg.tolmatcev@gmail.com>
Date: Fri Nov 6 14:15:54 2026 +0100
ld/pdb: Zero-initialize section array in handle_debugs_section
handle_debugs_section only fills in symbols and sectlist for primary
symbols with a positive section number, so a relocation in a malformed
object referring to any other symbol read uninitialized memory.
Allocate the sectlist array with xcalloc; the relocate_section routines
skip relocations against a NULL section.
ld/
* pdb.c (handle_debugs_section): Allocate sectlist with xcalloc.
Signed-off-by: Oleg Tolmatcev <oleg.tolmatcev@gmail.com>
Diff:
---
ld/pdb.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/ld/pdb.c b/ld/pdb.c
index 4083a7d17ba..c06cc635cbe 100644
--- a/ld/pdb.c
+++ b/ld/pdb.c
@@ -1947,7 +1947,7 @@ handle_debugs_section (asection *s, bfd *mod, struct string_table *strings,
relocs = bfd_coff_read_internal_relocs (mod, s, false, NULL, true, NULL);
symbols = xmalloc (sizeof (struct internal_syment) * syment_count);
- sectlist = xmalloc (sizeof (asection *) * syment_count);
+ sectlist = xcalloc (syment_count, sizeof (*sectlist));
ext = (struct external_syment *) (coff_data (mod)->external_syms);
More information about the Binutils-cvs
mailing list