From b1bc0f50350a568e67ed731c4fec2c72847f15fe Mon Sep 17 00:00:00 2001 From: Ren Kimura Date: Tue, 23 Jul 2019 07:33:32 +0000 Subject: [PATCH] libiberty: Check zero value shstrndx in simple-object-elf.c From-SVN: r273718 --- libiberty/ChangeLog | 5 +++++ libiberty/simple-object-elf.c | 10 +++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/libiberty/ChangeLog b/libiberty/ChangeLog index a0508e98b08..ddd96183e01 100644 --- a/libiberty/ChangeLog +++ b/libiberty/ChangeLog @@ -1,3 +1,8 @@ +2019-07-12 Ren Kimura + + * simple-object-elf.c (simple_object_elf_match): Check zero value shstrndx. + This fixes a Bug 90924. + 2019-07-22 Martin Liska * simple-object-elf.c (simple_object_elf_copy_lto_debug_sections): diff --git a/libiberty/simple-object-elf.c b/libiberty/simple-object-elf.c index 502388991a0..bdee963634d 100644 --- a/libiberty/simple-object-elf.c +++ b/libiberty/simple-object-elf.c @@ -548,7 +548,15 @@ simple_object_elf_match (unsigned char header[SIMPLE_OBJECT_MATCH_HEADER_LEN], XDELETE (eor); return NULL; } - + + if (eor->shstrndx == 0) + { + *errmsg = "invalid ELF shstrndx == 0"; + *err = 0; + XDELETE (eor); + return NULL; + } + return (void *) eor; } -- 2.30.2