From: Mark Wielaard Date: Thu, 18 Jun 2015 08:54:29 +0000 (+0200) Subject: libelf: Check symbol section header exists before use in nlist. X-Git-Tag: elfutils-0.163~10 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=aec69c7f2adcf9674f025c7f79cbeabbbd4e6b6a;p=thirdparty%2Felfutils.git libelf: Check symbol section header exists before use in nlist. Signed-off-by: Mark Wielaard --- diff --git a/libelf/ChangeLog b/libelf/ChangeLog index 2d2400748..2848f00c5 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 89fd0819d..c7b32fdbe 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. */