From: Mark Wielaard <mark@klomp.org>
To: elfutils-devel@sourceware.org
Cc: Mark Wielaard <mark@klomp.org>
Subject: [PATCH] elflint: Make sure we can read a whole element when iterating over group.
Date: Mon, 26 Feb 2018 21:53:00 -0000 [thread overview]
Message-ID: <20180226215310.16233-1-mark@klomp.org> (raw)
Change the for loop so that we can always read a full element.
https://sourceware.org/bugzilla/show_bug.cgi?id=22892
Signed-off-by: Mark Wielaard <mark@klomp.org>
---
src/ChangeLog | 5 +++++
src/elflint.c | 2 +-
2 files changed, 6 insertions(+), 1 deletion(-)
diff --git a/src/ChangeLog b/src/ChangeLog
index 0ae01e92..e73c6154 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,8 @@
+2018-02-09 Mark Wielaard <mark@klomp.org>
+
+ * elflint.c (check_group): Make sure we can read a complete
+ element when iterating over the group.
+
2018-02-09 Mark Wielaard <mark@klomp.org>
* readelf.c (attr_callback): Handle DW_FORM_data16 as Dwarf_Block.
diff --git a/src/elflint.c b/src/elflint.c
index df1b3a03..ebb0e4e0 100644
--- a/src/elflint.c
+++ b/src/elflint.c
@@ -2713,7 +2713,7 @@ section [%2d] '%s': section group with only one member\n"),
ERROR (gettext ("section [%2d] '%s': unknown section group flags\n"),
idx, section_name (ebl, idx));
- for (cnt = elsize; cnt < data->d_size; cnt += elsize)
+ for (cnt = elsize; cnt + elsize <= data->d_size; cnt += elsize)
{
#if ALLOW_UNALIGNED
val = *((Elf32_Word *) ((char *) data->d_buf + cnt));
--
2.16.1
reply other threads:[~2018-02-26 21:53 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180226215310.16233-1-mark@klomp.org \
--to=mark@klomp.org \
--cc=elfutils-devel@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).