public inbox for binutils-cvs@sourceware.org
 help / color / mirror / Atom feed
* [binutils-gdb] skip_attr_bytes assertion (data) <= (end) fail
@ 2024-08-01 13:47 Alan Modra
  0 siblings, 0 replies; only message in thread
From: Alan Modra @ 2024-08-01 13:47 UTC (permalink / raw)
  To: binutils-cvs

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

commit 479c61163612f37d853efd21c40963459ef611d4
Author: Alan Modra <amodra@gmail.com>
Date:   Thu Aug 1 20:36:42 2024 +0930

    skip_attr_bytes assertion (data) <= (end) fail
    
    get_type_abbrev_from_form is lax in not limiting data for a uleb to
    the current CU, because DW_FORM_ref_addr allows access to other CU's
    data.  This can lead to an assertion fail when skipping or reading
    attributes in get_type_signedness.
    
            * dwarf.c (get_type_abbrev_from_form): Limit uleb data to map end
            for ref_addr, cu_end otherwise.

Diff:
---
 binutils/dwarf.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/binutils/dwarf.c b/binutils/dwarf.c
index 972bb920161..13a91624200 100644
--- a/binutils/dwarf.c
+++ b/binutils/dwarf.c
@@ -2119,7 +2119,10 @@ get_type_abbrev_from_form (unsigned long form,
 	*map_return = NULL;
     }
 
-  READ_ULEB (abbrev_number, data, section->start + section->size);
+  if (form == DW_FORM_ref_addr)
+    cu_end = section->start + map->end;
+
+  READ_ULEB (abbrev_number, data, cu_end);
 
   for (entry = map->list->first_abbrev; entry != NULL; entry = entry->next)
     if (entry->number == abbrev_number)

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

only message in thread, other threads:[~2024-08-01 13:47 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-08-01 13:47 [binutils-gdb] skip_attr_bytes assertion (data) <= (end) fail 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).