Signed-off-by: Mark Wielaard <[email protected]> --- libelf/ChangeLog | 4 ++++ libelf/nlist.c | 8 ++++++-- 2 files changed, 10 insertions(+), 2 deletions(-)
diff --git a/libelf/ChangeLog b/libelf/ChangeLog index 52004f7..82540f6 100644 --- a/libelf/ChangeLog +++ b/libelf/ChangeLog @@ -1,5 +1,9 @@ 2015-06-18 Mark Wielaard <[email protected]> + * nlist.c (nlist): Check symscn shdr exists before use. + +2015-06-18 Mark Wielaard <[email protected]> + * elf32_updatefile.c (updatefile): Always free shdr_data and scns when allocated on failure paths. diff --git a/libelf/nlist.c b/libelf/nlist.c index 89fd081..c72f420 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 <[email protected]>, 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 (shdr == NULL) + goto fail_close; + } /* SHDR->SH_LINK now contains the index of the string section. */ /* Get the data for the symbol section. */ -- 1.8.3.1
