AArch64: Fix compile time warning

Nick Clifton nickc@redhat.com
Mon Jun 25 11:48:00 GMT 2018


Hi Guys,

  Whilst building various different toolchains using the 2.31 branch
  sources, I came across this compile time error:
  
/work/sources/binutils/branches/2.31/bfd/elfnn-aarch64.c: In function 'elf32_aarch64_size_stubs':
/work/sources/binutils/branches/2.31/bfd/elfnn-aarch64.c:3748:3: error: null destination pointer [-Werror=format-overflow=]
   sprintf (stub_name,"__erratum_835769_veneer_%d", num_fixes);

  So I am applying the patch below to the branch and the mainline, in
  order to fix the problem.

Cheers
  Nick

bfd/ChangeLog
2018-06-25  Nick Clifton  <nickc@redhat.com>

	* elfnn-aarch64.c (_bfd_aarch64_erratum_835769_stub_name): Check
	for malloc returning NULL.
	(_bfd_aarch64_erratum_843419_fixup): Check for
	_bfd_aarch64_erratum_835769_stub_name returning NULL.

diff --git a/bfd/elfnn-aarch64.c b/bfd/elfnn-aarch64.c
index 3ccca779ff..cf321f32c2 100644
--- a/bfd/elfnn-aarch64.c
+++ b/bfd/elfnn-aarch64.c
@@ -3745,7 +3745,8 @@ _bfd_aarch64_erratum_835769_stub_name (unsigned num_fixes)
 {
   char *stub_name = (char *) bfd_malloc
     (strlen ("__erratum_835769_veneer_") + 16);
-  sprintf (stub_name,"__erratum_835769_veneer_%d", num_fixes);
+  if (stub_name != NULL)
+    sprintf (stub_name,"__erratum_835769_veneer_%d", num_fixes);
   return stub_name;
 }
 
@@ -3992,6 +3993,8 @@ _bfd_aarch64_erratum_843419_fixup (uint32_t insn,
   struct elf_aarch64_stub_hash_entry *stub_entry;
 
   stub_name = _bfd_aarch64_erratum_843419_stub_name (section, ldst_offset);
+  if (stub_name == NULL)
+    return FALSE;
   stub_entry = aarch64_stub_hash_lookup (&htab->stub_hash_table, stub_name,
 					 FALSE, FALSE);
   if (stub_entry)



More information about the Binutils mailing list