Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 13 Apr 2017 23:22:18 +0000 (UTC)
From:      Conrad Meyer <cem@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r316797 - head/usr.bin/banner
Message-ID:  <201704132322.v3DNMIWh095362@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: cem
Date: Thu Apr 13 23:22:18 2017
New Revision: 316797
URL: https://svnweb.freebsd.org/changeset/base/316797

Log:
  banner(6): Squash a harmless coverity warning
  
  The destination buffer is sized as the sum of program argument lengths, so
  it has plenty of room for *argv.  Appease Coverity by using strlcpy instead
  of strcpy.  Similar to a nearby cleanup performed in r316500.
  
  No functional change.
  
  Reported by:	Coverity (CWE-120)
  CID:		1006703
  Sponsored by:	Dell EMC Isilon

Modified:
  head/usr.bin/banner/banner.c

Modified: head/usr.bin/banner/banner.c
==============================================================================
--- head/usr.bin/banner/banner.c	Thu Apr 13 23:00:26 2017	(r316796)
+++ head/usr.bin/banner/banner.c	Thu Apr 13 23:22:18 2017	(r316797)
@@ -1062,7 +1062,7 @@ main(int argc, char *argv[])
 			j += strlen(argv[i]) + 1;
 		if ((message = malloc((size_t)j)) == NULL) 
 			err(1, "malloc");
-		strcpy(message, *argv);
+		strlcpy(message, *argv, j);
 		while (*++argv) {
 			strlcat(message, " ", j);
 			strlcat(message, *argv, j);



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