aboutsummaryrefslogtreecommitdiff
path: root/gdb/coffread.c
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2023-08-22 21:20:57 +0930
committerAlan Modra <amodra@gmail.com>2023-08-23 10:07:45 +0930
commit0e3513d256c3b4475aa7fae33d20e073c3a3b929 (patch)
tree0bc89a155b4fd5546fac05bd029c943c464dbd26 /gdb/coffread.c
parent8c8145a43ee4815b8851f8da7091c04f551dff6e (diff)
downloadgdb-0e3513d256c3b4475aa7fae33d20e073c3a3b929.zip
gdb-0e3513d256c3b4475aa7fae33d20e073c3a3b929.tar.gz
gdb-0e3513d256c3b4475aa7fae33d20e073c3a3b929.tar.bz2
gdb: bfd_get_symbol_leading_char vs. ""
Some places matching the first char of a string against bfd_get_symbol_leading_char, which may be zero, didn't check for "". This could lead to accesses past the end of the string and potential buffer overruns. Fix that, and also get rid of a stupid optimisation in dbxread when looking for "__DYNAMIC" that also might access past the end of a string.
Diffstat (limited to 'gdb/coffread.c')
-rw-r--r--gdb/coffread.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/gdb/coffread.c b/gdb/coffread.c
index 1361099..7998327 100644
--- a/gdb/coffread.c
+++ b/gdb/coffread.c
@@ -64,8 +64,8 @@ static const registry<objfile>::key<coff_symfile_info> coff_objfile_data_key;
/* Translate an external name string into a user-visible name. */
#define EXTERNAL_NAME(string, abfd) \
- (string[0] == bfd_get_symbol_leading_char (abfd) \
- ? string + 1 : string)
+ (*string && *string == bfd_get_symbol_leading_char (abfd) \
+ ? string + 1 : string)
/* To be an sdb debug type, type must have at least a basic or primary
derived type. Using this rather than checking against T_NULL is