public inbox for elfutils@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] elflint: Check sh_info for symtab isn't too big.
@ 2020-02-07 17:21 Mark Wielaard
  2020-02-18 12:11 ` Mark Wielaard
  0 siblings, 1 reply; 2+ messages in thread
From: Mark Wielaard @ 2020-02-07 17:21 UTC (permalink / raw)
  To: elfutils-devel; +Cc: Mark Wielaard

The sh_info field of the symtab says how many symbols are in the
section. Make sure at least that many symbols fit in the section.

Reported-by: Ulrich Drepper <drepper@redhat.com>
Signed-off-by: Mark Wielaard <mark@klomp.org>
---
 src/ChangeLog | 4 ++++
 src/elflint.c | 4 ++++
 2 files changed, 8 insertions(+)

diff --git a/src/ChangeLog b/src/ChangeLog
index 7ce9e54b..e351318b 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,7 @@
+2020-02-07  Mark Wielaard  <mark@klomp.org>
+
+	* elflint.c (check_symtab): Check st_info isn't too big.
+
 2020-01-16  Mark Wielaard  <mark@klomp.org>
 
 	* nm.c (show_symbols_sysv): Iterate over all symbols starting
diff --git a/src/elflint.c b/src/elflint.c
index 684b794e..78d485e3 100644
--- a/src/elflint.c
+++ b/src/elflint.c
@@ -658,6 +658,10 @@ section [%2d] '%s': symbol table cannot have more than one extended index sectio
     ERROR (gettext ("\
 section [%2u] '%s': entry size is does not match ElfXX_Sym\n"),
 	   idx, section_name (ebl, idx));
+  else if (shdr->sh_info > shdr->sh_size / sh_entsize)
+    ERROR (gettext ("\
+section [%2u] '%s': number of local entries in 'st_info' larger than table size\n"),
+	   idx, section_name (ebl, idx));
 
   /* Test the zeroth entry.  */
   GElf_Sym sym_mem;
-- 
2.20.1

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] elflint: Check sh_info for symtab isn't too big.
  2020-02-07 17:21 [PATCH] elflint: Check sh_info for symtab isn't too big Mark Wielaard
@ 2020-02-18 12:11 ` Mark Wielaard
  0 siblings, 0 replies; 2+ messages in thread
From: Mark Wielaard @ 2020-02-18 12:11 UTC (permalink / raw)
  To: elfutils-devel

On Fri, 2020-02-07 at 18:20 +0100, Mark Wielaard wrote:
> The sh_info field of the symtab says how many symbols are in the
> section. Make sure at least that many symbols fit in the section.

I pushed this to master.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-02-18 12:11 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-07 17:21 [PATCH] elflint: Check sh_info for symtab isn't too big Mark Wielaard
2020-02-18 12:11 ` Mark Wielaard

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).