* [PATCH] nm: Guard against divide by zero in error check.
@ 2014-12-26 18:39 Mark Wielaard
0 siblings, 0 replies; 2+ messages in thread
From: Mark Wielaard @ 2014-12-26 18:39 UTC (permalink / raw)
To: elfutils-devel
[-- Attachment #1: Type: text/plain, Size: 2029 bytes --]
Also add section index number in error message.
https://bugzilla.redhat.com/show_bug.cgi?id=1170810
Reported-by: Alexander Cherepanov <cherepan@mccme.ru>
Signed-off-by: Mark Wielaard <mjw@redhat.com>
---
src/ChangeLog | 5 +++++
src/nm.c | 13 ++++++++-----
2 files changed, 13 insertions(+), 5 deletions(-)
diff --git a/src/ChangeLog b/src/ChangeLog
index 9da2853..904b3c9 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,5 +1,10 @@
2014-12-26 Mark Wielaard <mjw@redhat.com>
+ * nm.c (show_symbols): Guard against divide by zero in error check.
+ Add section index number in error message.
+
+2014-12-26 Mark Wielaard <mjw@redhat.com>
+
* nm.c (handle_ar): Skip over /SYM64/ entries.
2014-12-26 Mark Wielaard <mjw@redhat.com>
diff --git a/src/nm.c b/src/nm.c
index be91459..915153f 100644
--- a/src/nm.c
+++ b/src/nm.c
@@ -1169,14 +1169,17 @@ show_symbols (Ebl *ebl, GElf_Ehdr *ehdr, Elf_Scn *scn, Elf_Scn *xndxscn,
size_t entsize = shdr->sh_entsize;
/* Consistency checks. */
- if (entsize != gelf_fsize (ebl->elf, ELF_T_SYM, 1, ehdr->e_version))
+ if (entsize == 0
+ || entsize != gelf_fsize (ebl->elf, ELF_T_SYM, 1, ehdr->e_version))
error (0, 0,
- gettext ("%s: entry size in section `%s' is not what we expect"),
- fullname, elf_strptr (ebl->elf, shstrndx, shdr->sh_name));
+ gettext ("%s: entry size in section %zd `%s' is not what we expect"),
+ fullname, elf_ndxscn (scn),
+ elf_strptr (ebl->elf, shstrndx, shdr->sh_name));
else if (size % entsize != 0)
error (0, 0,
- gettext ("%s: size of section `%s' is not multiple of entry size"),
- fullname, elf_strptr (ebl->elf, shstrndx, shdr->sh_name));
+ gettext ("%s: size of section %zd `%s' is not multiple of entry size"),
+ fullname, elf_ndxscn (scn),
+ elf_strptr (ebl->elf, shstrndx, shdr->sh_name));
/* Compute number of entries. Handle buggy entsize values. */
size_t nentries = size / (entsize ?: 1);
--
2.1.0
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] nm: Guard against divide by zero in error check.
@ 2015-01-12 21:08 Mark Wielaard
0 siblings, 0 replies; 2+ messages in thread
From: Mark Wielaard @ 2015-01-12 21:08 UTC (permalink / raw)
To: elfutils-devel
[-- Attachment #1: Type: text/plain, Size: 305 bytes --]
On Fri, 2014-12-26 at 19:39 +0100, Mark Wielaard wrote:
> Also add section index number in error message.
>
> https://bugzilla.redhat.com/show_bug.cgi?id=1170810
>
> Reported-by: Alexander Cherepanov <cherepan@mccme.ru>
> Signed-off-by: Mark Wielaard <mjw@redhat.com>
I pushed this to master.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2015-01-12 21:08 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-12-26 18:39 [PATCH] nm: Guard against divide by zero in error check Mark Wielaard
2015-01-12 21:08 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).