diff options
author | Nick Clifton <nickc@redhat.com> | 2021-04-29 17:55:43 +0100 |
---|---|---|
committer | Nick Clifton <nickc@redhat.com> | 2021-04-29 17:55:43 +0100 |
commit | 09e40e44ad05822ed72f6ad720b5e75ea2a8fc67 (patch) | |
tree | 5a6c2619aaeb62334cea7aaa6c7bf0b05f140c5e /bfd/som.c | |
parent | 063e75c9e4307d21b787a71b6d5b61a2560f5073 (diff) | |
download | gdb-09e40e44ad05822ed72f6ad720b5e75ea2a8fc67.zip gdb-09e40e44ad05822ed72f6ad720b5e75ea2a8fc67.tar.gz gdb-09e40e44ad05822ed72f6ad720b5e75ea2a8fc67.tar.bz2 |
Fix an access through a null pointer when parsing a corrupt SOM format fle.
PR 27793
* som.c (som_slurp_symbol_table): Assign symbols without any scope
to the undefined section.
(som_decode_symclass): Check for a missing symbol section.
* syms.c (bfd_decode_symclass): Likewise.
Diffstat (limited to 'bfd/som.c')
-rw-r--r-- | bfd/som.c | 11 |
1 files changed, 10 insertions, 1 deletions
@@ -4740,7 +4740,7 @@ som_slurp_symbol_table (bfd *abfd) goto error_return; } sym->symbol.value = bfd_getb32 (bufp->symbol_value); - sym->symbol.section = 0; + sym->symbol.section = NULL; sym->symbol.flags = 0; switch (symbol_type) @@ -4800,6 +4800,10 @@ som_slurp_symbol_table (bfd *abfd) sym->symbol.section = bfd_section_from_som_symbol (abfd, bufp); sym->symbol.value -= sym->symbol.section->vma; break; + + default: + sym->symbol.section = bfd_und_section_ptr; + break; } /* Check for a weak symbol. */ @@ -5848,6 +5852,11 @@ som_decode_symclass (asymbol *symbol) { char c; + /* If the symbol did not have a scope specified, + then it will not have associated section. */ + if (symbol == NULL || symbol->section == NULL) + return '?'; + if (bfd_is_com_section (symbol->section)) return 'C'; if (bfd_is_und_section (symbol->section)) |