Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 14 Feb 2019 15:42:30 +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-11@freebsd.org
Subject:   svn commit: r344127 - stable/11/lib/libfigpar
Message-ID:  <201902141542.x1EFgUgc033784@repo.freebsd.org>

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



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