svn commit: r344127 - stable/11/lib/libfigpar

Stefan Esser se at FreeBSD.org
Thu Feb 14 15:42:31 UTC 2019


Author: se
Date: Thu Feb 14 15:42:29 2019
New Revision: 344127
URL: https://svnweb.freebsd.org/changeset/base/344127

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/11/lib/libfigpar/string_m.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/lib/libfigpar/string_m.c
==============================================================================
--- stable/11/lib/libfigpar/string_m.c	Thu Feb 14 15:41:05 2019	(r344126)
+++ stable/11/lib/libfigpar/string_m.c	Thu Feb 14 15:42:29 2019	(r344127)
@@ -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