public inbox for binutils-cvs@sourceware.org
 help / color / mirror / Atom feed
* [binutils-gdb] Tidy PR29893 and PR29908 fix
@ 2022-12-19 13:27 Alan Modra
  0 siblings, 0 replies; only message in thread
From: Alan Modra @ 2022-12-19 13:27 UTC (permalink / raw)
  To: bfd-cvs

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=956bc7a29fd952d709db29667b38f98cdd3db4c9

commit 956bc7a29fd952d709db29667b38f98cdd3db4c9
Author: Alan Modra <amodra@gmail.com>
Date:   Sun Dec 18 13:07:51 2022 +1030

    Tidy PR29893 and PR29908 fix
    
            PR 29893
            PR 29908
            * dwarf.c (display_debug_addr): Combine dwarf5 unit_length checks.
            Delete dead code.

Diff:
---
 binutils/dwarf.c | 24 ++++--------------------
 1 file changed, 4 insertions(+), 20 deletions(-)

diff --git a/binutils/dwarf.c b/binutils/dwarf.c
index b792902c496..a00568dd3d8 100644
--- a/binutils/dwarf.c
+++ b/binutils/dwarf.c
@@ -7738,19 +7738,14 @@ display_debug_addr (struct dwarf_section *section,
 	  SAFE_BYTE_GET_AND_INC (length, curr_header, 4, entry);
 	  if (length == 0xffffffff)
 	    SAFE_BYTE_GET_AND_INC (length, curr_header, 8, entry);
-	  if (length > (size_t) (section->start + section->size - curr_header))
+	  if (length > (size_t) (section->start + section->size - curr_header)
+	      || length < (size_t) (entry - curr_header))
 	    {
 	      warn (_("Corrupt %s section: unit_length field of %#" PRIx64
-		      " too large\n"), section->name, length);
+		      " is invalid\n"), section->name, length);
 	      return 0;
 	    }
 	  end = curr_header + length;
-	  if (end < entry)
-	    {
-	      warn (_("Corrupt %s section header: length field (%lx) is too small\n"),
-		    section->name, (long) length);
-	      return 0;
-	    }
 	  SAFE_BYTE_GET_AND_INC (version, curr_header, 2, entry);
 	  if (version != 5)
 	    warn (_("Corrupt %s section: expecting version number 5 in header but found %d instead\n"),
@@ -7761,18 +7756,7 @@ display_debug_addr (struct dwarf_section *section,
 	  address_size += segment_selector_size;
 	}
       else
-	{
-	  end = section->start + debug_addr_info [i + 1]->addr_base;
-
-	  if (end < entry)
-	    {
-	      warn (_("Corrupt %s section: address base of entry %u (%lx) is less than entry %u (%lx)\n"),
-		    section->name,
-		    i, (long) debug_addr_info [i]->addr_base,
-		    i + 1, (long) debug_addr_info [i + 1]->addr_base);
-	      return 0;
-	    }
-	}
+	end = section->start + debug_addr_info [i + 1]->addr_base;
 
       header = end;
       idx = 0;

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-12-19 13:27 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-19 13:27 [binutils-gdb] Tidy PR29893 and PR29908 fix Alan Modra

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).