From: vvvvvv@google.com
To: elfutils-devel@sourceware.org
Cc: kernel-team@android.com, maennich@google.com, vvvvvv@google.com
Subject: [PATCH] libdw: check offset dwarf_formstring in all cases
Date: Thu, 16 Nov 2023 21:29:22 +0000 [thread overview]
Message-ID: <20231116212922.4148717-1-vvvvvv@google.com> (raw)
From: Aleksei Vetrov <vvvvvv@google.com>
This check was initially added to test if offset overflows the safe
prefix where any string will be null-terminated. However the check
was placed in a wrong place and didn't cover all `attrp->form` cases.
* libdw/dwarf_formstring.c (dwarf_formstring): Move offset check
right before returning the result.
Signed-off-by: Aleksei Vetrov <vvvvvv@google.com>
---
libdw/dwarf_formstring.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/libdw/dwarf_formstring.c b/libdw/dwarf_formstring.c
index 0ee42411..65f03a5e 100644
--- a/libdw/dwarf_formstring.c
+++ b/libdw/dwarf_formstring.c
@@ -173,11 +173,11 @@ dwarf_formstring (Dwarf_Attribute *attrp)
off = read_4ubyte_unaligned (dbg, datap);
else
off = read_8ubyte_unaligned (dbg, datap);
-
- if (off >= data_size)
- goto invalid_offset;
}
+ if (off >= data_size)
+ goto invalid_offset;
+
return (const char *) data->d_buf + off;
}
INTDEF(dwarf_formstring)
--
2.43.0.rc1.413.gea7ed67945-goog
next reply other threads:[~2023-11-16 21:29 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-16 21:29 vvvvvv [this message]
2023-11-17 15:31 ` Mark Wielaard
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=20231116212922.4148717-1-vvvvvv@google.com \
--to=vvvvvv@google.com \
--cc=elfutils-devel@sourceware.org \
--cc=kernel-team@android.com \
--cc=maennich@google.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).