public inbox for elfutils@sourceware.org
 help / color / mirror / Atom feed
From: Mark Wielaard <mark@klomp.org>
To: elfutils-devel@sourceware.org
Cc: Mark Wielaard <mark@klomp.org>
Subject: [COMMITTED] libdw: Correct data end checkfor deref_type operand in dwarf_getlocation
Date: Tue, 14 Feb 2023 20:28:46 +0100	[thread overview]
Message-ID: <20230214192846.580713-1-mark@klomp.org> (raw)

In __libdw_intern_expression we checked for one byte too many.
We only need one byte for the size and (at least one) for the uleb128
DIE reference.

Signed-off-by: Mark Wielaard <mark@klomp.org>
---

This wrong check caused the recent buildbot failure on some arches.

 libdw/ChangeLog           | 5 +++++
 libdw/dwarf_getlocation.c | 2 +-
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/libdw/ChangeLog b/libdw/ChangeLog
index ddf14e55..e0cd8f21 100644
--- a/libdw/ChangeLog
+++ b/libdw/ChangeLog
@@ -1,3 +1,8 @@
+2023-02-14  Mark Wielaard  <mark@klomp.org>
+
+	* dwarf_getlocation.c (__libdw_intern_expression): Correct check
+	for deref_type.
+
 2023-02-10  Mark Wielaard  <mark@klomp.org>
 
 	* dwarf_getlocation.c (__libdw_intern_expression): Handle
diff --git a/libdw/dwarf_getlocation.c b/libdw/dwarf_getlocation.c
index 66eab3e9..553fdc98 100644
--- a/libdw/dwarf_getlocation.c
+++ b/libdw/dwarf_getlocation.c
@@ -546,7 +546,7 @@ __libdw_intern_expression (Dwarf *dbg, bool other_byte_order,
 	case DW_OP_deref_type:
 	case DW_OP_GNU_deref_type:
 	case DW_OP_xderef_type:
-	  if (unlikely (data + 2 >= end_data))
+	  if (unlikely (data + 1 >= end_data))
 	    goto invalid;
 	  newloc->number = *data++;
 	  get_uleb128 (newloc->number2, data, end_data);
-- 
2.31.1


                 reply	other threads:[~2023-02-14 19:28 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=20230214192846.580713-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).