From: Petr Machata Date: Mon, 7 Mar 2011 14:57:38 +0000 (+0100) Subject: dwarflint: Check that the name of relocated section is valid X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=43423ee7e421b01e23696692f8a30201cd1a3826;p=thirdparty%2Felfutils.git dwarflint: Check that the name of relocated section is valid --- diff --git a/dwarflint/sections.cc b/dwarflint/sections.cc index b1fb2a672..add26b894 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 000000000..de1b26d2b Binary files /dev/null and b/dwarflint/tests/garbage-1.bz2 differ diff --git a/dwarflint/tests/run-bad.sh b/dwarflint/tests/run-bad.sh index d67554fbd..5dd649566 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 <