ld: sprintf sanitizer null destination pointer

* configure.ac (stpcpy): AC_CHECK_DECLS.
	* sysdep.h (stpcpy): Add fallback declaraion.
	* config.in: Regenerate.
	* configure: Regenerate.
	* emultempl/pe.em (open_dynamic_archive): Use
	stpcpy rather than sprintf plus strlen.
	* emultempl/pep.em (open_dynamic_archive): Likewise.
	* emultempl/xtensaelf.em (elf_xtensa_before_allocation): Use
	auto rather than malloc'd buffer.  Use sprintf count.
	* ldelf.c (ldelf_search_needed): Use memcpy in place of sprintf.
	* pe-dll.c (pe_process_import_defs): Use string already formed
	for alias match rather than recreating.
This commit is contained in:
Alan Modra
2023-08-03 08:40:12 +09:30
parent 23f6f86ca0
commit eaf1fa5ac5
9 changed files with 42 additions and 25 deletions

10
ld/configure vendored
View File

@@ -16771,6 +16771,16 @@ fi
cat >>confdefs.h <<_ACEOF
#define HAVE_DECL_ENVIRON $ac_have_decl
_ACEOF
ac_fn_c_check_decl "$LINENO" "stpcpy" "ac_cv_have_decl_stpcpy" "$ac_includes_default"
if test "x$ac_cv_have_decl_stpcpy" = xyes; then :
ac_have_decl=1
else
ac_have_decl=0
fi
cat >>confdefs.h <<_ACEOF
#define HAVE_DECL_STPCPY $ac_have_decl
_ACEOF