aboutsummaryrefslogtreecommitdiff
path: root/gdb/dwarf2read.c
diff options
context:
space:
mode:
authorAndrew Cagney <cagney@redhat.com>1997-11-26 12:35:07 +0000
committerAndrew Cagney <cagney@redhat.com>1997-11-26 12:35:07 +0000
commit3199620a493eb1dd2dbc064bc520e386d2fb9114 (patch)
tree0c32925ecf400683eca3a984b4a5b3f2687b5c5c /gdb/dwarf2read.c
parent0d5d0d102d7ccd8fc9a1f1729175bb1cad6eb6a9 (diff)
downloadgdb-3199620a493eb1dd2dbc064bc520e386d2fb9114.zip
gdb-3199620a493eb1dd2dbc064bc520e386d2fb9114.tar.gz
gdb-3199620a493eb1dd2dbc064bc520e386d2fb9114.tar.bz2
Check the abbrev offset found in the .debug_info section before using
it.
Diffstat (limited to 'gdb/dwarf2read.c')
-rw-r--r--gdb/dwarf2read.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
index a754a84..e12953d 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -147,9 +147,9 @@ static unsigned int dwarf_str_size;
/* The data in a compilation unit header looks like this. */
struct comp_unit_head
{
- int length;
+ unsigned int length;
short version;
- int abbrev_offset;
+ unsigned int abbrev_offset;
unsigned char addr_size;
};
@@ -932,6 +932,16 @@ dwarf2_build_psymtabs_hard (objfile, section_offsets, mainline)
error ("Dwarf Error: wrong version in compilation unit header.");
return;
}
+ if (cu_header.abbrev_offset >= dwarf_abbrev_size)
+ {
+ error ("Dwarf Error: bad offset in compilation unit header.");
+ return;
+ }
+ if (cu_header.length > dwarf_abbrev_size - cu_header.abbrev_offset)
+ {
+ error ("Dwarf Error: bad length in compilation unit header.");
+ return;
+ }
/* Read the abbrevs for this compilation unit into a table */
dwarf2_read_abbrevs (abfd, cu_header.abbrev_offset);