Date: Tue, 4 Apr 2017 19:46:23 +0000 (UTC) From: Alan Somers <asomers@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r316500 - in head/usr.bin: banner fortune/strfile limits rpcinfo Message-ID: <201704041946.v34JkNQq045210@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: asomers Date: Tue Apr 4 19:46:23 2017 New Revision: 316500 URL: https://svnweb.freebsd.org/changeset/base/316500 Log: strcpy => strlcpy, strcat => strlcat Reported by: Coverity CID: 1006703 978863 1006745 1347163 Reviewed by: cem MFC after: 3 weeks Sponsored by: Spectra Logic Corp Differential Revision: https://reviews.freebsd.org/D10192 Modified: head/usr.bin/banner/banner.c head/usr.bin/fortune/strfile/strfile.c head/usr.bin/limits/limits.c head/usr.bin/rpcinfo/rpcinfo.c Modified: head/usr.bin/banner/banner.c ============================================================================== --- head/usr.bin/banner/banner.c Tue Apr 4 18:01:35 2017 (r316499) +++ head/usr.bin/banner/banner.c Tue Apr 4 19:46:23 2017 (r316500) @@ -1064,8 +1064,8 @@ main(int argc, char *argv[]) err(1, "malloc"); strcpy(message, *argv); while (*++argv) { - strcat(message, " "); - strcat(message, *argv); + strlcat(message, " ", j); + strlcat(message, *argv, j); } nchars = strlen(message); } else { Modified: head/usr.bin/fortune/strfile/strfile.c ============================================================================== --- head/usr.bin/fortune/strfile/strfile.c Tue Apr 4 18:01:35 2017 (r316499) +++ head/usr.bin/fortune/strfile/strfile.c Tue Apr 4 19:46:23 2017 (r316500) @@ -303,8 +303,8 @@ getargs(int argc, char **argv) usage(); } if (*Outfile == '\0') { - strcpy(Outfile, Infile); - strcat(Outfile, ".dat"); + strlcpy(Outfile, Infile, sizeof(Outfile)); + strlcat(Outfile, ".dat", sizeof(Outfile)); } } Modified: head/usr.bin/limits/limits.c ============================================================================== --- head/usr.bin/limits/limits.c Tue Apr 4 18:01:35 2017 (r316499) +++ head/usr.bin/limits/limits.c Tue Apr 4 19:46:23 2017 (r316500) @@ -561,7 +561,7 @@ print_limit(rlim_t limit, unsigned divis char numbr[64]; if (limit == RLIM_INFINITY) - strcpy(numbr, inf); + strlcpy(numbr, inf, sizeof(numbr)); else sprintf(numbr, "%jd", (intmax_t)((limit + divisor/2) / divisor)); printf(pfx, which, numbr); Modified: head/usr.bin/rpcinfo/rpcinfo.c ============================================================================== --- head/usr.bin/rpcinfo/rpcinfo.c Tue Apr 4 18:01:35 2017 (r316499) +++ head/usr.bin/rpcinfo/rpcinfo.c Tue Apr 4 19:46:23 2017 (r316500) @@ -856,9 +856,9 @@ failed: printf("%-10s", buf); buf[0] = '\0'; for (nl = rs->nlist; nl; nl = nl->next) { - strcat(buf, nl->netid); + strlcat(buf, nl->netid, sizeof(buf)); if (nl->next) - strcat(buf, ","); + strlcat(buf, ",", sizeof(buf)); } printf("%-32s", buf); rpc = getrpcbynumber(rs->prog);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201704041946.v34JkNQq045210>