use bounded string op

This commit is contained in:
itojun 2003-07-23 04:11:12 +00:00
parent 8556dff80c
commit e97c220e91
5 changed files with 24 additions and 24 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: docmd.c,v 1.23 2003/07/12 13:41:21 itojun Exp $ */ /* $NetBSD: docmd.c,v 1.24 2003/07/23 04:11:12 itojun Exp $ */
/* /*
* Copyright (c) 1983, 1993 * Copyright (c) 1983, 1993
@ -38,7 +38,7 @@
#if 0 #if 0
static char sccsid[] = "@(#)docmd.c 8.1 (Berkeley) 6/9/93"; static char sccsid[] = "@(#)docmd.c 8.1 (Berkeley) 6/9/93";
#else #else
__RCSID("$NetBSD: docmd.c,v 1.23 2003/07/12 13:41:21 itojun Exp $"); __RCSID("$NetBSD: docmd.c,v 1.24 2003/07/23 04:11:12 itojun Exp $");
#endif #endif
#endif /* not lint */ #endif /* not lint */
@ -335,7 +335,7 @@ lostconn(int signo)
} }
if (nr <= 0) if (nr <= 0)
(void) strcpy(buf, "lost connection"); (void) strlcpy(buf, "lost connection", sizeof(buf));
if (iamremote) if (iamremote)
cleanup(0); cleanup(0);

View File

@ -1,4 +1,4 @@
/* $NetBSD: expand.c,v 1.14 2002/06/14 01:18:54 wiz Exp $ */ /* $NetBSD: expand.c,v 1.15 2003/07/23 04:11:12 itojun Exp $ */
/* /*
* Copyright (c) 1983, 1993 * Copyright (c) 1983, 1993
@ -38,7 +38,7 @@
#if 0 #if 0
static char sccsid[] = "@(#)expand.c 8.1 (Berkeley) 6/9/93"; static char sccsid[] = "@(#)expand.c 8.1 (Berkeley) 6/9/93";
#else #else
__RCSID("$NetBSD: expand.c,v 1.14 2002/06/14 01:18:54 wiz Exp $"); __RCSID("$NetBSD: expand.c,v 1.15 2003/07/23 04:11:12 itojun Exp $");
#endif #endif
#endif /* not lint */ #endif /* not lint */
@ -218,7 +218,8 @@ expstr(char *s)
*cp1 = '\0'; *cp1 = '\0';
if (pw == NULL || strcmp(pw->pw_name, buf+1) != 0) { if (pw == NULL || strcmp(pw->pw_name, buf+1) != 0) {
if ((pw = getpwnam(buf+1)) == NULL) { if ((pw = getpwnam(buf+1)) == NULL) {
strcat(buf, ": unknown user name"); strlcat(buf, ": unknown user name",
sizeof(buf));
yyerror(buf+1); yyerror(buf+1);
return; return;
} }
@ -393,8 +394,8 @@ pend:
doit: doit:
savec = *pm; savec = *pm;
*pm = 0; *pm = 0;
strcpy(lm, pl); strlcpy(lm, pl, sizeof(restbuf) - (lm - restbuf));
strcat(restbuf, pe + 1); strlcat(restbuf, pe + 1, sizeof(restbuf));
*pm = savec; *pm = savec;
if (s == 0) { if (s == 0) {
spathp = pathp; spathp = pathp;

View File

@ -1,4 +1,4 @@
/* $NetBSD: main.c,v 1.13 2002/06/14 01:18:55 wiz Exp $ */ /* $NetBSD: main.c,v 1.14 2003/07/23 04:11:13 itojun Exp $ */
/* /*
* Copyright (c) 1983, 1993 * Copyright (c) 1983, 1993
@ -43,7 +43,7 @@ __COPYRIGHT("@(#) Copyright (c) 1983, 1993\n\
#if 0 #if 0
static char sccsid[] = "@(#)main.c 8.1 (Berkeley) 6/9/93"; static char sccsid[] = "@(#)main.c 8.1 (Berkeley) 6/9/93";
#else #else
__RCSID("$NetBSD: main.c,v 1.13 2002/06/14 01:18:55 wiz Exp $"); __RCSID("$NetBSD: main.c,v 1.14 2003/07/23 04:11:13 itojun Exp $");
#endif #endif
#endif /* not lint */ #endif /* not lint */
@ -101,13 +101,13 @@ main(int argc, char **argv)
fprintf(stderr, "%s: Who are you?\n", argv[0]); fprintf(stderr, "%s: Who are you?\n", argv[0]);
exit(1); exit(1);
} }
strcpy(user, pw->pw_name); strlcpy(user, pw->pw_name, sizeof(user));
strcpy(homedir, pw->pw_dir); strlcpy(homedir, pw->pw_dir, sizeof(homedir));
groupid = pw->pw_gid; groupid = pw->pw_gid;
gethostname(host, sizeof(host)); gethostname(host, sizeof(host));
host[sizeof(host) - 1] = '\0'; host[sizeof(host) - 1] = '\0';
strcpy(tempfile, _PATH_TMP); strlcpy(tempfile, _PATH_TMP, sizeof(tempfile));
strcat(tempfile, _RDIST_TMP); strlcat(tempfile, _RDIST_TMP, sizeof(tempfile));
if ((tempname = strrchr(tempfile, '/')) != 0) if ((tempname = strrchr(tempfile, '/')) != 0)
tempname++; tempname++;
else else

View File

@ -1,4 +1,4 @@
/* $NetBSD: server.c,v 1.25 2003/01/20 05:30:12 simonb Exp $ */ /* $NetBSD: server.c,v 1.26 2003/07/23 04:11:13 itojun Exp $ */
/* /*
* Copyright (c) 1983, 1993 * Copyright (c) 1983, 1993
@ -38,7 +38,7 @@
#if 0 #if 0
static char sccsid[] = "@(#)server.c 8.1 (Berkeley) 6/9/93"; static char sccsid[] = "@(#)server.c 8.1 (Berkeley) 6/9/93";
#else #else
__RCSID("$NetBSD: server.c,v 1.25 2003/01/20 05:30:12 simonb Exp $"); __RCSID("$NetBSD: server.c,v 1.26 2003/07/23 04:11:13 itojun Exp $");
#endif #endif
#endif /* not lint */ #endif /* not lint */
@ -301,7 +301,7 @@ install(char *src, char *dest, int destdir, int opts)
return; return;
if (destdir) { if (destdir) {
strcpy(destcopy, dest); strlcpy(destcopy, dest, sizeof(destcopy));
Tdest = destcopy; Tdest = destcopy;
} }
sendf(rname, opts); sendf(rname, opts);
@ -571,9 +571,9 @@ savelink(struct stat *stp)
lp->inum = stp->st_ino; lp->inum = stp->st_ino;
lp->devnum = stp->st_dev; lp->devnum = stp->st_dev;
lp->count = stp->st_nlink - 1; lp->count = stp->st_nlink - 1;
strcpy(lp->pathname, target); strlcpy(lp->pathname, target, sizeof(lp->pathname));
if (Tdest) if (Tdest)
strcpy(lp->target, Tdest); strlcpy(lp->target, Tdest, sizeof(lp->target));
else else
*lp->target = 0; *lp->target = 0;
} }
@ -831,7 +831,7 @@ recvf(char *cmd, int type)
(void) snprintf(tp, sizeof(target) - (tp - target), "/%s", cp); (void) snprintf(tp, sizeof(target) - (tp - target), "/%s", cp);
cp = strrchr(target, '/'); cp = strrchr(target, '/');
if (cp == NULL) if (cp == NULL)
strcpy(new, tempname); strlcpy(new, tempname, sizeof(new));
else if (cp == target) else if (cp == target)
(void) snprintf(new, sizeof(new), "/%s", tempname); (void) snprintf(new, sizeof(new), "/%s", tempname);
else { else {

View File

@ -1,4 +1,4 @@
/* $NetBSD: skeyinfo.c,v 1.3 1997/11/08 09:37:44 lukem Exp $ */ /* $NetBSD: skeyinfo.c,v 1.4 2003/07/23 04:11:50 itojun Exp $ */
/*- /*-
* Copyright (c) 1997 The NetBSD Foundation, Inc. * Copyright (c) 1997 The NetBSD Foundation, Inc.
@ -38,7 +38,7 @@
#include <sys/cdefs.h> #include <sys/cdefs.h>
#ifndef lint #ifndef lint
__RCSID("$NetBSD: skeyinfo.c,v 1.3 1997/11/08 09:37:44 lukem Exp $"); __RCSID("$NetBSD: skeyinfo.c,v 1.4 2003/07/23 04:11:50 itojun Exp $");
#endif #endif
#include <stdio.h> #include <stdio.h>
@ -82,8 +82,7 @@ main(argc, argv)
errx(1, "who are you?"); errx(1, "who are you?");
} }
(void) strncpy(name, pw->pw_name, sizeof(name)); (void) strlcpy(name, pw->pw_name, sizeof(name));
name[sizeof(name) - 1] = '\0';
if (getskeyprompt(&skey, name, prompt) == -1) { if (getskeyprompt(&skey, name, prompt) == -1) {
printf("%s %s no s/key\n", printf("%s %s no s/key\n",