summaryrefslogtreecommitdiffstats
path: root/lib/libelf/libelf_checksum.c
diff options
context:
space:
mode:
authorjkoshy <jkoshy@FreeBSD.org>2006-12-25 02:22:22 +0000
committerjkoshy <jkoshy@FreeBSD.org>2006-12-25 02:22:22 +0000
commit26d8253ac6532abcb8d1c8d57743998f5368173b (patch)
tree1f1c4db9c6b866adf56e5cc3eccd23baaa57af28 /lib/libelf/libelf_checksum.c
parent44313eba34c379a180dc73dcd02ab9c415941db3 (diff)
downloadFreeBSD-src-26d8253ac6532abcb8d1c8d57743998f5368173b.zip
FreeBSD-src-26d8253ac6532abcb8d1c8d57743998f5368173b.tar.gz
Keep shadow copies of the `e_shnum', `e_phnum' and `e_shstrndx'
members of the ELF Executable Header inside the library-private `struct _Elf' descriptor and only update the underlying Elf{32,64}_Ehdr structure on an elf_update(3) call. These fields of the Ehdr structure are technically `out of bounds' for an application program per the ELF(3) API, but we've seen applications that initialize a new Ehdr structure using memcpy(), messing up the library's invariants. [1] Implement elf_getphnum() and handle ELF objects with more than 64K program header table entries. Reported by: jb [1]
Diffstat (limited to 'lib/libelf/libelf_checksum.c')
-rw-r--r--lib/libelf/libelf_checksum.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/libelf/libelf_checksum.c b/lib/libelf/libelf_checksum.c
index 3210412..c7eb8a0 100644
--- a/lib/libelf/libelf_checksum.c
+++ b/lib/libelf/libelf_checksum.c
@@ -76,7 +76,7 @@ _libelf_checksum(Elf *e, int elfclass)
*/
checksum = 0;
- for (shn = 1; shn < eh.e_shnum; shn++) {
+ for (shn = 1; shn < e->e_u.e_elf.e_nscn; shn++) {
if ((scn = elf_getscn(e, shn)) == NULL)
return (0);
if (gelf_getshdr(scn, &shdr) == NULL)
OpenPOWER on IntegriCloud