This is the mail archive of the elfutils-devel@sourceware.org mailing list for the elfutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH 2/6] robustify: elflint.


On Fri, 2014-01-17 at 21:20 +0100, Mark Wielaard wrote:
> +2014-01-17  Jakub Jelinek  <jakub@redhat.com>
> +
> +	* elflint.c (section_name): Return "<invalid>" instead of
> +	crashing on invalid section name.
> +	(check_symtab, is_rel_dyn, check_rela, check_rel, check_dynamic,
> +	check_symtab_shndx, check_hash, check_versym): Robustify.
> +	(check_hash): Don't check entries beyond end of section.
> +	(check_note): Don't crash if gelf_rawchunk fails.

I made a small merge mistake (it was correct on the robustify branch and
in the original patch), since we now use shnum here already...

> @@ -311,10 +311,19 @@ section_name (Ebl *ebl, int idx)
>  {
>    GElf_Shdr shdr_mem;
>    GElf_Shdr *shdr;
> +  const char *ret;
> +
> +  if ((unsigned int) idx > shnum)
> +    return "<invalid>";

The definitions should be moved up:

@@ -123,6 +123,10 @@ static uint32_t shstrndx;
 /* Array to count references in section groups.  */
 static int *scnref;
 
+/* Numbers of sections and program headers.  */
+static unsigned int shnum;
+static unsigned int phnum;
+
 
 int
 main (int argc, char *argv[])
@@ -337,11 +350,6 @@ static const int valid_e_machine[] =
   (sizeof (valid_e_machine) / sizeof (valid_e_machine[0]))
 
 
-/* Numbers of sections and program headers.  */
-static unsigned int shnum;
-static unsigned int phnum;
-
-
 static void
 check_elf_header (Ebl *ebl, GElf_Ehdr *ehdr, size_t size)
 {

Fixed up the patch and rebased the series against current master on the
mjw/pending branch.

Cheers,

Mark


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]