use strl*

This commit is contained in:
itojun 2003-05-17 21:05:10 +00:00
parent 0e1bb4cd82
commit 4005e1b9e9
2 changed files with 29 additions and 26 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: skeyinit.c,v 1.20 2002/11/16 05:24:44 itojun Exp $ */
/* $NetBSD: skeyinit.c,v 1.21 2003/05/17 21:05:10 itojun Exp $ */
/* S/KEY v1.1b (skeyinit.c)
*
@ -84,8 +84,8 @@ int main(int argc, char **argv)
defaultseed[SKEY_NAMELEN] = '\0';
(void)time(&now);
(void)sprintf(tbuf, "%05ld", (long) (now % 100000));
(void)strncat(defaultseed, tbuf, sizeof(defaultseed) - 5);
(void)snprintf(tbuf, sizeof(tbuf), "%05ld", (long) (now % 100000));
(void)strlcat(defaultseed, tbuf, sizeof(defaultseed));
if ((pp = getpwuid(getuid())) == NULL)
err(1, "no user with uid %ld", (u_long)getuid());
@ -169,7 +169,7 @@ int main(int argc, char **argv)
}
if (isdigit((unsigned char)lastc) && lastc == '9' &&
l < 16) {
(void)strncpy(defaultseed, skey.seed,
(void)strlcpy(defaultseed, skey.seed,
sizeof(defaultseed));
defaultseed[l - 1] = '0';
defaultseed[l] = '0';

View File

@ -1,4 +1,4 @@
/* $NetBSD: units.c,v 1.11 2002/08/31 07:26:17 kristerw Exp $ */
/* $NetBSD: units.c,v 1.12 2003/05/17 21:12:51 itojun Exp $ */
/*
* units.c Copyright (c) 1993 by Adrian Mariano (adrian@cam.cornell.edu)
@ -91,10 +91,9 @@ dupstr(char *str)
{
char *ret;
ret = malloc(strlen(str) + 1);
ret = strdup(str);
if (!ret)
err(3, "Memory allocation error");
strcpy(ret, str);
return (ret);
}
@ -131,17 +130,20 @@ readunits(char *userfile)
env = getenv("PATH");
if (env) {
if (strchr(env, ';'))
strcpy(separator, ";");
strlcpy(separator, ";",
sizeof(separator));
else
strcpy(separator, ":");
strlcpy(separator, ":",
sizeof(separator));
direc = strtok(env, separator);
while (direc) {
strcpy(filename, "");
strncat(filename, direc, 999);
strncat(filename, "/",
999 - strlen(filename));
strncat(filename, UNITSFILE,
999 - strlen(filename));
strlcpy(filename, "", sizeof(filename));
strlcat(filename, direc,
sizeof(filename));
strlcat(filename, "/",
sizeof(filename));
strlcat(filename, UNITSFILE,
sizeof(filename));
unitfile = fopen(filename, "rt");
if (unitfile)
break;
@ -459,7 +461,7 @@ lookupunit(char *unit)
copy[strlen(copy) - 1] = 0;
for (i = 0; i < unitcount; i++) {
if (!strcmp(unittable[i].uname, copy)) {
strcpy(buffer, copy);
strlcpy(buffer, copy, sizeof(buffer));
free(copy);
return buffer;
}
@ -471,7 +473,7 @@ lookupunit(char *unit)
copy[strlen(copy) - 1] = 0;
for (i = 0; i < unitcount; i++) {
if (!strcmp(unittable[i].uname, copy)) {
strcpy(buffer, copy);
strlcpy(buffer, copy, sizeof(buffer));
free(copy);
return buffer;
}
@ -480,7 +482,7 @@ lookupunit(char *unit)
copy[strlen(copy) - 1] = 0;
for (i = 0; i < unitcount; i++) {
if (!strcmp(unittable[i].uname, copy)) {
strcpy(buffer, copy);
strlcpy(buffer, copy, sizeof(buffer));
free(copy);
return buffer;
}
@ -493,9 +495,10 @@ lookupunit(char *unit)
strlen(prefixtable[i].prefixname))) {
unit += strlen(prefixtable[i].prefixname);
if (!strlen(unit) || lookupunit(unit)) {
strcpy(buffer, prefixtable[i].prefixval);
strcat(buffer, " ");
strcat(buffer, unit);
strlcpy(buffer, prefixtable[i].prefixval,
sizeof(buffer));
strlcat(buffer, " ", sizeof(buffer));
strlcat(buffer, unit, sizeof(buffer));
return buffer;
}
}
@ -682,17 +685,17 @@ main(int argc, char **argv)
readunits(userfile);
if (argc == 3) {
strcpy(havestr, argv[0]);
strcat(havestr, " ");
strcat(havestr, argv[1]);
strlcpy(havestr, argv[0], sizeof(havestr));
strlcat(havestr, " ", sizeof(havestr));
strlcat(havestr, argv[1], sizeof(havestr));
argc--;
argv++;
argv[0] = havestr;
}
if (argc == 2) {
strcpy(havestr, argv[0]);
strcpy(wantstr, argv[1]);
strlcpy(havestr, argv[0], sizeof(havestr));
strlcpy(wantstr, argv[1], sizeof(wantstr));
initializeunit(&have);
addunit(&have, havestr, 0);
completereduce(&have);