diff options
author | Andrew Burgess <andrew.burgess@embecosm.com> | 2018-11-06 19:55:21 +0000 |
---|---|---|
committer | Andrew Burgess <andrew.burgess@embecosm.com> | 2018-11-07 12:58:56 +0000 |
commit | 35ee2dc2e4de8b1ae73f420d5db3375f92300b70 (patch) | |
tree | 0e3bf62a6485e3d8d9345ed6d3a404919ab43076 /gdb/dwarf2read.c | |
parent | 42d4c301c45df41d1c724b7b86f8683a875c010a (diff) | |
download | fsf-binutils-gdb-35ee2dc2e4de8b1ae73f420d5db3375f92300b70.zip fsf-binutils-gdb-35ee2dc2e4de8b1ae73f420d5db3375f92300b70.tar.gz fsf-binutils-gdb-35ee2dc2e4de8b1ae73f420d5db3375f92300b70.tar.bz2 |
gdb: Guard against NULL dereference in dwarf2_init_integer_type
In this commit:
commit eb77c9df9f6d2f7aa644a170280fe31ce080f887
Date: Thu Oct 18 14:04:27 2018 +0100
gdb: Handle ICC's unexpected void return type
A potential dereference of a NULL pointer was introduced if a
DW_TAG_base_type is missing a DW_AT_name attribute.
I have taken this opportunity to fix a slight confusion that existed
in the test also added in the above commit, the test had two C
variables, declared like this:
int var_a = 5;
void *var_ptr = &var_a;
However, the fake DWARF in the test script declared them like this:
void var_a = 5;
void *var_ptr = &var_a;
This wasn't a problem as the test never uses 'var_a' directly, this
only exists so 'var_ptr' can be initialised. However, it seemed worth
fixing.
I've also added a test for a DW_TAG_base_type with a missing
DW_AT_name, as clearly there's not test currently that covers this
(the original patch tested cleanly). I can confirm that the new test
causes GDB to crash before this patch, and passes with this patch.
gdb/ChangeLog:
* dwarf2read.c (dwarf2_init_integer_type): Check for name being
NULL before dereferencing it.
gdb/testsuite/ChangeLog:
* gdb.dwarf2/void-type.exp: Rename types, and make var_a an 'int'.
* gdb.dwarf2/missing-type-name.exp: New file.
Diffstat (limited to 'gdb/dwarf2read.c')
-rw-r--r-- | gdb/dwarf2read.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c index b237c81..d2a8cd4 100644 --- a/gdb/dwarf2read.c +++ b/gdb/dwarf2read.c @@ -17522,7 +17522,8 @@ dwarf2_init_integer_type (struct dwarf2_cu *cu, struct objfile *objfile, /* Versions of Intel's C Compiler generate an integer type called "void" instead of using DW_TAG_unspecified_type. This has been seen on at least versions 14, 17, and 18. */ - if (bits == 0 && producer_is_icc (cu) && strcmp (name, "void") == 0) + if (bits == 0 && producer_is_icc (cu) && name != nullptr + && strcmp (name, "void") == 0) type = objfile_type (objfile)->builtin_void; else type = init_integer_type (objfile, bits, unsigned_p, name); |