Signed-off-by: Mark Wielaard <[email protected]>
---
 src/ChangeLog | 5 +++++
 src/readelf.c | 3 ++-
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/src/ChangeLog b/src/ChangeLog
index 00a587c..7203dd9 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,5 +1,10 @@
 2014-12-20  Mark Wielaard  <[email protected]>
 
+       * readelf.c (print_debug_macinfo_section): Mark cus sentinel files
+       as -1 non-existent. Check macoff against sentinel cus.
+
+2014-12-20  Mark Wielaard  <[email protected]>
+
        * readelf.c (print_debug_exception_table): Add max_action overflow
        check. Check action_table_end before reading slib128. Check
        max_ar_filter underflow.
diff --git a/src/readelf.c b/src/readelf.c
index a05b238..237975f 100644
--- a/src/readelf.c
+++ b/src/readelf.c
@@ -7061,6 +7061,7 @@ print_debug_macinfo_section (Dwfl_Module *dwflmod 
__attribute__ ((unused)),
                                                         * sizeof (*cus));
   /* Add sentinel.  */
   cus[nculist].offset = data->d_size;
+  cus[nculist].files = (Dwarf_Files *) -1l;
   if (nculist > 0)
     {
       for (size_t cnt = nculist - 1; culist != NULL; --cnt)
@@ -7136,7 +7137,7 @@ print_debug_macinfo_section (Dwfl_Module *dwflmod 
__attribute__ ((unused)),
          const char *fname = "???";
          if (macoff >= cus[0].offset)
            {
-             while (macoff >= cus[1].offset)
+             while (macoff >= cus[1].offset && cus[1].offset != data->d_size)
                ++cus;
 
              if (cus[0].files == NULL
-- 
2.1.0

Reply via email to