From 09e40e44ad05822ed72f6ad720b5e75ea2a8fc67 Mon Sep 17 00:00:00 2001 From: Nick Clifton Date: Thu, 29 Apr 2021 17:55:43 +0100 Subject: 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. --- bfd/som.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'bfd/som.c') diff --git a/bfd/som.c b/bfd/som.c index 656ded9..42ecc76 100644 --- a/bfd/som.c +++ b/bfd/som.c @@ -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)) -- cgit v1.1