diff options
author | 2015-01-16 06:39:28 +0000 | |
---|---|---|
committer | 2015-01-16 06:39:28 +0000 | |
commit | b9fc9a728fce9c4289b7e9a992665e28d5629a54 (patch) | |
tree | 72b2433e418dfa1aef5fcf8305617b97979a25d8 /bin/csh | |
parent | improve checksum parsing slightly. now handles filenames with spaces. (diff) | |
download | wireguard-openbsd-b9fc9a728fce9c4289b7e9a992665e28d5629a54.tar.xz wireguard-openbsd-b9fc9a728fce9c4289b7e9a992665e28d5629a54.zip |
Replace <sys/param.h> with <limits.h> and other less dirty headers where
possible. Annotate <sys/param.h> lines with their current reasons. Switch
to PATH_MAX, NGROUPS_MAX, HOST_NAME_MAX+1, LOGIN_NAME_MAX, etc. Change
MIN() and MAX() to local definitions of MINIMUM() and MAXIMUM() where
sensible to avoid pulling in the pollution. These are the files confirmed
through binary verification.
ok guenther, millert, doug (helped with the verification protocol)
Diffstat (limited to 'bin/csh')
-rw-r--r-- | bin/csh/csh.c | 6 | ||||
-rw-r--r-- | bin/csh/dir.c | 20 | ||||
-rw-r--r-- | bin/csh/exec.c | 10 | ||||
-rw-r--r-- | bin/csh/file.c | 17 | ||||
-rw-r--r-- | bin/csh/glob.c | 19 | ||||
-rw-r--r-- | bin/csh/sem.c | 9 |
6 files changed, 42 insertions, 39 deletions
diff --git a/bin/csh/csh.c b/bin/csh/csh.c index fb908d3f9d8..c1d88b80c3a 100644 --- a/bin/csh/csh.c +++ b/bin/csh/csh.c @@ -1,4 +1,4 @@ -/* $OpenBSD: csh.c,v 1.26 2014/10/16 19:43:31 deraadt Exp $ */ +/* $OpenBSD: csh.c,v 1.27 2015/01/16 06:39:31 deraadt Exp $ */ /* $NetBSD: csh.c,v 1.14 1995/04/29 23:21:28 mycroft Exp $ */ /*- @@ -33,7 +33,6 @@ #include <sys/types.h> #include <sys/ioctl.h> #include <sys/stat.h> -#include <sys/param.h> #include <fcntl.h> #include <errno.h> #include <pwd.h> @@ -41,6 +40,7 @@ #include <string.h> #include <locale.h> #include <unistd.h> +#include <limits.h> #include <vis.h> #include <stdarg.h> @@ -207,7 +207,7 @@ main(int argc, char *argv[]) */ set(STRstatus, Strsave(STR0)); - if ((tcp = getenv("HOME")) != NULL && strlen(tcp) < MAXPATHLEN) + if ((tcp = getenv("HOME")) != NULL && strlen(tcp) < PATH_MAX) cp = SAVE(tcp); else cp = NULL; diff --git a/bin/csh/dir.c b/bin/csh/dir.c index a4b81eb512c..ce9eb6e0fc3 100644 --- a/bin/csh/dir.c +++ b/bin/csh/dir.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dir.c,v 1.17 2014/10/16 19:43:31 deraadt Exp $ */ +/* $OpenBSD: dir.c,v 1.18 2015/01/16 06:39:31 deraadt Exp $ */ /* $NetBSD: dir.c,v 1.9 1995/03/21 09:02:42 cgd Exp $ */ /*- @@ -30,12 +30,12 @@ * SUCH DAMAGE. */ -#include <sys/param.h> #include <sys/stat.h> #include <errno.h> #include <stdlib.h> #include <string.h> #include <unistd.h> +#include <limits.h> #include <stdarg.h> #include "csh.h" @@ -66,11 +66,11 @@ dinit(Char *hp) char *tcp; Char *cp; struct directory *dp; - char path[MAXPATHLEN]; + char path[PATH_MAX]; static const char emsg[] = "csh: Trying to start from \"%s\"\n"; /* Don't believe the login shell home, because it may be a symlink */ - tcp = getcwd(path, MAXPATHLEN); + tcp = getcwd(path, PATH_MAX); if (tcp == NULL || *tcp == '\0') { (void) fprintf(csherr, "csh: %s\n", strerror(errno)); if (hp && *hp) { @@ -405,7 +405,7 @@ dfollow(Char *cp) { Char *dp; struct varent *c; - char ebuf[MAXPATHLEN]; + char ebuf[PATH_MAX]; int serrno; cp = globone(cp, G_ERROR); @@ -428,7 +428,7 @@ dfollow(Char *cp) && (c = adrof(STRcdpath))) { Char **cdp; Char *p; - Char buf[MAXPATHLEN]; + Char buf[PATH_MAX]; for (cdp = c->vec; *cdp; cdp++) { for (dp = buf, p = *cdp; (*dp++ = *p++) != '\0';) @@ -610,8 +610,8 @@ dcanon(Char *cp, Char *p) Char *p1, *p2; /* general purpose */ bool slash; - Char link[MAXPATHLEN]; - char tlink[MAXPATHLEN]; + Char link[PATH_MAX]; + char tlink[PATH_MAX]; int cc; Char *newcp; @@ -620,12 +620,12 @@ dcanon(Char *cp, Char *p) * cwd does not start with a path or the result would be too long abort(). */ if (*cp != '/') { - Char tmpdir[MAXPATHLEN]; + Char tmpdir[PATH_MAX]; p1 = value(STRcwd); if (p1 == NULL || *p1 != '/') abort(); - if (Strlen(p1) + Strlen(cp) + 1 >= MAXPATHLEN) + if (Strlen(p1) + Strlen(cp) + 1 >= PATH_MAX) abort(); (void) Strlcpy(tmpdir, p1, sizeof tmpdir/sizeof(Char)); (void) Strlcat(tmpdir, STRslash, sizeof tmpdir/sizeof(Char)); diff --git a/bin/csh/exec.c b/bin/csh/exec.c index fb5061e93ea..ea0bf3f26b8 100644 --- a/bin/csh/exec.c +++ b/bin/csh/exec.c @@ -1,4 +1,4 @@ -/* $OpenBSD: exec.c,v 1.15 2009/10/27 23:59:21 deraadt Exp $ */ +/* $OpenBSD: exec.c,v 1.16 2015/01/16 06:39:31 deraadt Exp $ */ /* $NetBSD: exec.c,v 1.9 1996/09/30 20:03:54 christos Exp $ */ /*- @@ -31,7 +31,6 @@ */ #include <sys/types.h> -#include <sys/param.h> #include <dirent.h> #include <fcntl.h> #include <sys/stat.h> @@ -39,6 +38,7 @@ #include <stdlib.h> #include <string.h> #include <unistd.h> +#include <limits.h> #include <stdarg.h> #include "csh.h" @@ -554,17 +554,17 @@ static int executable(Char *dir, Char *name, bool dir_ok) { struct stat stbuf; - Char path[MAXPATHLEN], *dp, *sp; + Char path[PATH_MAX], *dp, *sp; char *strname; if (dir && *dir) { for (dp = path, sp = dir; *sp; *dp++ = *sp++) - if (dp == &path[MAXPATHLEN]) { + if (dp == &path[PATH_MAX]) { *--dp = '\0'; break; } for (sp = name; *sp; *dp++ = *sp++) - if (dp == &path[MAXPATHLEN]) { + if (dp == &path[PATH_MAX]) { *--dp = '\0'; break; } diff --git a/bin/csh/file.c b/bin/csh/file.c index 11961e6e37a..40730e7c08d 100644 --- a/bin/csh/file.c +++ b/bin/csh/file.c @@ -1,4 +1,4 @@ -/* $OpenBSD: file.c,v 1.17 2014/10/16 19:43:31 deraadt Exp $ */ +/* $OpenBSD: file.c,v 1.18 2015/01/16 06:39:31 deraadt Exp $ */ /* $NetBSD: file.c,v 1.11 1996/11/08 19:34:37 christos Exp $ */ /*- @@ -32,7 +32,7 @@ #ifdef FILEC -#include <sys/param.h> +#include <sys/types.h> #include <sys/ioctl.h> #include <sys/stat.h> #include <termios.h> @@ -40,6 +40,7 @@ #include <pwd.h> #include <stdlib.h> #include <unistd.h> +#include <limits.h> #ifndef SHORT_STRINGS #include <string.h> #endif /* SHORT_STRINGS */ @@ -200,7 +201,7 @@ copyn(Char *des, Char *src, int count) static Char filetype(Char *dir, Char *file) { - Char path[MAXPATHLEN]; + Char path[PATH_MAX]; struct stat statb; Strlcpy(path, dir, sizeof path/sizeof(Char)); @@ -281,7 +282,7 @@ tilde(Char *new, Char *old) static Char person[40]; if (old[0] != '~') { - Strlcpy(new, old, MAXPATHLEN); + Strlcpy(new, old, PATH_MAX); return new; } @@ -289,14 +290,14 @@ tilde(Char *new, Char *old) continue; *p = '\0'; if (person[0] == '\0') - (void) Strlcpy(new, value(STRhome), MAXPATHLEN); + (void) Strlcpy(new, value(STRhome), PATH_MAX); else { pw = getpwnam(short2str(person)); if (pw == NULL) return (NULL); - (void) Strlcpy(new, str2short(pw->pw_dir), MAXPATHLEN); + (void) Strlcpy(new, str2short(pw->pw_dir), PATH_MAX); } - (void) Strlcat(new, o, MAXPATHLEN); + (void) Strlcat(new, o, PATH_MAX); return (new); } @@ -417,7 +418,7 @@ tsearch(Char *word, COMMAND command, int max_word_length) DIR *dir_fd; int numitems = 0, ignoring = TRUE, nignored = 0; int name_length, looking_for_lognames; - Char tilded_dir[MAXPATHLEN], dir[MAXPATHLEN]; + Char tilded_dir[PATH_MAX], dir[PATH_MAX]; Char name[MAXNAMLEN + 1], extended_name[MAXNAMLEN + 1]; Char *entry; Char **items = NULL; diff --git a/bin/csh/glob.c b/bin/csh/glob.c index 75605e57e64..d5d4a54c292 100644 --- a/bin/csh/glob.c +++ b/bin/csh/glob.c @@ -1,4 +1,4 @@ -/* $OpenBSD: glob.c,v 1.14 2014/10/16 19:43:31 deraadt Exp $ */ +/* $OpenBSD: glob.c,v 1.15 2015/01/16 06:39:31 deraadt Exp $ */ /* $NetBSD: glob.c,v 1.10 1995/03/21 09:03:01 cgd Exp $ */ /*- @@ -30,12 +30,13 @@ * SUCH DAMAGE. */ -#include <sys/param.h> +#include <sys/types.h> #include <glob.h> #include <errno.h> #include <stdlib.h> #include <string.h> #include <unistd.h> +#include <limits.h> #include <stdarg.h> #include "csh.h" @@ -87,12 +88,12 @@ static void backeval(Char *, bool); static Char * globtilde(Char **nv, Char *s) { - Char gbuf[MAXPATHLEN], *gstart, *b, *u, *e; + Char gbuf[PATH_MAX], *gstart, *b, *u, *e; gstart = gbuf; *gstart++ = *s++; u = s; - for (b = gstart, e = &gbuf[MAXPATHLEN - 1]; + for (b = gstart, e = &gbuf[PATH_MAX - 1]; *s && *s != '/' && *s != ':' && b < e; *b++ = *s++) continue; @@ -119,7 +120,7 @@ globbrace(Char *s, Char *p, Char ***bl) int i, len; Char *pm, *pe, *lm, *pl; Char **nv, **vl; - Char gbuf[MAXPATHLEN]; + Char gbuf[PATH_MAX]; int size = GLOBSPACE; nv = vl = xreallocarray(NULL, size, sizeof(Char *)); @@ -182,7 +183,7 @@ globbrace(Char *s, Char *p, Char ***bl) *pm = EOS; (void) Strlcpy(lm, pl, &gbuf[sizeof(gbuf)/sizeof(Char)] - lm); - (void) Strlcat(gbuf, pe + 1, MAXPATHLEN); + (void) Strlcat(gbuf, pe + 1, PATH_MAX); *pm = savec; *vl++ = Strsave(gbuf); len++; @@ -575,7 +576,7 @@ Char ** dobackp(Char *cp, bool literal) { Char *lp, *rp; - Char *ep, word[MAXPATHLEN]; + Char *ep, word[PATH_MAX]; if (pargv) { #ifdef notdef @@ -588,7 +589,7 @@ dobackp(Char *cp, bool literal) pargv[0] = NULL; pargcp = pargs = word; pargc = 0; - pnleft = MAXPATHLEN - 4; + pnleft = PATH_MAX - 4; for (;;) { for (lp = cp; *lp != '`'; lp++) { if (*lp == 0) { @@ -769,7 +770,7 @@ pword(void) pargv[pargc++] = Strsave(pargs); pargv[pargc] = NULL; pargcp = pargs; - pnleft = MAXPATHLEN - 4; + pnleft = PATH_MAX - 4; } int diff --git a/bin/csh/sem.c b/bin/csh/sem.c index 3d4d0428ffe..930b8a214aa 100644 --- a/bin/csh/sem.c +++ b/bin/csh/sem.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sem.c,v 1.17 2010/08/12 02:00:27 kevlo Exp $ */ +/* $OpenBSD: sem.c,v 1.18 2015/01/16 06:39:31 deraadt Exp $ */ /* $NetBSD: sem.c,v 1.9 1995/09/27 00:38:50 jtc Exp $ */ /*- @@ -30,7 +30,7 @@ * SUCH DAMAGE. */ -#include <sys/param.h> +#include <sys/types.h> #include <sys/ioctl.h> #include <sys/stat.h> #include <errno.h> @@ -38,6 +38,7 @@ #include <stdlib.h> #include <string.h> #include <unistd.h> +#include <limits.h> #include <stdarg.h> #include "csh.h" @@ -518,7 +519,7 @@ doio(struct command *t, int *pipein, int *pipeout) return; if ((flags & F_READ) == 0) {/* F_READ already done */ if (t->t_dlef) { - char tmp[MAXPATHLEN]; + char tmp[PATH_MAX]; /* * so < /dev/std{in,out,err} work @@ -550,7 +551,7 @@ doio(struct command *t, int *pipein, int *pipeout) } } if (t->t_drit) { - char tmp[MAXPATHLEN]; + char tmp[PATH_MAX]; cp = splicepipe(t, t->t_drit); strlcpy(tmp, short2str(cp), sizeof tmp); |