e_shstrndx checks
Alan Modra
amodra@bigpond.net.au
Mon May 14 04:15:00 GMT 2007
PR 4496
* elf.c (bfd_elf_string_from_elf_section): Return NULL on
invalid shstrndx.
(bfd_elf_get_str_section): Likewise.
Index: bfd/elf.c
===================================================================
RCS file: /cvs/src/src/bfd/elf.c,v
retrieving revision 1.387
diff -u -p -r1.387 elf.c
--- bfd/elf.c 10 May 2007 14:46:48 -0000 1.387
+++ bfd/elf.c 14 May 2007 04:11:37 -0000
@@ -252,7 +252,9 @@ bfd_elf_get_str_section (bfd *abfd, unsi
bfd_size_type shstrtabsize;
i_shdrp = elf_elfsections (abfd);
- if (i_shdrp == 0 || i_shdrp[shindex] == 0)
+ if (i_shdrp == 0
+ || shindex >= elf_numsections (abfd)
+ || i_shdrp[shindex] == 0)
return NULL;
shstrtab = i_shdrp[shindex]->contents;
@@ -291,6 +293,9 @@ bfd_elf_string_from_elf_section (bfd *ab
if (strindex == 0)
return "";
+ if (elf_elfsections (abfd) == NULL || shindex >= elf_numsections (abfd))
+ return NULL;
+
hdr = elf_elfsections (abfd)[shindex];
if (hdr->contents == NULL
--
Alan Modra
IBM OzLabs - Linux Technology Centre
More information about the Binutils
mailing list