svn commit: r343941 - stable/12/lib/libfigpar

Stefan Esser se at FreeBSD.org
Sat Feb 9 14:44:19 UTC 2019


Author: se
Date: Sat Feb  9 14:44:17 2019
New Revision: 343941
URL: https://svnweb.freebsd.org/changeset/base/343941

Log:
  MFC r343480,343482: Silence Clang Scan warning about unsafe use of strcpy.
  
  Replace	strcpy() by memcpy to the previously allocated range of	known size.

Modified:
  stable/12/lib/libfigpar/string_m.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/lib/libfigpar/string_m.c
==============================================================================
--- stable/12/lib/libfigpar/string_m.c	Sat Feb  9 14:33:43 2019	(r343940)
+++ stable/12/lib/libfigpar/string_m.c	Sat Feb  9 14:44:17 2019	(r343941)
@@ -120,9 +120,9 @@ replaceall(char *source, const char *find, const char 
 	/* If replace is longer than find, we'll need to create a temp copy */
 	if (rlen > flen) {
 		temp = malloc(slen + 1);
-		if (errno != 0) /* could not allocate memory */
+		if (temp == NULL) /* could not allocate memory */
 			return (-1);
-		strcpy(temp, source);
+		memcpy(temp, source, slen + 1);
 	} else
 		temp = source;
 


More information about the svn-src-stable mailing list