summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPetr Machata <pmachata@redhat.com>2011-03-07 15:57:38 +0100
committerPetr Machata <pmachata@redhat.com>2011-03-07 15:57:38 +0100
commit43423ee7e421b01e23696692f8a30201cd1a3826 (patch)
tree3af81358cbea063073088face26aa7e0da7a9791
parent427cc2ef9317a16137fe8f9d589967947eea40a3 (diff)
downloadelfutils-43423ee7e421b01e23696692f8a30201cd1a3826.tar.gz
dwarflint: Check that the name of relocated section is valid
-rw-r--r--dwarflint/sections.cc6
-rw-r--r--dwarflint/tests/garbage-1.bz2bin0 -> 2768 bytes
-rwxr-xr-xdwarflint/tests/run-bad.sh8
3 files changed, 11 insertions, 3 deletions
diff --git a/dwarflint/sections.cc b/dwarflint/sections.cc
index b1fb2a67..add26b89 100644
--- a/dwarflint/sections.cc
+++ b/dwarflint/sections.cc
@@ -262,7 +262,8 @@ namespace
if (shdr == NULL)
{
invalid_elf:
- wr_error () << "Broken ELF." << std::endl;
+ wr_error () << "Broken ELF: " << elf_errmsg (-1) << "."
+ << std::endl;
goto close_and_out;
}
@@ -318,9 +319,10 @@ namespace
const char *relocated_scnname
= elf_strptr (elf, file->ehdr.e_shstrndx,
relocated_shdr->sh_name);
+ if (unlikely (relocated_scnname == NULL))
+ goto invalid_elf;
secentry *relocated = secinfo.get (relocated_scnname);
-
if (relocated != NULL)
{
if (relocated->reldata != NULL)
diff --git a/dwarflint/tests/garbage-1.bz2 b/dwarflint/tests/garbage-1.bz2
new file mode 100644
index 00000000..de1b26d2
--- /dev/null
+++ b/dwarflint/tests/garbage-1.bz2
Binary files differ
diff --git a/dwarflint/tests/run-bad.sh b/dwarflint/tests/run-bad.sh
index d67554fb..5dd64956 100755
--- a/dwarflint/tests/run-bad.sh
+++ b/dwarflint/tests/run-bad.sh
@@ -27,7 +27,7 @@
srcdir=$srcdir/tests
-testfiles hello.bad-1 hello.bad-3
+testfiles hello.bad-1 hello.bad-3 garbage-1
testrun_compare ./dwarflint hello.bad-1 <<EOF
error: .debug_info: DIE 0x83: abbrev section at 0x0 doesn't contain code 83.
@@ -40,3 +40,9 @@ error: .debug_info: DIE 0x9e: toplevel DIE chain contains more than one DIE.
error: .debug_info: DIE 0xa4: toplevel DIE chain contains more than one DIE.
error: .debug_info: DIE 0xab: toplevel DIE chain contains more than one DIE.
EOF
+
+testrun_compare ./dwarflint garbage-1 <<EOF
+error: Broken ELF: offset out of range.
+error: .debug_abbrev: data not found.
+error: .debug_info: data not found.
+EOF