aboutsummaryrefslogtreecommitdiff
path: root/bfd/aoutx.h
diff options
context:
space:
mode:
authorNick Clifton <nickc@redhat.com>2018-04-17 17:47:51 +0100
committerNick Clifton <nickc@redhat.com>2018-04-17 17:47:51 +0100
commit808346fcfcff1c3f2471c98e48613afd7bce3679 (patch)
tree0a0fc7a563dabb064b5db4a2032ecf764e985513 /bfd/aoutx.h
parentc4a91159afa222c1025f1535f42e382b91dc6b73 (diff)
downloadgdb-808346fcfcff1c3f2471c98e48613afd7bce3679.zip
gdb-808346fcfcff1c3f2471c98e48613afd7bce3679.tar.gz
gdb-808346fcfcff1c3f2471c98e48613afd7bce3679.tar.bz2
Fix illegal memory accesses trigeered when linking corrupt input files.
PR 23055 * aoutx.h (find_nearest_line): Check that the symbol name exists and is long enough, before attempting to see if it is for a .o file. * hash.c (bfd_hash_hash): Add an assertion that the string is not NULL. * linker.c (bfd_link_hash_lookup): Fail if the table or string are NULL. (_bfd_generic_link_add_archive_symbols): Fail if an archive entry has no name.
Diffstat (limited to 'bfd/aoutx.h')
-rw-r--r--bfd/aoutx.h9
1 files changed, 6 insertions, 3 deletions
diff --git a/bfd/aoutx.h b/bfd/aoutx.h
index 0e0bab0..7cc9561 100644
--- a/bfd/aoutx.h
+++ b/bfd/aoutx.h
@@ -2723,7 +2723,10 @@ NAME (aout, find_nearest_line) (bfd *abfd,
const char *symname;
symname = q->symbol.name;
- if (strcmp (symname + strlen (symname) - 2, ".o") == 0)
+
+ if (symname != NULL
+ && strlen (symname) > 2
+ && strcmp (symname + strlen (symname) - 2, ".o") == 0)
{
if (q->symbol.value > low_line_vma)
{
@@ -2788,8 +2791,8 @@ NAME (aout, find_nearest_line) (bfd *abfd,
case N_FUN:
{
/* We'll keep this if it is nearer than the one we have already. */
- if (q->symbol.value >= low_func_vma &&
- q->symbol.value <= offset)
+ if (q->symbol.value >= low_func_vma
+ && q->symbol.value <= offset)
{
low_func_vma = q->symbol.value;
func = (asymbol *)q;