public inbox for dwz@sourceware.org
 help / color / mirror / Atom feed
From: Tom de Vries <tdevries@suse.de>
To: dwz@sourceware.org, jakub@redhat.com
Subject: [PATCH] Error out on invalid locexpr length
Date: Tue, 01 Jan 2019 00:00:00 -0000	[thread overview]
Message-ID: <20190307071254.GA20914@delia> (raw)

Hi,

When invoking dwz with a file containing an invalid locexpr length, we can run
into this assertion:
...
dwz: dwz.c:1722: read_loclist: Assertion `ptr + len <= endsec' failed.
Aborted (core dumped)
...

Change the assert into an error:
...
dwz: a.out: locexpr length 0x4ef exceeds .debug_loc section
...

OK for trunk?

Thanks,
- Tom

Error out on invalid locexpr length

2019-02-14  Tom de Vries  <tdevries@suse.de>

	PR dwz/24172
	* dwz.c (read_loclist): Change assert (ptr + len <= endsec) into an
	error.

---
 dwz.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/dwz.c b/dwz.c
index 4ef8657..a876ab2 100644
--- a/dwz.c
+++ b/dwz.c
@@ -1719,7 +1719,13 @@ read_loclist (DSO *dso, dw_die_ref die, GElf_Addr offset)
 	continue;
 
       len = read_16 (ptr);
-      assert (ptr + len <= endsec);
+      if (!(ptr + len <= endsec))
+	{
+	  error (0, 0,
+		 "%s: locexpr length 0x%Lx exceeds .debug_loc section",
+		 dso->filename, (long long) len);
+	  return 1;
+	}
 
       if (read_exprloc (dso, die, ptr, len, &need_adjust))
 	return 1;

             reply	other threads:[~2019-03-07  7:12 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-01  0:00 Tom de Vries [this message]
2019-01-01  0:00 ` [committed] " Tom de Vries
2019-01-01  0:00 ` [PATCH] " Tom de Vries
2019-01-01  0:00   ` Tom de Vries

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=20190307071254.GA20914@delia \
    --to=tdevries@suse.de \
    --cc=dwz@sourceware.org \
    --cc=jakub@redhat.com \
    /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).