]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
Reject requests for abbreviation with code 0
authorPetr Machata <pmachata@redhat.com>
Thu, 10 Mar 2011 00:50:32 +0000 (01:50 +0100)
committerPetr Machata <pmachata@redhat.com>
Thu, 10 Mar 2011 00:50:32 +0000 (01:50 +0100)
libdw/ChangeLog
libdw/dwarf_tag.c
tests/Makefile.am
tests/rerequest_tag.c [new file with mode: 0644]
tests/run-rerequest_tag.sh [new file with mode: 0755]
tests/testfile56.bz2 [new file with mode: 0644]

index e31fabf9e84ae7beffa5fc3be95ce69d72b3941a..fb98e9288003c45eb0c42069f11ff3351b2454f8 100644 (file)
@@ -1,3 +1,8 @@
+2011-03-10  Petr Machata  <pmachata@redhat.com>
+
+       * libdw/dwarf_tag.c (__libdw_findabbrev): Reject requests for
+       abbreviation with code 0.
+
 2011-03-09  Petr Machata  <pmachata@redhat.com>
 
        * libdw/dwarf_child.c (dwarf_child): Check for section overrun.
index 15183d2db04db2a93aef8fa19819359b37798a1c..6d9090c6c20dd70561f7ab2cc79b45f71bd0d737 100644 (file)
@@ -1,5 +1,5 @@
 /* Return tag of given DIE.
-   Copyright (C) 2003, 2004, 2005, 2006, 2008 Red Hat, Inc.
+   Copyright (C) 2003-2011 Red Hat, Inc.
    This file is part of Red Hat elfutils.
    Written by Ulrich Drepper <drepper@redhat.com>, 2003.
 
@@ -61,6 +61,10 @@ __libdw_findabbrev (struct Dwarf_CU *cu, unsigned int code)
 {
   Dwarf_Abbrev *abb;
 
+  /* Abbreviation code can never have a value of 0.  */
+  if (unlikely (code == 0))
+    return DWARF_END_ABBREV;
+
   /* See whether the entry is already in the hash table.  */
   abb = Dwarf_Abbrev_Hash_find (&cu->abbrev_hash, code, NULL);
   if (abb == NULL)
index 37eb568e1713ebe79ece74ef38309572e02056ac..32a15e28375357e62e8e2e5b7fad39e7f4779a98 100644 (file)
@@ -1,6 +1,6 @@
 ## Process this file with automake to create Makefile.in
 ##
-## Copyright (C) 1996-2010 Red Hat, Inc.
+## Copyright (C) 1996-2011 Red Hat, Inc.
 ## This file is part of Red Hat elfutils.
 ##
 ## Red Hat elfutils is free software; you can redistribute it and/or modify
@@ -57,7 +57,7 @@ noinst_PROGRAMS = arextract arsymtest newfile saridx scnnames sectiondump \
                  dwfl-bug-addr-overflow arls dwfl-bug-fd-leak \
                  dwfl-addr-sect dwfl-bug-report early-offscn \
                  dwfl-bug-getmodules dwarf-getmacros addrcfi \
-                 test-flag-nobits dwarf-getstring
+                 test-flag-nobits dwarf-getstring rerequest_tag
 asm_TESTS = asm-tst1 asm-tst2 asm-tst3 asm-tst4 asm-tst5 \
            asm-tst6 asm-tst7 asm-tst8 asm-tst9
 
@@ -84,7 +84,7 @@ TESTS = run-arextract.sh run-arsymtest.sh newfile test-nlist \
        run-disasm-x86.sh run-disasm-x86-64.sh \
        run-early-offscn.sh run-dwarf-getmacros.sh \
        run-test-flag-nobits.sh run-prelink-addr-test.sh \
-       run-dwarf-getstring.sh
+       run-dwarf-getstring.sh run-rerequest_tag.sh
 # run-show-ciefde.sh
 
 if !STANDALONE
@@ -156,7 +156,8 @@ EXTRA_DIST = run-arextract.sh run-arsymtest.sh \
             testfile54-64.prelink.so.bz2 testfile54-64.noshdrs.so.bz2 \
             testfile55-32.bz2 testfile55-32.debug.bz2 \
             testfile55-32.prelink.bz2 testfile55-64.bz2 \
-            testfile55-64.debug.bz2 testfile55-64.prelink.bz2
+            testfile55-64.debug.bz2 testfile55-64.prelink.bz2 \
+            testfile56.bz2
 
 installed_TESTS_ENVIRONMENT = libdir=$(DESTDIR)$(libdir) \
                              bindir=$(DESTDIR)$(bindir) \
@@ -251,6 +252,7 @@ dwarf_getmacros_LDADD = $(libdw) $(libmudflap)
 dwarf_getstring_LDADD = $(libdw) $(libmudflap)
 addrcfi_LDADD = $(libdw) $(libebl) $(libelf) $(libmudflap) -ldl
 test_flag_nobits_LDADD = $(libelf) $(libmudflap)
+rerequest_tag_LDADD = $(libdw) $(libmudflap)
 
 if GCOV
 check: check-am coverage
diff --git a/tests/rerequest_tag.c b/tests/rerequest_tag.c
new file mode 100644 (file)
index 0000000..b0d2c2c
--- /dev/null
@@ -0,0 +1,53 @@
+/* Copyright (C) 2011 Red Hat, Inc.
+   This file is part of Red Hat elfutils.
+
+   Red Hat elfutils is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by the
+   Free Software Foundation; version 2 of the License.
+
+   Red Hat elfutils is distributed in the hope that it will be useful, but
+   WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   General Public License for more details.
+
+   You should have received a copy of the GNU General Public License along
+   with Red Hat elfutils; if not, write to the Free Software Foundation,
+   Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA.
+
+   Red Hat elfutils is an included package of the Open Invention Network.
+   An included package of the Open Invention Network is a package for which
+   Open Invention Network licensees cross-license their patents.  No patent
+   license is granted, either expressly or impliedly, by designation as an
+   included package.  Should you wish to participate in the Open Invention
+   Network licensing program, please visit www.openinventionnetwork.com
+   <http://www.openinventionnetwork.com>.  */
+
+#include <config.h>
+
+#include ELFUTILS_HEADER(dw)
+#include <fcntl.h>
+#include <stdio.h>
+#include <string.h>
+#include <assert.h>
+
+int main(int argc, char *argv[])
+{
+  assert (argc > 1);
+
+  int i = open(argv[1], O_RDONLY);
+  assert (i >= 0);
+
+  Dwarf *dw = dwarf_begin(i, DWARF_C_READ);
+  assert (dw != NULL);
+
+  Dwarf_Die die_mem, *die;
+  die = dwarf_offdie (dw, 11, &die_mem);
+  assert (die == &die_mem);
+  assert (dwarf_tag (die) == 0);
+
+  die = dwarf_offdie (dw, 11, &die_mem);
+  assert (die == &die_mem);
+  assert (dwarf_tag (die) == 0);
+
+  return 0;
+}
diff --git a/tests/run-rerequest_tag.sh b/tests/run-rerequest_tag.sh
new file mode 100755 (executable)
index 0000000..ad5f767
--- /dev/null
@@ -0,0 +1,33 @@
+#! /bin/sh
+# Copyright (C) 2011 Red Hat, Inc.
+# This file is part of Red Hat elfutils.
+#
+# Red Hat elfutils is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by the
+# Free Software Foundation; version 2 of the License.
+#
+# Red Hat elfutils is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with Red Hat elfutils; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA.
+#
+# Red Hat elfutils is an included package of the Open Invention Network.
+# An included package of the Open Invention Network is a package for which
+# Open Invention Network licensees cross-license their patents.  No patent
+# license is granted, either expressly or impliedly, by designation as an
+# included package.  Should you wish to participate in the Open Invention
+# Network licensing program, please visit www.openinventionnetwork.com
+# <http://www.openinventionnetwork.com>.
+
+. $srcdir/test-subr.sh
+
+testfiles testfile56
+
+testrun_compare ./rerequest_tag testfile56 <<\EOF
+EOF
+
+exit 0
diff --git a/tests/testfile56.bz2 b/tests/testfile56.bz2
new file mode 100644 (file)
index 0000000..0e2257c
Binary files /dev/null and b/tests/testfile56.bz2 differ