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
This commit is contained in:
Alan Somers 2017-04-04 19:46:23 +00:00
parent db3625531e
commit 9039018c34
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=316500
4 changed files with 7 additions and 7 deletions

View File

@ -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 {

View File

@ -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));
}
}

View File

@ -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);

View File

@ -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);