| From df78be05daf4eb07f60f50ec1080cb979af32ec0 Mon Sep 17 00:00:00 2001 |
| From: marxin <marxin@138bc75d-0d04-0410-961f-82ee72b054a4> |
| Date: Tue, 23 Jul 2019 07:33:32 +0000 |
| Subject: [PATCH] libiberty: Check zero value shstrndx in simple-object-elf.c |
| |
| git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@273718 138bc75d-0d04-0410-961f-82ee72b054a4 |
| |
| CVE: CVE-2019-14250 |
| Upstream-Status: Backport [from gcc: https://gcc.gnu.org/viewcvs/gcc?view=revision&revision=273718] |
| [Removed Changelog entry] |
| Signed-off-by: Anuj Mittal <anuj.mittal@intel.com> |
| --- |
| diff --git a/libiberty/simple-object-elf.c b/libiberty/simple-object-elf.c |
| index 502388991a08..bdee963634d6 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; |
| } |
| |