From: Petr Machata Date: Thu, 10 Mar 2011 00:50:32 +0000 (+0100) Subject: Reject requests for abbreviation with code 0 X-Git-Tag: elfutils-0.153~59 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=02c561914caceb41c36a3eecd01114d8d33ec1f9;p=thirdparty%2Felfutils.git Reject requests for abbreviation with code 0 --- diff --git a/libdw/ChangeLog b/libdw/ChangeLog index e31fabf9e..fb98e9288 100644 --- a/libdw/ChangeLog +++ b/libdw/ChangeLog @@ -1,3 +1,8 @@ +2011-03-10 Petr Machata + + * libdw/dwarf_tag.c (__libdw_findabbrev): Reject requests for + abbreviation with code 0. + 2011-03-09 Petr Machata * libdw/dwarf_child.c (dwarf_child): Check for section overrun. diff --git a/libdw/dwarf_tag.c b/libdw/dwarf_tag.c index 15183d2db..6d9090c6c 100644 --- a/libdw/dwarf_tag.c +++ b/libdw/dwarf_tag.c @@ -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 , 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) diff --git a/tests/Makefile.am b/tests/Makefile.am index 37eb568e1..32a15e283 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -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 index 000000000..b0d2c2c5e --- /dev/null +++ b/tests/rerequest_tag.c @@ -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 + . */ + +#include + +#include ELFUTILS_HEADER(dw) +#include +#include +#include +#include + +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 index 000000000..ad5f767e5 --- /dev/null +++ b/tests/run-rerequest_tag.sh @@ -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 +# . + +. $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 index 000000000..0e2257cff Binary files /dev/null and b/tests/testfile56.bz2 differ