PR27844, Unstable symbol name in objdump outputs

Message ID 20210511120941.GK25246@bubble.grove.modra.org
State New
Headers show
Series
  • PR27844, Unstable symbol name in objdump outputs
Related show

Commit Message

H.J. Lu via Binutils May 11, 2021, 12:09 p.m.
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.


-- 
Alan Modra
Australia Development Lab, IBM

Patch

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;