PR27844, Unstable symbol name in objdump outputs

Alan Modra amodra@gmail.com
Tue May 11 12:09:41 GMT 2021


Special care for fuzzers.

	PR 27844
	* pdp11.c (aout_get_external_symbols): Clear first four bytes of
	strings array, not just the first byte.
	* aoutx.h (aout_get_external_symbols): Likewise.

diff --git a/bfd/aoutx.h b/bfd/aoutx.h
index 76bb13c8e8d..17560bd8f54 100644
--- a/bfd/aoutx.h
+++ b/bfd/aoutx.h
@@ -1364,7 +1364,7 @@ aout_get_external_symbols (bfd *abfd)
 	    }
 	}
       /* Ensure that a zero index yields an empty string.  */
-      strings[0] = '\0';
+      memset (strings, 0, BYTES_IN_WORD);
 
       /* Ensure that the string buffer is NUL terminated.  */
       strings[stringsize] = 0;
diff --git a/bfd/pdp11.c b/bfd/pdp11.c
index 75ddf2038c2..2c9fe0ae56b 100644
--- a/bfd/pdp11.c
+++ b/bfd/pdp11.c
@@ -1344,7 +1344,7 @@ aout_get_external_symbols (bfd *abfd)
 	    }
 	}
       /* Ensure that a zero index yields an empty string.  */
-      strings[0] = '\0';
+      memset (strings, 0, BYTES_IN_LONG);
 
       /* Ensure that the string buffer is NUL terminated.  */
       strings[stringsize] = 0;

-- 
Alan Modra
Australia Development Lab, IBM


More information about the Binutils mailing list