Commit: AVR: Check for a NULL pointer before creating a stub name
Nick Clifton
nickc@redhat.com
Wed Aug 1 13:43:00 GMT 2018
Hi Guys,
I am checking in the patch below to fix a potential illegal memory
access in the AVR code, should bfd_malloc() return NULL.
Cheers
Nick
bfd/ChangeLog
2018-08-01 Nick Clifton <nickc@redhat.com>
* elf32-avr.c (avr_stub_name): Check for a NULL return from
bfd_malloc.
diff --git a/bfd/elf32-avr.c b/bfd/elf32-avr.c
index 7087606c93..6d38d1db3a 100644
--- a/bfd/elf32-avr.c
+++ b/bfd/elf32-avr.c
@@ -3295,10 +3295,10 @@ avr_stub_name (const asection *symbol_section,
len = 8 + 1 + 8 + 1 + 1;
stub_name = bfd_malloc (len);
-
- sprintf (stub_name, "%08x+%08x",
- symbol_section->id & 0xffffffff,
- (unsigned int) ((rela->r_addend & 0xffffffff) + symbol_offset));
+ if (stub_name != NULL)
+ sprintf (stub_name, "%08x+%08x",
+ symbol_section->id & 0xffffffff,
+ (unsigned int) ((rela->r_addend & 0xffffffff) + symbol_offset));
return stub_name;
}
More information about the Binutils
mailing list