]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
libelf: Check symbol section header exists before use in nlist.
authorMark Wielaard <mjw@redhat.com>
Thu, 18 Jun 2015 08:54:29 +0000 (10:54 +0200)
committerMark Wielaard <mjw@redhat.com>
Fri, 19 Jun 2015 10:27:22 +0000 (12:27 +0200)
Signed-off-by: Mark Wielaard <mjw@redhat.com>
libelf/ChangeLog
libelf/nlist.c

index 2d2400748d32924738e09868d89733d846c96894..2848f00c583ddc3792e6a87259001e07783accff 100644 (file)
@@ -1,3 +1,7 @@
+2015-06-18  Mark Wielaard  <mjw@redhat.com>
+
+       * nlist.c (nlist): Check symscn shdr exists before use.
+
 2015-06-16  Mark Wielaard  <mjw@redhat.com>
 
        * elf_update.c (write_file): Always also use ftruncate before
index 89fd0819dfd1a7148c5e662e84a3f02038536814..c7b32fdbe1d17bb8d2c100d3f605cdfdcbb16cca 100644 (file)
@@ -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 <drepper@redhat.com>, 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.  */