Skip to content

Commit

Permalink
strcpy => strlcpy, strcat => strlcat
Browse files Browse the repository at this point in the history
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
  • Loading branch information
asomers committed Apr 4, 2017
1 parent db36255 commit 9039018
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions usr.bin/banner/banner.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions usr.bin/fortune/strfile/strfile.c
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
}

Expand Down
2 changes: 1 addition & 1 deletion usr.bin/limits/limits.c
Original file line number Diff line number Diff line change
Expand Up @@ -561,7 +561,7 @@ print_limit(rlim_t limit, unsigned divisor, const char * inf, const char * pfx,
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);
Expand Down
4 changes: 2 additions & 2 deletions usr.bin/rpcinfo/rpcinfo.c
Original file line number Diff line number Diff line change
Expand Up @@ -856,9 +856,9 @@ rpcbdump(int dumptype, char *netid, int argc, char **argv)
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);
Expand Down

0 comments on commit 9039018

Please sign in to comment.