From 02c561914caceb41c36a3eecd01114d8d33ec1f9 Mon Sep 17 00:00:00 2001 From: Petr Machata Date: Thu, 10 Mar 2011 01:50:32 +0100 Subject: [PATCH] Reject requests for abbreviation with code 0 --- libdw/ChangeLog | 5 ++++ libdw/dwarf_tag.c | 6 ++++- tests/Makefile.am | 10 ++++--- tests/rerequest_tag.c | 53 +++++++++++++++++++++++++++++++++++++ tests/run-rerequest_tag.sh | 33 +++++++++++++++++++++++ tests/testfile56.bz2 | Bin 0 -> 2768 bytes 6 files changed, 102 insertions(+), 5 deletions(-) create mode 100644 tests/rerequest_tag.c create mode 100755 tests/run-rerequest_tag.sh create mode 100644 tests/testfile56.bz2 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 0000000000000000000000000000000000000000..0e2257cff43cbb85d67d54abf6875bd8b0019978 GIT binary patch literal 2768 zc-jHb3NQ6ST4*^jL0KkKS^4oEkN^qDfB*mg|Ns8~_y7O@|9$`e-**3h^mXM*=}iCQ z?9O+7@894FJnqK(&cQn8H*b5j?!6uztqx!V+_MInLIpD^gH&dy^*qXlsp@!B#M2^r zp43l6Q`9v5Nb;D5fB?|Q8fl@m9+29Bpn8DNX`pBT&@>Gi2dR;f>J11(NrEvl38eBT zijPK9Pf$HT9-s{X(9i%Lpbt<0G#Yw=qd+tO0D6D{pa-G=1JoLt0%_M4KPDM8UO&$#5B+hfB-ZDK*(qY zfEfXxX`>Km&;S9T05k~{lzI`O41tg|7=+p;nqf5bGys?;)OtfqCJ~bcfiW-u00d%S z39?NL0%?hW022<5WoKiqjaOeqJl1zi)>fufBxdg0wB7?D?KW-+K>(Jyv=PEYwbZIm zf`z1Jsc7Nh^f-Zu=PIdTPbW0ck|LDq3OdwDb%fhVp_rN@yCJ1V71cVxPOxAs z&qrhwXgVffZS*Ogs>;rwag(Znl#8x$h;Yoe6Afi6Uo=ZuwBKoVVFy_tnXhN$|8PHN`$uxjT zf5wfdfGz+YEg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