This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Commit: AVR: Check for a NULL pointer before creating a stub name


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;
 }


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]