* [PATCH] readelf: Return correct readp (or readendp) from print_form_data.
@ 2018-06-11 9:33 Mark Wielaard
2018-06-11 17:03 ` Mark Wielaard
0 siblings, 1 reply; 2+ messages in thread
From: Mark Wielaard @ 2018-06-11 9:33 UTC (permalink / raw)
To: elfutils-devel; +Cc: Mark Wielaard
print_form_data returns the new readp (or readendp on error) to show how
much data was consumed. But when reading the .debug_str_offsets section
we would reuse readp and readendp. This meant the wrong readp would be
returned to the caller.
Signed-off-by: Mark Wielaard <mark@klomp.org>
---
src/ChangeLog | 5 +++++
src/readelf.c | 10 +++++-----
2 files changed, 10 insertions(+), 5 deletions(-)
diff --git a/src/ChangeLog b/src/ChangeLog
index 6484b9a..fd45405 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,8 @@
+2018-06-11 Mark Wielaard <mark@klomp.org>
+
+ * readelf.c (print_form_data): Don't reuse readp and readendp when
+ reading str_offsets section.
+
2018-06-10 Mark Wielaard <mark@klomp.org>
* readelf.c (print_form_data): Don't cast value to ptrdiff_t, cast
diff --git a/src/readelf.c b/src/readelf.c
index fbda6c1..f185897 100644
--- a/src/readelf.c
+++ b/src/readelf.c
@@ -7986,17 +7986,17 @@ print_form_data (Dwarf *dbg, int form, const unsigned char *readp,
str = "???";
else
{
- readp = data->d_buf + str_offsets_base + val;
- readendp = data->d_buf + data->d_size;
- if ((size_t) (readendp - readp) < offset_len)
+ const unsigned char *strreadp = data->d_buf + str_offsets_base + val;
+ const unsigned char *strreadendp = data->d_buf + data->d_size;
+ if ((size_t) (strreadendp - strreadp) < offset_len)
str = "???";
else
{
Dwarf_Off idx;
if (offset_len == 8)
- idx = read_8ubyte_unaligned_inc (dbg, readp);
+ idx = read_8ubyte_unaligned_inc (dbg, strreadp);
else
- idx = read_4ubyte_unaligned_inc (dbg, readp);
+ idx = read_4ubyte_unaligned_inc (dbg, strreadp);
data = dbg->sectiondata[IDX_debug_str];
if (data == NULL || idx >= data->d_size
--
1.8.3.1
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] readelf: Return correct readp (or readendp) from print_form_data.
2018-06-11 9:33 [PATCH] readelf: Return correct readp (or readendp) from print_form_data Mark Wielaard
@ 2018-06-11 17:03 ` Mark Wielaard
0 siblings, 0 replies; 2+ messages in thread
From: Mark Wielaard @ 2018-06-11 17:03 UTC (permalink / raw)
To: elfutils-devel
On Mon, Jun 11, 2018 at 11:33:14AM +0200, Mark Wielaard wrote:
> print_form_data returns the new readp (or readendp on error) to show how
> much data was consumed. But when reading the .debug_str_offsets section
> we would reuse readp and readendp. This meant the wrong readp would be
> returned to the caller.
Pushed to master.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2018-06-11 17:03 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-06-11 9:33 [PATCH] readelf: Return correct readp (or readendp) from print_form_data Mark Wielaard
2018-06-11 17:03 ` 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).