File elflint-check-symbol-table-data-is-big-enough-before-check.patch of Package elfutils.8903

[PATCH] elflint: Check symbol table data is big enough before checking.
From: Mark Wielaard <mark at klomp dot org>
To: elfutils-devel at sourceware dot org
Cc: Mark Wielaard <mark at klomp dot org>
Date: Mon, 27 Mar 2017 23:59:02 +0200
Subject: [PATCH] elflint: Check symbol table data is big enough before checking.
Reference: bnc#1033088

Before checking symbol index zero we should make sure the data size
is big enough.

https://sourceware.org/bugzilla/show_bug.cgi?id=21310

elfutils packaging edits:
 - changelog hunk removed from original patch to avoid conflict

Signed-off-by: Mark Wielaard <mark@klomp.org>
---
 src/ChangeLog | 4 ++++
 src/elflint.c | 3 ++-
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/src/elflint.c b/src/elflint.c
index 66a13ca..76fb1a0 100644
--- a/src/elflint.c
+++ b/src/elflint.c
@@ -1959,7 +1959,8 @@ section [%2d] '%s': extended section index in section [%2zu] '%s' refers to same
       return;
     }
 
-  if (*((Elf32_Word *) data->d_buf) != 0)
+  if (data->d_size < sizeof (Elf32_Word)
+      || *((Elf32_Word *) data->d_buf) != 0)
     ERROR (gettext ("symbol 0 should have zero extended section index\n"));
 
   for (size_t cnt = 1; cnt < data->d_size / sizeof (Elf32_Word); ++cnt)
-- 
2.9.3
openSUSE Build Service is sponsored by