diff options
author | Hakan Olsson <ho@cvs.openbsd.org> | 2003-04-06 17:57:46 +0000 |
---|---|---|
committer | Hakan Olsson <ho@cvs.openbsd.org> | 2003-04-06 17:57:46 +0000 |
commit | 3e28f790dc37ad1ea6b086cd4f2ccb29d07b1166 (patch) | |
tree | a1180dc808234d185d863cc6b97480d381f4a3eb | |
parent | ffb779eb9946f1908e42f24f0b7de38723048d19 (diff) |
strcpy/strcat cleanup. Ick millert@.
-rw-r--r-- | usr.bin/oldrdist/expand.c | 22 | ||||
-rw-r--r-- | usr.bin/oldrdist/server.c | 12 |
2 files changed, 18 insertions, 16 deletions
diff --git a/usr.bin/oldrdist/expand.c b/usr.bin/oldrdist/expand.c index 59b5c0fb914..4e29fbcd3a0 100644 --- a/usr.bin/oldrdist/expand.c +++ b/usr.bin/oldrdist/expand.c @@ -1,4 +1,4 @@ -/* $OpenBSD: expand.c,v 1.9 2002/02/16 21:27:50 millert Exp $ */ +/* $OpenBSD: expand.c,v 1.10 2003/04/06 17:57:45 ho Exp $ */ /* * Copyright (c) 1983, 1993 @@ -35,7 +35,7 @@ #ifndef lint /* from: static char sccsid[] = "@(#)expand.c 8.1 (Berkeley) 6/9/93"; */ -static char *rcsid = "$OpenBSD: expand.c,v 1.9 2002/02/16 21:27:50 millert Exp $"; +static char *rcsid = "$OpenBSD: expand.c,v 1.10 2003/04/06 17:57:45 ho Exp $"; #endif /* not lint */ #include "defs.h" @@ -49,6 +49,7 @@ static char shchars[] = "${[*?"; int which; /* bit mask of types to expand */ int eargc; /* expanded arg count */ char **eargv; /* expanded arg vectors */ +char pathbuf[BUFSIZ]; char *path; char *pathp; char *lastpathp; @@ -90,7 +91,6 @@ expand(list, wh) { struct namelist *nl, *prev; int n; - char pathbuf[BUFSIZ]; char *argvbuf[GAVSIZ]; if (debug) { @@ -212,7 +212,8 @@ expstr(s) *cp1 = '\0'; if (pw == NULL || strcmp(pw->pw_name, buf+1) != 0) { if ((pw = getpwnam(buf+1)) == NULL) { - strcat(buf, ": unknown user name"); + strlcat(buf, ": unknown user name", + sizeof buf); yyerror(buf+1); return; } @@ -319,7 +320,8 @@ matchdir(pattern) if (which & E_TILDE) Cat(path, dp->d_name); else { - strcpy(pathp, dp->d_name); + strlcpy(pathp, dp->d_name, + pathbuf + sizeof pathbuf - pathp); Cat(tilde, tpathp); *pathp = '\0'; } @@ -330,8 +332,8 @@ matchdir(pattern) patherr1: closedir(dirp); patherr2: - strcat(path, ": "); - strcat(path, strerror(errno)); + strlcat(path, ": ", pathbuf + sizeof pathbuf - path); + strlcat(path, strerror(errno), pathbuf + sizeof pathbuf - path); yyerror(path); } @@ -391,8 +393,8 @@ pend: doit: savec = *pm; *pm = 0; - strcpy(lm, pl); - strcat(restbuf, pe + 1); + strlcpy(lm, pl, restbuf + sizeof restbuf - lm); + strlcat(restbuf, pe + 1, sizeof restbuf); *pm = savec; if (s == 0) { spathp = pathp; @@ -630,7 +632,7 @@ exptilde(buf, file, maxlen) extern char homedir[]; if (*file != '~') { - strcpy(buf, file); + strlcpy(buf, file, maxlen); return(buf); } if (*++file == '\0') { diff --git a/usr.bin/oldrdist/server.c b/usr.bin/oldrdist/server.c index 1a28e4e64a0..c30785de140 100644 --- a/usr.bin/oldrdist/server.c +++ b/usr.bin/oldrdist/server.c @@ -1,4 +1,4 @@ -/* $OpenBSD: server.c,v 1.21 2003/04/05 17:18:26 deraadt Exp $ */ +/* $OpenBSD: server.c,v 1.22 2003/04/06 17:57:45 ho Exp $ */ /* * Copyright (c) 1983, 1993 @@ -35,7 +35,7 @@ #ifndef lint /* from: static char sccsid[] = "@(#)server.c 8.1 (Berkeley) 6/9/93"; */ -static char *rcsid = "$OpenBSD: server.c,v 1.21 2003/04/05 17:18:26 deraadt Exp $"; +static char *rcsid = "$OpenBSD: server.c,v 1.22 2003/04/06 17:57:45 ho Exp $"; #endif /* not lint */ #include <sys/wait.h> @@ -251,7 +251,7 @@ install(src, dest, destdir, opts) if (opts & WHOLE) source[0] = '\0'; else - strcpy(source, src); + strlcpy(source, src, sizeof source); if (dest == NULL) { opts &= ~WHOLE; /* WHOLE mode only useful if renaming */ @@ -582,10 +582,10 @@ savelink(stp) lp->inum = stp->st_ino; lp->devnum = stp->st_dev; lp->count = stp->st_nlink - 1; - strcpy(lp->pathname, target); - strcpy(lp->src, source); + strlcpy(lp->pathname, target, sizeof lp->pathname); + strlcpy(lp->src, source, sizeof lp->src); if (Tdest) - strcpy(lp->target, Tdest); + strlcpy(lp->target, Tdest, sizeof lp->target); else *lp->target = 0; } |