aboutsummaryrefslogtreecommitdiff
path: root/gdb/dbxread.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/dbxread.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/dbxread.c')
-rw-r--r--gdb/dbxread.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/gdb/dbxread.c b/gdb/dbxread.c
index 7cddf65..4c585ef 100644
--- a/gdb/dbxread.c
+++ b/gdb/dbxread.c
@@ -479,14 +479,15 @@ record_minimal_symbol (minimal_symbol_reader &reader,
Record it as global even if it's local, not global, so
lookup_minimal_symbol can find it. We don't check symbol_leading_char
because for SunOS4 it always is '_'. */
- if (name[8] == 'C' && strcmp ("__DYNAMIC", name) == 0)
+ if (strcmp ("__DYNAMIC", name) == 0)
ms_type = mst_data;
/* Same with virtual function tables, both global and static. */
{
const char *tempstring = name;
- if (tempstring[0] == bfd_get_symbol_leading_char (objfile->obfd.get ()))
+ if (*tempstring
+ && *tempstring == bfd_get_symbol_leading_char (objfile->obfd.get ()))
++tempstring;
if (is_vtable_name (tempstring))
ms_type = mst_data;
@@ -2254,7 +2255,8 @@ read_ofile_symtab (struct objfile *objfile, legacy_psymtab *pst)
processing_gcc_compilation = 1;
else if (strcmp (namestring, GCC2_COMPILED_FLAG_SYMBOL) == 0)
processing_gcc_compilation = 2;
- if (tempstring[0] == bfd_get_symbol_leading_char (symfile_bfd))
+ if (*tempstring
+ && *tempstring == bfd_get_symbol_leading_char (symfile_bfd))
++tempstring;
if (startswith (tempstring, "__gnu_compiled"))
processing_gcc_compilation = 2;