Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 9 Feb 2019 14:44:18 +0000 (UTC)
From:      Stefan Esser <se@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org
Subject:   svn commit: r343941 - stable/12/lib/libfigpar
Message-ID:  <201902091444.x19EiI9w085144@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
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;
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201902091444.x19EiI9w085144>