From aec69c7f2adcf9674f025c7f79cbeabbbd4e6b6a Mon Sep 17 00:00:00 2001 From: Mark Wielaard Date: Thu, 18 Jun 2015 10:54:29 +0200 Subject: libelf: Check symbol section header exists before use in nlist. Signed-off-by: Mark Wielaard --- libelf/ChangeLog | 4 ++++ libelf/nlist.c | 8 ++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/libelf/ChangeLog b/libelf/ChangeLog index 2d240074..2848f00c 100644 --- a/libelf/ChangeLog +++ b/libelf/ChangeLog @@ -1,3 +1,7 @@ +2015-06-18 Mark Wielaard + + * nlist.c (nlist): Check symscn shdr exists before use. + 2015-06-16 Mark Wielaard * elf_update.c (write_file): Always also use ftruncate before diff --git a/libelf/nlist.c b/libelf/nlist.c index 89fd0819..c7b32fdb 100644 --- a/libelf/nlist.c +++ b/libelf/nlist.c @@ -1,5 +1,5 @@ /* Extract symbol list from binary. - Copyright (C) 1998, 1999, 2000, 2001, 2002, 2005, 2007 Red Hat, Inc. + Copyright (C) 1998, 1999, 2000, 2001, 2002, 2005, 2007, 2015 Red Hat, Inc. This file is part of elfutils. Written by Ulrich Drepper , 1998. @@ -116,7 +116,11 @@ nlist (const char *filename, struct nlist *nl) /* Re-get the section header in case we found only the dynamic symbol table. */ if (scn == NULL) - shdr = INTUSE(gelf_getshdr) (symscn, &shdr_mem); + { + shdr = INTUSE(gelf_getshdr) (symscn, &shdr_mem); + if (unlikely (shdr == NULL)) + goto fail_close; + } /* SHDR->SH_LINK now contains the index of the string section. */ /* Get the data for the symbol section. */ -- cgit v1.2.3