diff mbox series

libdwfl: Make sure the note len increases each iteration

Message ID 20211217171224.5407-1-mark@klomp.org
State Committed
Headers show
Series libdwfl: Make sure the note len increases each iteration | expand

Commit Message

Mark Wielaard Dec. 17, 2021, 5:12 p.m. UTC
In dwfl_segment_report_module we have an overflow check when reading
notes, but we could still not make any progress if the number of bytes
read (len) didn't increase at all. Check len > last_len.

Signed-off-by: Mark Wielaard <mark@klomp.org>
---
 libdwfl/ChangeLog                    | 5 +++++
 libdwfl/dwfl_segment_report_module.c | 2 +-
 2 files changed, 6 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/libdwfl/ChangeLog b/libdwfl/ChangeLog
index 21f3b6a4..a1288d44 100644
--- a/libdwfl/ChangeLog
+++ b/libdwfl/ChangeLog
@@ -1,3 +1,8 @@ 
+2021-12-08  Mark Wielaard  <mark@klomp.org>
+
+	* dwfl_segment_report_module.c (dwfl_segment_report_module): Make
+	sure the note len increases each iteration.
+
 2021-12-17  Mark Wielaard  <mark@klomp.org>
 
 	* libdwflP.h (dwfl_segment_report_module): Add maxread argument.
diff --git a/libdwfl/dwfl_segment_report_module.c b/libdwfl/dwfl_segment_report_module.c
index 73704efe..cad1a9b3 100644
--- a/libdwfl/dwfl_segment_report_module.c
+++ b/libdwfl/dwfl_segment_report_module.c
@@ -559,7 +559,7 @@  dwfl_segment_report_module (Dwfl *dwfl, int ndx, const char *name,
                   note_desc = notes + len;
 
                   if (unlikely (filesz < len + nh->n_descsz
-                                || len < last_len
+                                || len <= last_len
                                 || len + nh->n_descsz < last_len))
                     break;