diff options
669 files changed, 2205 insertions, 2220 deletions
diff --git a/bin/cat/cat.c b/bin/cat/cat.c index 399db63d71a..857534e6eee 100644 --- a/bin/cat/cat.c +++ b/bin/cat/cat.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cat.c,v 1.20 2009/10/27 23:59:19 deraadt Exp $ */ +/* $OpenBSD: cat.c,v 1.21 2015/01/16 06:39:28 deraadt Exp $ */ /* $NetBSD: cat.c,v 1.11 1995/09/07 06:12:54 jtc Exp $ */ /* @@ -33,7 +33,7 @@ * SUCH DAMAGE. */ -#include <sys/param.h> +#include <sys/types.h> #include <sys/stat.h> #include <ctype.h> @@ -46,6 +46,8 @@ #include <string.h> #include <unistd.h> +#define MAXIMUM(a, b) (((a) > (b)) ? (a) : (b)) + extern char *__progname; int bflag, eflag, nflag, sflag, tflag, vflag; @@ -227,7 +229,7 @@ raw_cat(int rfd) if (buf == NULL) { if (fstat(wfd, &sbuf)) err(1, "stdout"); - bsize = MAX(sbuf.st_blksize, BUFSIZ); + bsize = MAXIMUM(sbuf.st_blksize, BUFSIZ); if ((buf = malloc(bsize)) == NULL) err(1, "malloc"); } diff --git a/bin/cp/cp.c b/bin/cp/cp.c index 436e4eb6712..0b4f4361e8a 100644 --- a/bin/cp/cp.c +++ b/bin/cp/cp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cp.c,v 1.36 2014/05/21 06:23:02 guenther Exp $ */ +/* $OpenBSD: cp.c,v 1.37 2015/01/16 06:39:31 deraadt Exp $ */ /* $NetBSD: cp.c,v 1.14 1995/09/07 06:14:51 jtc Exp $ */ /* @@ -48,7 +48,7 @@ * in "to") to form the final target path. */ -#include <sys/param.h> +#include <sys/types.h> #include <sys/stat.h> #include <sys/mman.h> #include <sys/time.h> @@ -63,6 +63,7 @@ #include <stdlib.h> #include <string.h> #include <unistd.h> +#include <limits.h> #include "extern.h" @@ -318,7 +319,7 @@ copy(char *argv[], enum op type, int fts_options) if (*p != '/' && target_mid[-1] != '/') *target_mid++ = '/'; *target_mid = '\0'; - if (target_mid - to.p_path + nlen >= MAXPATHLEN) { + if (target_mid - to.p_path + nlen >= PATH_MAX) { warnx("%s%s: name too long (not copied)", to.p_path, p); rval = 1; diff --git a/bin/cp/extern.h b/bin/cp/extern.h index f76bca24c32..91d40d57da6 100644 --- a/bin/cp/extern.h +++ b/bin/cp/extern.h @@ -1,4 +1,4 @@ -/* $OpenBSD: extern.h,v 1.13 2012/12/04 02:26:59 deraadt Exp $ */ +/* $OpenBSD: extern.h,v 1.14 2015/01/16 06:39:31 deraadt Exp $ */ /* $NetBSD: extern.h,v 1.3 1995/03/21 09:02:16 cgd Exp $ */ /*- @@ -35,7 +35,7 @@ typedef struct { char *p_end; /* pointer to NULL at end of path */ char *target_end; /* pointer to end of target base */ - char p_path[MAXPATHLEN]; /* pointer to the start of a path */ + char p_path[PATH_MAX]; /* pointer to the start of a path */ } PATH_T; extern PATH_T to; diff --git a/bin/cp/utils.c b/bin/cp/utils.c index 1a39ae783a2..2d76aa0cde9 100644 --- a/bin/cp/utils.c +++ b/bin/cp/utils.c @@ -1,4 +1,4 @@ -/* $OpenBSD: utils.c,v 1.34 2014/04/24 01:34:35 tedu Exp $ */ +/* $OpenBSD: utils.c,v 1.35 2015/01/16 06:39:31 deraadt Exp $ */ /* $NetBSD: utils.c,v 1.6 1997/02/26 14:40:51 cgd Exp $ */ /*- @@ -30,7 +30,7 @@ * SUCH DAMAGE. */ -#include <sys/param.h> +#include <sys/param.h> /* for MAXBSIZE */ #include <sys/stat.h> #include <sys/mman.h> #include <sys/time.h> @@ -43,6 +43,7 @@ #include <stdlib.h> #include <string.h> #include <unistd.h> +#include <limits.h> #include "extern.h" @@ -201,7 +202,7 @@ int copy_link(FTSENT *p, int exists) { int len; - char link[MAXPATHLEN]; + char link[PATH_MAX]; if ((len = readlink(p->fts_path, link, sizeof(link)-1)) == -1) { warn("readlink: %s", p->fts_path); 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); diff --git a/bin/dd/conv.c b/bin/dd/conv.c index ba005a3e155..16aa5f1b8f3 100644 --- a/bin/dd/conv.c +++ b/bin/dd/conv.c @@ -1,4 +1,4 @@ -/* $OpenBSD: conv.c,v 1.11 2009/10/27 23:59:21 deraadt Exp $ */ +/* $OpenBSD: conv.c,v 1.12 2015/01/16 06:39:31 deraadt Exp $ */ /* $NetBSD: conv.c,v 1.6 1996/02/20 19:29:02 jtc Exp $ */ /*- @@ -34,7 +34,7 @@ * SUCH DAMAGE. */ -#include <sys/param.h> +#include <sys/types.h> #include <sys/time.h> #include <err.h> @@ -43,6 +43,8 @@ #include "dd.h" #include "extern.h" +#define MINIMUM(a, b) (((a) < (b)) ? (a) : (b)) + /* * def -- * Copy input to output. Input is buffered until reaches obs, and then @@ -137,7 +139,7 @@ block(void) * translation is done as we copy into the output buffer. */ for (inp = in.dbp - in.dbcnt, outp = out.dbp; in.dbcnt;) { - maxlen = MIN(cbsz, in.dbcnt); + maxlen = MINIMUM(cbsz, in.dbcnt); if ((t = ctab) != NULL) for (cnt = 0; cnt < maxlen && (ch = *inp++) != '\n'; ++cnt) diff --git a/bin/dd/dd.c b/bin/dd/dd.c index 23f9608aec1..715a1aa79fd 100644 --- a/bin/dd/dd.c +++ b/bin/dd/dd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dd.c,v 1.20 2015/01/05 13:52:47 tedu Exp $ */ +/* $OpenBSD: dd.c,v 1.21 2015/01/16 06:39:31 deraadt Exp $ */ /* $NetBSD: dd.c,v 1.6 1996/02/20 19:29:06 jtc Exp $ */ /*- @@ -34,7 +34,7 @@ * SUCH DAMAGE. */ -#include <sys/param.h> +#include <sys/types.h> #include <sys/stat.h> #include <sys/ioctl.h> #include <sys/mtio.h> @@ -57,6 +57,8 @@ static void dd_in(void); static void getfdtype(IO *); static void setup(void); +#define MAXIMUM(a, b) (((a) > (b)) ? (a) : (b)) + IO in, out; /* input/output state */ STAT st; /* statistics */ void (*cfunc)(void); /* conversion function */ @@ -135,7 +137,7 @@ setup(void) err(1, "input buffer"); out.db = in.db; } else if ((in.db = - malloc((u_int)(MAX(in.dbsz, cbsz) + cbsz))) == NULL || + malloc((u_int)(MAXIMUM(in.dbsz, cbsz) + cbsz))) == NULL || (out.db = malloc((u_int)(out.dbsz + cbsz))) == NULL) err(1, "output buffer"); in.dbp = in.db; diff --git a/bin/df/df.c b/bin/df/df.c index 7cfe89bf7f3..d4d928c5471 100644 --- a/bin/df/df.c +++ b/bin/df/df.c @@ -1,4 +1,4 @@ -/* $OpenBSD: df.c,v 1.51 2014/05/20 21:11:16 krw Exp $ */ +/* $OpenBSD: df.c,v 1.52 2015/01/16 06:39:31 deraadt Exp $ */ /* $NetBSD: df.c,v 1.21.2.1 1995/11/01 00:06:11 jtc Exp $ */ /* @@ -35,7 +35,6 @@ * SUCH DAMAGE. */ -#include <sys/param.h> #include <sys/stat.h> #include <sys/mount.h> diff --git a/bin/df/ext2fs_df.c b/bin/df/ext2fs_df.c index 86ed0ecf9cc..07e02832ca3 100644 --- a/bin/df/ext2fs_df.c +++ b/bin/df/ext2fs_df.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ext2fs_df.c,v 1.11 2004/09/14 22:46:04 deraadt Exp $ */ +/* $OpenBSD: ext2fs_df.c,v 1.12 2015/01/16 06:39:31 deraadt Exp $ */ /* * This file is substantially derived from src/sys/ufs/ext2fs/ext2fs_vfsops.c:e2fs_statfs(). @@ -38,7 +38,7 @@ * @(#)ffs_vfsops.c 8.14 (Berkeley) 11/28/94 */ -#include <sys/param.h> +#include <sys/types.h> #include <sys/mount.h> #include <ufs/ext2fs/ext2fs.h> #include <ufs/ext2fs/ext2fs_dinode.h> diff --git a/bin/df/ffs_df.c b/bin/df/ffs_df.c index 2a1a733832c..d1fa39d6c2f 100644 --- a/bin/df/ffs_df.c +++ b/bin/df/ffs_df.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ffs_df.c,v 1.14 2014/05/16 13:44:09 krw Exp $ */ +/* $OpenBSD: ffs_df.c,v 1.15 2015/01/16 06:39:31 deraadt Exp $ */ /* * Copyright (c) 1980, 1990, 1993, 1994 @@ -34,7 +34,7 @@ * SUCH DAMAGE. */ -#include <sys/param.h> +#include <sys/param.h> /* MAXFRAG */ #include <sys/mount.h> #include <ufs/ufs/dinode.h> #include <ufs/ffs/fs.h> diff --git a/bin/domainname/domainname.c b/bin/domainname/domainname.c index a5a38929ddc..b4cc6db4ff0 100644 --- a/bin/domainname/domainname.c +++ b/bin/domainname/domainname.c @@ -1,4 +1,4 @@ -/* $OpenBSD: domainname.c,v 1.8 2009/10/27 23:59:21 deraadt Exp $ */ +/* $OpenBSD: domainname.c,v 1.9 2015/01/16 06:39:31 deraadt Exp $ */ /* $NetBSD: domainname.c,v 1.7 1995/03/21 09:04:22 cgd Exp $ */ /* @@ -30,13 +30,12 @@ * SUCH DAMAGE. */ -#include <sys/param.h> - #include <err.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <unistd.h> +#include <limits.h> extern char *__progname; @@ -46,7 +45,7 @@ int main(int argc, char *argv[]) { int ch; - char domainname[MAXHOSTNAMELEN]; + char domainname[HOST_NAME_MAX+1]; while ((ch = getopt(argc, argv, "")) != -1) switch (ch) { diff --git a/bin/ed/ed.h b/bin/ed/ed.h index a68b1ede7a3..2acce50456e 100644 --- a/bin/ed/ed.h +++ b/bin/ed/ed.h @@ -1,4 +1,4 @@ -/* $OpenBSD: ed.h,v 1.14 2014/12/02 20:34:14 millert Exp $ */ +/* $OpenBSD: ed.h,v 1.15 2015/01/16 06:39:32 deraadt Exp $ */ /* $NetBSD: ed.h,v 1.23 1995/03/21 09:04:40 cgd Exp $ */ /* ed.h: type and constant definitions for the ed editor. */ @@ -31,7 +31,6 @@ */ #include <sys/types.h> -#include <sys/param.h> /* for MAXPATHLEN */ #include <errno.h> #include <limits.h> #include <regex.h> @@ -230,7 +229,7 @@ extern int sigflags; /* global vars */ extern int addr_last; extern int current_addr; -extern char errmsg[MAXPATHLEN + 40]; +extern char errmsg[PATH_MAX + 40]; extern int first_addr; extern int lineno; extern int second_addr; diff --git a/bin/ed/main.c b/bin/ed/main.c index afbdb340682..c7cff84f86f 100644 --- a/bin/ed/main.c +++ b/bin/ed/main.c @@ -1,4 +1,4 @@ -/* $OpenBSD: main.c,v 1.42 2014/12/04 08:34:04 daniel Exp $ */ +/* $OpenBSD: main.c,v 1.43 2015/01/16 06:39:32 deraadt Exp $ */ /* $NetBSD: main.c,v 1.3 1995/03/21 09:04:44 cgd Exp $ */ /* main.c: This file contains the main control and user-interface routines @@ -80,7 +80,7 @@ int interactive = 0; /* if set, we are in interactive mode */ /* if set, signal handlers are enabled */ volatile sig_atomic_t sigactive = 0; -char old_filename[MAXPATHLEN] = ""; /* default filename */ +char old_filename[PATH_MAX] = ""; /* default filename */ int current_addr; /* current address in editor buffer */ int addr_last; /* last address in editor buffer */ int lineno; /* script line number */ @@ -962,7 +962,7 @@ get_filename(void) return NULL; if (n) printf("%s\n", shcmd + 1); return shcmd; - } else if (n >= MAXPATHLEN) { + } else if (n >= PATH_MAX) { seterrmsg("filename too long"); return NULL; } @@ -973,7 +973,7 @@ get_filename(void) return NULL; } #endif - REALLOC(file, filesz, MAXPATHLEN, NULL); + REALLOC(file, filesz, PATH_MAX, NULL); for (n = 0; *ibufp != '\n';) file[n++] = *ibufp++; file[n] = '\0'; @@ -1331,7 +1331,7 @@ has_trailing_escape(char *s, char *t) } -/* strip_escapes: return copy of escaped string of at most length MAXPATHLEN */ +/* strip_escapes: return copy of escaped string of at most length PATH_MAX */ char * strip_escapes(char *s) { @@ -1340,12 +1340,12 @@ strip_escapes(char *s) int i = 0; - REALLOC(file, filesz, MAXPATHLEN, NULL); + REALLOC(file, filesz, PATH_MAX, NULL); /* assert: no trailing escape */ while ((file[i++] = (*s == '\\') ? *++s : *s) != '\0' && - i < MAXPATHLEN-1) + i < PATH_MAX-1) s++; - file[MAXPATHLEN-1] = '\0'; + file[PATH_MAX-1] = '\0'; return file; } @@ -1379,7 +1379,7 @@ signal_int(int signo) void handle_hup(int signo) { - char hup[MAXPATHLEN]; + char hup[PATH_MAX]; if (!sigactive) quit(1); diff --git a/bin/ed/re.c b/bin/ed/re.c index 57d0b89dca4..e99a29a0250 100644 --- a/bin/ed/re.c +++ b/bin/ed/re.c @@ -1,4 +1,4 @@ -/* $OpenBSD: re.c,v 1.11 2009/10/27 23:59:21 deraadt Exp $ */ +/* $OpenBSD: re.c,v 1.12 2015/01/16 06:39:32 deraadt Exp $ */ /* $NetBSD: re.c,v 1.14 1995/03/21 09:04:48 cgd Exp $ */ /* re.c: This file contains the regular expression interface routines for @@ -34,7 +34,7 @@ extern int patlock; -char errmsg[MAXPATHLEN + 40] = ""; +char errmsg[PATH_MAX + 40] = ""; /* get_compiled_pattern: return pointer to compiled pattern from command buffer */ diff --git a/bin/hostname/hostname.c b/bin/hostname/hostname.c index 6a63d7f08bf..e9c6454fb36 100644 --- a/bin/hostname/hostname.c +++ b/bin/hostname/hostname.c @@ -1,4 +1,4 @@ -/* $OpenBSD: hostname.c,v 1.8 2009/10/27 23:59:21 deraadt Exp $ */ +/* $OpenBSD: hostname.c,v 1.9 2015/01/16 06:39:32 deraadt Exp $ */ /* $NetBSD: hostname.c,v 1.10 1995/09/07 06:28:40 jtc Exp $ */ /* @@ -30,13 +30,12 @@ * SUCH DAMAGE. */ -#include <sys/param.h> - #include <err.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <unistd.h> +#include <limits.h> extern char *__progname; @@ -46,7 +45,7 @@ int main(int argc, char *argv[]) { int ch, sflag; - char *p, hostname[MAXHOSTNAMELEN]; + char *p, hostname[HOST_NAME_MAX+1]; sflag = 0; while ((ch = getopt(argc, argv, "s")) != -1) diff --git a/bin/ksh/misc.c b/bin/ksh/misc.c index 3a5f19f0930..90da37d0426 100644 --- a/bin/ksh/misc.c +++ b/bin/ksh/misc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: misc.c,v 1.38 2013/11/28 10:33:37 sobrado Exp $ */ +/* $OpenBSD: misc.c,v 1.39 2015/01/16 06:39:32 deraadt Exp $ */ /* * Miscellaneous functions @@ -6,7 +6,6 @@ #include "sh.h" #include <ctype.h> -#include <sys/param.h> /* for MAXPATHLEN */ #include "charclass.h" short ctypes [UCHAR_MAX+1]; /* type bits for unsigned char */ @@ -1120,7 +1119,7 @@ reset_nonblock(int fd) } -/* Like getcwd(), except bsize is ignored if buf is 0 (MAXPATHLEN is used) */ +/* Like getcwd(), except bsize is ignored if buf is 0 (PATH_MAX is used) */ char * ksh_get_wd(char *buf, int bsize) { @@ -1131,8 +1130,8 @@ ksh_get_wd(char *buf, int bsize) * inject possibly allocated space into the ATEMP area. */ /* Assume getcwd() available */ if (!buf) { - bsize = MAXPATHLEN; - b = alloc(MAXPATHLEN + 1, ATEMP); + bsize = PATH_MAX; + b = alloc(PATH_MAX + 1, ATEMP); } else b = buf; diff --git a/bin/ln/ln.c b/bin/ln/ln.c index 8d86167cbef..653875cc84a 100644 --- a/bin/ln/ln.c +++ b/bin/ln/ln.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ln.c,v 1.21 2014/05/23 04:38:57 guenther Exp $ */ +/* $OpenBSD: ln.c,v 1.22 2015/01/16 06:39:32 deraadt Exp $ */ /* $NetBSD: ln.c,v 1.10 1995/03/21 09:06:10 cgd Exp $ */ /* @@ -30,7 +30,7 @@ * SUCH DAMAGE. */ -#include <sys/param.h> +#include <sys/types.h> #include <sys/stat.h> #include <err.h> @@ -41,6 +41,7 @@ #include <stdlib.h> #include <string.h> #include <unistd.h> +#include <limits.h> int fflag; /* Unlink existing files. */ int hflag; /* Check new name for symlink first. */ @@ -112,7 +113,7 @@ int linkit(char *target, char *source, int isdir) { struct stat sb; - char *p, path[MAXPATHLEN]; + char *p, path[PATH_MAX]; int (*statf)(const char *, struct stat *); int exists, n; diff --git a/bin/ls/print.c b/bin/ls/print.c index 5b223303976..ccc1d856ec1 100644 --- a/bin/ls/print.c +++ b/bin/ls/print.c @@ -1,4 +1,4 @@ -/* $OpenBSD: print.c,v 1.32 2014/05/06 20:55:10 tedu Exp $ */ +/* $OpenBSD: print.c,v 1.33 2015/01/16 06:39:32 deraadt Exp $ */ /* $NetBSD: print.c,v 1.15 1996/12/11 03:25:39 thorpej Exp $ */ /* @@ -33,7 +33,7 @@ * SUCH DAMAGE. */ -#include <sys/param.h> +#include <sys/types.h> #include <sys/stat.h> #include <err.h> @@ -47,6 +47,7 @@ #include <time.h> #include <tzfile.h> #include <unistd.h> +#include <limits.h> #include <util.h> #include "ls.h" @@ -346,7 +347,7 @@ static void printlink(FTSENT *p) { int lnklen; - char name[MAXPATHLEN], path[MAXPATHLEN]; + char name[PATH_MAX], path[PATH_MAX]; if (p->fts_level == FTS_ROOTLEVEL) (void)snprintf(name, sizeof(name), "%s", p->fts_name); diff --git a/bin/md5/md5.c b/bin/md5/md5.c index 33b31886fb0..e9d40e7ec8c 100644 --- a/bin/md5/md5.c +++ b/bin/md5/md5.c @@ -1,4 +1,4 @@ -/* $OpenBSD: md5.c,v 1.77 2014/09/13 16:06:36 doug Exp $ */ +/* $OpenBSD: md5.c,v 1.78 2015/01/16 06:39:32 deraadt Exp $ */ /* * Copyright (c) 2001,2003,2005-2007,2010,2013,2014 @@ -48,8 +48,8 @@ #define MAX_DIGEST_LEN 128 -#define MIN(a,b) (((a)<(b))?(a):(b)) -#define MAX(a,b) (((a)>(b))?(a):(b)) +#define MINIMUM(a, b) (((a) < (b)) ? (a) : (b)) +#define MAXIMUM(a, b) (((a) > (b)) ? (a) : (b)) union ANY_CTX { #if !defined(SHA2_ONLY) @@ -546,8 +546,8 @@ digest_filelist(const char *file, struct hash_function *defhash, int selcount, algorithm_max = algorithm_min = strlen(functions[0].name); for (hf = &functions[1]; hf->name != NULL; hf++) { len = strlen(hf->name); - algorithm_max = MAX(algorithm_max, len); - algorithm_min = MIN(algorithm_min, len); + algorithm_max = MAXIMUM(algorithm_max, len); + algorithm_min = MINIMUM(algorithm_min, len); } error = found = 0; diff --git a/bin/mv/mv.c b/bin/mv/mv.c index c3a5bfb6ce0..dce0f0e2320 100644 --- a/bin/mv/mv.c +++ b/bin/mv/mv.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mv.c,v 1.37 2014/07/21 19:55:33 deraadt Exp $ */ +/* $OpenBSD: mv.c,v 1.38 2015/01/16 06:39:32 deraadt Exp $ */ /* $NetBSD: mv.c,v 1.9 1995/03/21 09:06:52 cgd Exp $ */ /* @@ -33,7 +33,6 @@ * SUCH DAMAGE. */ -#include <sys/param.h> #include <sys/time.h> #include <sys/wait.h> #include <sys/stat.h> @@ -46,6 +45,7 @@ #include <stdlib.h> #include <string.h> #include <unistd.h> +#include <limits.h> #include <pwd.h> #include <grp.h> @@ -68,7 +68,7 @@ main(int argc, char *argv[]) char *p, *endp; struct stat sb; int ch; - char path[MAXPATHLEN]; + char path[PATH_MAX]; while ((ch = getopt(argc, argv, "if")) != -1) switch (ch) { @@ -134,7 +134,7 @@ main(int argc, char *argv[]) p++; } - if ((baselen + (len = strlen(p))) >= MAXPATHLEN) { + if ((baselen + (len = strlen(p))) >= PATH_MAX) { warnx("%s: destination pathname too long", *argv); rval = 1; } else { @@ -218,7 +218,7 @@ do_move(char *from, char *to) /* Disallow moving a mount point. */ if (S_ISDIR(fsb.st_mode)) { struct statfs sfs; - char path[MAXPATHLEN]; + char path[PATH_MAX]; if (realpath(from, path) == NULL) { warnx("cannot resolve %s", from); diff --git a/bin/pax/buf_subs.c b/bin/pax/buf_subs.c index 1ba152b3432..36fcce445bf 100644 --- a/bin/pax/buf_subs.c +++ b/bin/pax/buf_subs.c @@ -1,4 +1,4 @@ -/* $OpenBSD: buf_subs.c,v 1.25 2014/07/14 05:58:19 guenther Exp $ */ +/* $OpenBSD: buf_subs.c,v 1.26 2015/01/16 06:39:32 deraadt Exp $ */ /* $NetBSD: buf_subs.c,v 1.5 1995/03/21 09:07:08 cgd Exp $ */ /*- @@ -398,7 +398,7 @@ rd_skip(off_t skcnt) */ if (skcnt == 0) return(0); - res = MIN((bufend - bufpt), skcnt); + res = MINIMUM((bufend - bufpt), skcnt); bufpt += res; skcnt -= res; @@ -437,7 +437,7 @@ rd_skip(off_t skcnt) return(-1); if (cnt == 0) return(1); - cnt = MIN(cnt, res); + cnt = MINIMUM(cnt, res); bufpt += cnt; res -= cnt; } @@ -489,7 +489,7 @@ wr_rdbuf(char *out, int outcnt) /* * only move what we have space for */ - cnt = MIN(cnt, outcnt); + cnt = MINIMUM(cnt, outcnt); memcpy(bufpt, out, cnt); bufpt += cnt; out += cnt; @@ -537,7 +537,7 @@ rd_wrbuf(char *in, int cpcnt) * calculate how much data to copy based on whats left and * state of buffer */ - cnt = MIN(cnt, incnt); + cnt = MINIMUM(cnt, incnt); memcpy(in, bufpt, cnt); bufpt += cnt; incnt -= cnt; @@ -569,7 +569,7 @@ wr_skip(off_t skcnt) cnt = bufend - bufpt; if ((cnt <= 0) && ((cnt = buf_flush(blksz)) < 0)) return(-1); - cnt = MIN(cnt, skcnt); + cnt = MINIMUM(cnt, skcnt); memset(bufpt, 0, cnt); bufpt += cnt; skcnt -= cnt; @@ -612,7 +612,7 @@ wr_rdfile(ARCHD *arcn, int ifd, off_t *left) *left = size; return(-1); } - cnt = MIN(cnt, size); + cnt = MINIMUM(cnt, size); if ((res = read(ifd, bufpt, cnt)) <= 0) break; size -= res; @@ -697,7 +697,7 @@ rd_wrfile(ARCHD *arcn, int ofd, off_t *left) */ if ((cnt <= 0) && ((cnt = buf_fill()) <= 0)) break; - cnt = MIN(cnt, size); + cnt = MINIMUM(cnt, size); if ((res = file_write(ofd,bufpt,cnt,&rem,&isem,sz,fnm)) <= 0) { *left = size; break; diff --git a/bin/pax/file_subs.c b/bin/pax/file_subs.c index e37c085847a..364c433cc26 100644 --- a/bin/pax/file_subs.c +++ b/bin/pax/file_subs.c @@ -1,4 +1,4 @@ -/* $OpenBSD: file_subs.c,v 1.37 2014/11/23 05:32:20 guenther Exp $ */ +/* $OpenBSD: file_subs.c,v 1.38 2015/01/16 06:39:32 deraadt Exp $ */ /* $NetBSD: file_subs.c,v 1.4 1995/03/21 09:07:18 cgd Exp $ */ /*- @@ -841,7 +841,7 @@ file_write(int fd, char *str, int cnt, int *rem, int *isempt, int sz, * only examine up to the end of the current file block or * remaining characters to write, whatever is smaller */ - wcnt = MIN(cnt, *rem); + wcnt = MINIMUM(cnt, *rem); cnt -= wcnt; *rem -= wcnt; if (*isempt) { diff --git a/bin/pax/pax.h b/bin/pax/pax.h index 13b53283596..1c85aaec837 100644 --- a/bin/pax/pax.h +++ b/bin/pax/pax.h @@ -1,4 +1,4 @@ -/* $OpenBSD: pax.h,v 1.19 2014/11/23 05:32:20 guenther Exp $ */ +/* $OpenBSD: pax.h,v 1.20 2015/01/16 06:39:32 deraadt Exp $ */ /* $NetBSD: pax.h,v 1.3 1995/03/21 09:07:41 cgd Exp $ */ /*- @@ -224,9 +224,7 @@ typedef struct oplist { /* * General Macros */ -#ifndef MIN -#define MIN(a,b) (((a)<(b))?(a):(b)) -#endif +#define MINIMUM(a, b) (((a) < (b)) ? (a) : (b)) #define MAJOR(x) major(x) #define MINOR(x) minor(x) #define TODEV(x, y) makedev((x), (y)) diff --git a/bin/ps/keyword.c b/bin/ps/keyword.c index 041c75a0ca1..3cc32e3e6b0 100644 --- a/bin/ps/keyword.c +++ b/bin/ps/keyword.c @@ -1,4 +1,4 @@ -/* $OpenBSD: keyword.c,v 1.41 2014/10/13 17:30:21 schwarze Exp $ */ +/* $OpenBSD: keyword.c,v 1.42 2015/01/16 06:39:32 deraadt Exp $ */ /* $NetBSD: keyword.c,v 1.12.6.1 1996/05/30 21:25:13 cgd Exp $ */ /*- @@ -30,7 +30,7 @@ * SUCH DAMAGE. */ -#include <sys/param.h> +#include <sys/param.h> /* MAXCOMLEN */ #include <sys/time.h> #include <sys/resource.h> #include <sys/proc.h> @@ -114,7 +114,7 @@ VAR var[] = { /* XXX */ {"ktracep", "KTRACEP", NULL, 0, pvar, PTRWIDTH, 0, POFF(p_tracep), UINT64, "llx"}, {"lim", "LIM", NULL, 0, maxrss, 5}, - {"login", "LOGIN", NULL, LJUST, logname, MAXLOGNAME}, + {"login", "LOGIN", NULL, LJUST, logname, LOGIN_NAME_MAX}, {"logname", "", "login"}, {"lstart", "STARTED", NULL, LJUST|USER, lstarted, 28}, {"majflt", "MAJFLT", NULL, USER, pvar, 4, 0, POFF(p_uru_majflt), UINT64, "lld"}, diff --git a/bin/ps/nlist.c b/bin/ps/nlist.c index 43aae25eaa8..aab817f70c3 100644 --- a/bin/ps/nlist.c +++ b/bin/ps/nlist.c @@ -1,4 +1,4 @@ -/* $OpenBSD: nlist.c,v 1.18 2011/12/11 00:16:49 nicm Exp $ */ +/* $OpenBSD: nlist.c,v 1.19 2015/01/16 06:39:32 deraadt Exp $ */ /* $NetBSD: nlist.c,v 1.11 1995/03/21 09:08:03 cgd Exp $ */ /*- @@ -30,8 +30,9 @@ * SUCH DAMAGE. */ -#include <sys/param.h> +#include <sys/param.h> /* MAXCOMLEN */ #include <sys/time.h> +#include <sys/signal.h> #include <sys/proc.h> #include <sys/resource.h> #include <sys/sysctl.h> diff --git a/bin/ps/print.c b/bin/ps/print.c index 3ffd499f239..3c22518397e 100644 --- a/bin/ps/print.c +++ b/bin/ps/print.c @@ -1,4 +1,4 @@ -/* $OpenBSD: print.c,v 1.58 2014/08/16 16:38:38 tedu Exp $ */ +/* $OpenBSD: print.c,v 1.59 2015/01/16 06:39:32 deraadt Exp $ */ /* $NetBSD: print.c,v 1.27 1995/09/29 21:58:12 cgd Exp $ */ /*- @@ -30,7 +30,8 @@ * SUCH DAMAGE. */ -#include <sys/param.h> +#include <sys/param.h> /* MAXCOMLEN PZERO NODEV */ +#include <sys/types.h> #include <sys/proc.h> #include <sys/stat.h> @@ -47,6 +48,7 @@ #include <string.h> #include <tzfile.h> #include <unistd.h> +#include <limits.h> #include <pwd.h> #include "ps.h" @@ -180,7 +182,7 @@ curwd(const struct kinfo_proc *kp, VARENT *ve) { VAR *v; int name[] = { CTL_KERN, KERN_PROC_CWD, kp->p_pid }; - char path[MAXPATHLEN]; + char path[PATH_MAX]; size_t pathlen = sizeof path; if (!kvm_sysctl_only || sysctl(name, 3, path, &pathlen, NULL, 0) != 0) @@ -197,7 +199,7 @@ logname(const struct kinfo_proc *kp, VARENT *ve) v = ve->var; if (kp->p_login[0]) { - int n = min(v->width, MAXLOGNAME); + int n = min(v->width, LOGIN_NAME_MAX); (void)printf("%-*.*s", n, n, kp->p_login); if (v->width > n) (void)printf("%*s", v->width - n, ""); diff --git a/bin/ps/ps.c b/bin/ps/ps.c index 6d76ee8340f..56eb2658af3 100644 --- a/bin/ps/ps.c +++ b/bin/ps/ps.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ps.c,v 1.62 2014/07/08 23:31:22 deraadt Exp $ */ +/* $OpenBSD: ps.c,v 1.63 2015/01/16 06:39:32 deraadt Exp $ */ /* $NetBSD: ps.c,v 1.15 1995/05/18 20:33:25 mycroft Exp $ */ /*- @@ -30,7 +30,8 @@ * SUCH DAMAGE. */ -#include <sys/param.h> +#include <sys/param.h> /* MAXCOMLEN NODEV */ +#include <sys/types.h> #include <sys/sysctl.h> #include <sys/time.h> #include <sys/resource.h> @@ -203,7 +204,7 @@ main(int argc, char *argv[]) /* FALLTHROUGH */ case 't': { struct stat sb; - char *ttypath, pathbuf[MAXPATHLEN]; + char *ttypath, pathbuf[PATH_MAX]; if (strcmp(optarg, "co") == 0) ttypath = _PATH_CONSOLE; diff --git a/bin/rm/rm.c b/bin/rm/rm.c index ed43f02e5b8..833d3039b97 100644 --- a/bin/rm/rm.c +++ b/bin/rm/rm.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rm.c,v 1.29 2014/05/21 06:23:02 guenther Exp $ */ +/* $OpenBSD: rm.c,v 1.30 2015/01/16 06:39:32 deraadt Exp $ */ /* $NetBSD: rm.c,v 1.19 1995/09/07 06:48:50 jtc Exp $ */ /*- @@ -32,7 +32,6 @@ #include <sys/types.h> #include <sys/stat.h> -#include <sys/param.h> #include <sys/mount.h> #include <locale.h> @@ -44,9 +43,12 @@ #include <stdlib.h> #include <string.h> #include <unistd.h> +#include <limits.h> #include <pwd.h> #include <grp.h> +#define MAXIMUM(a, b) (((a) > (b)) ? (a) : (b)) + extern char *__progname; int dflag, eval, fflag, iflag, Pflag, stdin_ok; @@ -304,7 +306,7 @@ rm_overwrite(char *file, struct stat *sbp) } if (fstatfs(fd, &fsb) == -1) goto err; - bsize = MAX(fsb.f_iosize, 1024U); + bsize = MAXIMUM(fsb.f_iosize, 1024U); if ((buf = malloc(bsize)) == NULL) err(1, "%s: malloc", file); diff --git a/distrib/special/more/more.c b/distrib/special/more/more.c index ba972431b6d..b56ecce4ed6 100644 --- a/distrib/special/more/more.c +++ b/distrib/special/more/more.c @@ -1,4 +1,4 @@ -/* $OpenBSD: more.c,v 1.34 2013/11/27 20:25:47 deraadt Exp $ */ +/* $OpenBSD: more.c,v 1.35 2015/01/16 06:39:33 deraadt Exp $ */ /* * Copyright (c) 2003 Todd C. Miller <Todd.Miller@courtesan.com> @@ -62,7 +62,7 @@ * o POSIX compliance */ -#include <sys/param.h> +#include <sys/types.h> #include <sys/exec.h> #include <sys/ioctl.h> #include <sys/file.h> @@ -81,6 +81,7 @@ #include <string.h> #include <termios.h> #include <unistd.h> +#include <limits.h> #include <paths.h> #define Fopen(s, m) (Currline = 0, file_pos = 0, fopen(s,m)) diff --git a/distrib/special/sysctl/sysctl.c b/distrib/special/sysctl/sysctl.c index 9d73865ce55..6f3e333ac21 100644 --- a/distrib/special/sysctl/sysctl.c +++ b/distrib/special/sysctl/sysctl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sysctl.c,v 1.8 2014/05/03 00:27:19 chl Exp $ */ +/* $OpenBSD: sysctl.c,v 1.9 2015/01/16 06:39:34 deraadt Exp $ */ /* * Copyright (c) 2009 Theo de Raadt <deraadt@openbsd.org> @@ -16,7 +16,8 @@ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#include <sys/param.h> + +#include <sys/types.h> #include <sys/sysctl.h> #include <sys/uio.h> diff --git a/libexec/comsat/comsat.c b/libexec/comsat/comsat.c index 0e4b0a5cc22..b77ef5aa13b 100644 --- a/libexec/comsat/comsat.c +++ b/libexec/comsat/comsat.c @@ -1,4 +1,4 @@ -/* $OpenBSD: comsat.c,v 1.37 2012/12/04 02:24:47 deraadt Exp $ */ +/* $OpenBSD: comsat.c,v 1.38 2015/01/16 06:39:49 deraadt Exp $ */ /* * Copyright (c) 1980, 1993 @@ -40,6 +40,7 @@ #include <errno.h> #include <fcntl.h> #include <netdb.h> +#include <limits.h> #include <paths.h> #include <pwd.h> #include <signal.h> @@ -57,7 +58,7 @@ int debug = 0; #define MAXIDLE 120 -char hostname[MAXHOSTNAMELEN]; +char hostname[HOST_NAME_MAX+1]; struct utmp *utmp = NULL; time_t lastmsgtime; int nutmp, uf; @@ -222,7 +223,7 @@ notify(struct utmp *utp, off_t offset) FILE *tp; struct stat stb; struct termios ttybuf; - char tty[MAXPATHLEN], name[UT_NAMESIZE + 1]; + char tty[PATH_MAX], name[UT_NAMESIZE + 1]; (void)snprintf(tty, sizeof(tty), "%s%.*s", _PATH_DEV, (int)sizeof(utp->ut_line), utp->ut_line); diff --git a/libexec/fingerd/fingerd.c b/libexec/fingerd/fingerd.c index 5d44b3f6dae..26d353caa77 100644 --- a/libexec/fingerd/fingerd.c +++ b/libexec/fingerd/fingerd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: fingerd.c,v 1.36 2012/12/04 02:24:47 deraadt Exp $ */ +/* $OpenBSD: fingerd.c,v 1.37 2015/01/16 06:39:50 deraadt Exp $ */ /* * Copyright (c) 1983, 1993 @@ -42,6 +42,7 @@ #include <stdlib.h> #include <string.h> #include <stdarg.h> +#include <limits.h> #include "pathnames.h" __dead void logerr(const char *, ...); @@ -65,7 +66,7 @@ main(int argc, char *argv[]) #define ENTRIES 50 char **comp, *prog; char **ap, *av[ENTRIES + 1], line[8192], *lp, *hname; - char hostbuf[MAXHOSTNAMELEN]; + char hostbuf[HOST_NAME_MAX+1]; prog = _PATH_FINGER; logging = secure = user_required = short_list = 0; diff --git a/libexec/ftpd/ftpcmd.y b/libexec/ftpd/ftpcmd.y index e67e24ecdd4..a1de80ed99c 100644 --- a/libexec/ftpd/ftpcmd.y +++ b/libexec/ftpd/ftpcmd.y @@ -1,4 +1,4 @@ -/* $OpenBSD: ftpcmd.y,v 1.56 2014/02/08 13:31:51 millert Exp $ */ +/* $OpenBSD: ftpcmd.y,v 1.57 2015/01/16 06:39:50 deraadt Exp $ */ /* $NetBSD: ftpcmd.y,v 1.7 1996/04/08 19:03:11 jtc Exp $ */ /* @@ -39,7 +39,7 @@ %{ -#include <sys/param.h> +#include <sys/types.h> #include <sys/socket.h> #include <sys/stat.h> diff --git a/libexec/ftpd/ftpd.c b/libexec/ftpd/ftpd.c index b5f09f18277..9c2560303ff 100644 --- a/libexec/ftpd/ftpd.c +++ b/libexec/ftpd/ftpd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ftpd.c,v 1.205 2014/10/25 03:19:22 lteo Exp $ */ +/* $OpenBSD: ftpd.c,v 1.206 2015/01/16 06:39:50 deraadt Exp $ */ /* $NetBSD: ftpd.c,v 1.15 1995/06/03 22:46:47 mycroft Exp $ */ /* @@ -151,9 +151,9 @@ off_t byte_count; mode_t defumask = CMASK; /* default umask value */ int umaskchange = 1; /* allow user to change umask value. */ char tmpline[7]; -char hostname[MAXHOSTNAMELEN]; -char remotehost[MAXHOSTNAMELEN]; -char dhostname[MAXHOSTNAMELEN]; +char hostname[HOST_NAME_MAX+1]; +char remotehost[HOST_NAME_MAX+1]; +char dhostname[HOST_NAME_MAX+1]; char *guestpw; char ttyline[20]; #if 0 @@ -227,7 +227,7 @@ void set_slave_signals(void); static char * curdir(void) { - static char path[MAXPATHLEN+1]; /* path + '/' */ + static char path[PATH_MAX+1]; /* path + '/' */ if (getcwd(path, sizeof(path)-1) == NULL) return (""); @@ -702,7 +702,7 @@ sgetpwnam(char *name, struct passwd *pw) static int login_attempts; /* number of failed login attempts */ static int askpasswd; /* had user command, ask for passwd */ -static char curname[MAXLOGNAME]; /* current USER name */ +static char curname[LOGIN_NAME_MAX]; /* current USER name */ /* * USER command. @@ -906,8 +906,8 @@ pass(char *passwd) int authok; unsigned int flags; FILE *fp; - static char homedir[MAXPATHLEN]; - char *motd, *dir, rootdir[MAXPATHLEN]; + static char homedir[PATH_MAX]; + char *motd, *dir, rootdir[PATH_MAX]; size_t sz_pw_dir; if (logged_in || askpasswd == 0) { @@ -1101,7 +1101,7 @@ pass(char *passwd) /* * Set home directory so that use of ~ (tilde) works correctly. */ - if (getcwd(homedir, MAXPATHLEN) != NULL) { + if (getcwd(homedir, PATH_MAX) != NULL) { if (setenv("HOME", homedir, 1) == -1) { reply(550, "Can't setup environment."); goto bad; @@ -1469,7 +1469,7 @@ dataconn(char *name, off_t size, char *mode) (void) fclose(file); file = getdatasock(mode); if (file == NULL) { - char hbuf[MAXHOSTNAMELEN], pbuf[10]; + char hbuf[HOST_NAME_MAX+1], pbuf[10]; error = getnameinfo((struct sockaddr *)&data_source, data_source.su_len, hbuf, sizeof(hbuf), pbuf, @@ -1814,7 +1814,7 @@ statcmd(void) { union sockunion *su; u_char *a, *p; - char hbuf[MAXHOSTNAMELEN]; + char hbuf[HOST_NAME_MAX+1]; int ispassive; int error; @@ -2092,7 +2092,7 @@ void replydirname(const char *name, const char *message) { char *p, *ep; - char npath[MAXPATHLEN * 2]; + char npath[PATH_MAX * 2]; p = npath; ep = &npath[sizeof(npath) - 1]; @@ -2137,7 +2137,7 @@ removedir(char *name) void pwd(void) { - char path[MAXPATHLEN]; + char path[PATH_MAX]; if (getcwd(path, sizeof(path)) == NULL) perror_reply(550, "Can't get current directory"); @@ -2596,7 +2596,7 @@ epsv_protounsupp(const char *message) static int guniquefd(char *local, char **nam) { - static char new[MAXPATHLEN]; + static char new[PATH_MAX]; struct stat st; int count, len, fd; char *cp; @@ -2715,7 +2715,7 @@ send_file_list(char *whichf) continue; while ((dir = readdir(dirp)) != NULL) { - char nbuf[MAXPATHLEN]; + char nbuf[PATH_MAX]; if (recvurg) { myoob(); @@ -2797,9 +2797,9 @@ reapchild(int signo) void logxfer(char *name, off_t size, time_t start) { - char buf[400 + MAXHOSTNAMELEN*4 + MAXPATHLEN*4]; - char dir[MAXPATHLEN], path[MAXPATHLEN], rpath[MAXPATHLEN]; - char vremotehost[MAXHOSTNAMELEN*4], vpath[MAXPATHLEN*4]; + char buf[400 + (HOST_NAME_MAX+1)*4 + PATH_MAX*4]; + char dir[PATH_MAX], path[PATH_MAX], rpath[PATH_MAX]; + char vremotehost[(HOST_NAME_MAX+1)*4], vpath[PATH_MAX*4]; char *vpw; time_t now; int len; diff --git a/libexec/login_passwd/common.h b/libexec/login_passwd/common.h index 18eca80aad7..aeaee7b41e4 100644 --- a/libexec/login_passwd/common.h +++ b/libexec/login_passwd/common.h @@ -1,4 +1,4 @@ -/* $OpenBSD: common.h,v 1.4 2012/06/01 01:43:19 dlg Exp $ */ +/* $OpenBSD: common.h,v 1.5 2015/01/16 06:39:50 deraadt Exp $ */ /*- * Copyright (c) 2001 Hans Insulander <hin@openbsd.org>. * All rights reserved. @@ -30,7 +30,6 @@ #include <sys/types.h> #include <sys/resource.h> -#include <sys/param.h> #include <signal.h> #include <syslog.h> @@ -43,6 +42,7 @@ #include <pwd.h> #include <err.h> #include <util.h> +#include <limits.h> #define MODE_LOGIN 0 diff --git a/libexec/login_passwd/login.c b/libexec/login_passwd/login.c index 4f73489e463..6548178e001 100644 --- a/libexec/login_passwd/login.c +++ b/libexec/login_passwd/login.c @@ -1,4 +1,4 @@ -/* $OpenBSD: login.c,v 1.10 2012/06/01 01:43:19 dlg Exp $ */ +/* $OpenBSD: login.c,v 1.11 2015/01/16 06:39:50 deraadt Exp $ */ /*- * Copyright (c) 1995 Berkeley Software Design, Inc. All rights reserved. @@ -45,7 +45,7 @@ main(int argc, char **argv) char *username, *password = NULL; char response[1024]; int arg_login = 0, arg_notickets = 0; - char invokinguser[MAXLOGNAME]; + char invokinguser[LOGIN_NAME_MAX]; char *wheel = NULL, *class = NULL; invokinguser[0] = '\0'; diff --git a/libexec/login_radius/raddauth.c b/libexec/login_radius/raddauth.c index b0fb6933451..71089908058 100644 --- a/libexec/login_radius/raddauth.c +++ b/libexec/login_radius/raddauth.c @@ -1,4 +1,4 @@ -/* $OpenBSD: raddauth.c,v 1.26 2014/08/10 05:06:38 guenther Exp $ */ +/* $OpenBSD: raddauth.c,v 1.27 2015/01/16 06:39:50 deraadt Exp $ */ /*- * Copyright (c) 1996, 1997 Berkeley Software Design, Inc. All rights reserved. @@ -483,7 +483,7 @@ rad_recv(char *state, char *challenge, u_char *req_vector) in_addr_t gethost(void) { - char hostname[MAXHOSTNAMELEN]; + char hostname[HOST_NAME_MAX+1]; if (gethostname(hostname, sizeof(hostname))) err(1, "gethost"); @@ -511,7 +511,7 @@ void getsecret(void) { FILE *servfd; - char *host, *secret, buffer[MAXPATHLEN]; + char *host, *secret, buffer[PATH_MAX]; size_t len; snprintf(buffer, sizeof(buffer), "%s/%s", diff --git a/libexec/login_skey/login_skey.c b/libexec/login_skey/login_skey.c index b67e78ad287..63838238e17 100644 --- a/libexec/login_skey/login_skey.c +++ b/libexec/login_skey/login_skey.c @@ -1,4 +1,4 @@ -/* $OpenBSD: login_skey.c,v 1.23 2009/06/02 20:42:48 jmeltzer Exp $ */ +/* $OpenBSD: login_skey.c,v 1.24 2015/01/16 06:39:50 deraadt Exp $ */ /* * Copyright (c) 2000, 2001, 2004 Todd C. Miller <Todd.Miller@courtesan.com> @@ -16,7 +16,6 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#include <sys/param.h> #include <sys/socket.h> #include <sys/stat.h> #include <sys/time.h> @@ -34,6 +33,7 @@ #include <string.h> #include <syslog.h> #include <unistd.h> +#include <limits.h> #include <login_cap.h> #include <bsd_auth.h> diff --git a/libexec/login_tis/login_tis.c b/libexec/login_tis/login_tis.c index 7bd493cde60..3ac22aaa3f1 100644 --- a/libexec/login_tis/login_tis.c +++ b/libexec/login_tis/login_tis.c @@ -1,4 +1,4 @@ -/* $OpenBSD: login_tis.c,v 1.11 2012/12/04 02:24:47 deraadt Exp $ */ +/* $OpenBSD: login_tis.c,v 1.12 2015/01/16 06:39:50 deraadt Exp $ */ /* * Copyright (c) 2004 Todd C. Miller <Todd.Miller@courtesan.com> @@ -33,6 +33,7 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> +#include <limits.h> #include <syslog.h> #include <unistd.h> diff --git a/libexec/login_yubikey/login_yubikey.c b/libexec/login_yubikey/login_yubikey.c index 57170d4c79f..8580a836a8b 100644 --- a/libexec/login_yubikey/login_yubikey.c +++ b/libexec/login_yubikey/login_yubikey.c @@ -1,4 +1,4 @@ -/* $OpenBSD: login_yubikey.c,v 1.9 2014/05/28 12:59:03 otto Exp $ */ +/* $OpenBSD: login_yubikey.c,v 1.10 2015/01/16 06:39:50 deraadt Exp $ */ /* * Copyright (c) 2010 Daniel Hartmeier <daniel@benzedrine.cx> @@ -30,7 +30,6 @@ * */ -#include <sys/param.h> #include <sys/stat.h> #include <sys/time.h> #include <sys/resource.h> @@ -43,6 +42,7 @@ #include <string.h> #include <syslog.h> #include <unistd.h> +#include <limits.h> #include <errno.h> #include "yubikey.h" @@ -178,7 +178,7 @@ clean_string(const char *s) static int yubikey_login(const char *username, const char *password) { - char fn[MAXPATHLEN]; + char fn[PATH_MAX]; char hexkey[33], key[YUBIKEY_KEY_SIZE]; char hexuid[13], uid[YUBIKEY_UID_SIZE]; FILE *f; diff --git a/libexec/mail.local/locking.c b/libexec/mail.local/locking.c index a9a2a8d1881..191b2dfeed7 100644 --- a/libexec/mail.local/locking.c +++ b/libexec/mail.local/locking.c @@ -1,4 +1,4 @@ -/* $OpenBSD: locking.c,v 1.11 2014/01/17 21:42:47 tobias Exp $ */ +/* $OpenBSD: locking.c,v 1.12 2015/01/16 06:39:50 deraadt Exp $ */ /* * Copyright (c) 1996-1998 Theo de Raadt <deraadt@theos.com> @@ -28,13 +28,14 @@ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include <sys/param.h> +#include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> #include <pwd.h> #include <syslog.h> #include <time.h> #include <unistd.h> +#include <limits.h> #include <errno.h> #include <stdio.h> #include <stdlib.h> @@ -43,7 +44,7 @@ #include "pathnames.h" #include "mail.local.h" -static char lpath[MAXPATHLEN]; +static char lpath[PATH_MAX]; void rellock(void) @@ -141,7 +142,7 @@ again: void baditem(char *path) { - char npath[MAXPATHLEN]; + char npath[PATH_MAX]; int fd; if (unlink(path) == 0) diff --git a/libexec/mail.local/mail.local.c b/libexec/mail.local/mail.local.c index 5c776327558..5231b44661d 100644 --- a/libexec/mail.local/mail.local.c +++ b/libexec/mail.local/mail.local.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mail.local.c,v 1.32 2009/10/27 23:59:31 deraadt Exp $ */ +/* $OpenBSD: mail.local.c,v 1.33 2015/01/16 06:39:50 deraadt Exp $ */ /*- * Copyright (c) 1996-1998 Theo de Raadt <deraadt@theos.com> @@ -31,7 +31,7 @@ * SUCH DAMAGE. */ -#include <sys/param.h> +#include <sys/types.h> #include <sys/stat.h> #include <sys/socket.h> #include <netinet/in.h> @@ -41,6 +41,7 @@ #include <pwd.h> #include <time.h> #include <unistd.h> +#include <limits.h> #include <errno.h> #include <stdio.h> #include <stdlib.h> @@ -171,7 +172,7 @@ deliver(int fd, char *name, int lockfile) struct stat sb, fsb; struct passwd *pw; int mbfd=-1, rval=1, lfd=-1; - char biffmsg[100], buf[8*1024], path[MAXPATHLEN]; + char biffmsg[100], buf[8*1024], path[PATH_MAX]; off_t curoff; size_t off; ssize_t nr, nw; diff --git a/libexec/rpc.rquotad/rquotad.c b/libexec/rpc.rquotad/rquotad.c index f357b26c7af..12b854eded1 100644 --- a/libexec/rpc.rquotad/rquotad.c +++ b/libexec/rpc.rquotad/rquotad.c @@ -1,10 +1,10 @@ -/* $OpenBSD: rquotad.c,v 1.21 2014/10/08 04:29:16 deraadt Exp $ */ +/* $OpenBSD: rquotad.c,v 1.22 2015/01/16 06:39:50 deraadt Exp $ */ /* * by Manuel Bouyer (bouyer@ensta.fr). Public domain. */ -#include <sys/param.h> +#include <sys/param.h> /* DEV_BSIZE */ #include <sys/types.h> #include <sys/mount.h> #include <sys/socket.h> diff --git a/libexec/rpc.rstatd/rstat_proc.c b/libexec/rpc.rstatd/rstat_proc.c index 793ca385924..1b73cba4128 100644 --- a/libexec/rpc.rstatd/rstat_proc.c +++ b/libexec/rpc.rstatd/rstat_proc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rstat_proc.c,v 1.32 2014/09/15 19:08:19 miod Exp $ */ +/* $OpenBSD: rstat_proc.c,v 1.33 2015/01/16 06:39:50 deraadt Exp $ */ /* * Copyright (c) 2010, Oracle America, Inc. @@ -35,7 +35,7 @@ * rstat service: built with rstat.x and derived from rpc.rstatd.c */ -#include <sys/param.h> +#include <sys/types.h> #include <sys/sched.h> #include <sys/socket.h> #include <sys/sysctl.h> diff --git a/libexec/spamd-setup/spamd-setup.c b/libexec/spamd-setup/spamd-setup.c index d88b31181db..9f37ee1c182 100644 --- a/libexec/spamd-setup/spamd-setup.c +++ b/libexec/spamd-setup/spamd-setup.c @@ -1,4 +1,4 @@ -/* $OpenBSD: spamd-setup.c,v 1.42 2015/01/14 11:59:10 millert Exp $ */ +/* $OpenBSD: spamd-setup.c,v 1.43 2015/01/16 06:39:50 deraadt Exp $ */ /* * Copyright (c) 2003 Bob Beck. All rights reserved. @@ -89,6 +89,8 @@ int greyonly = 1; extern char *__progname; +#define MAXIMUM(a,b) (((a)>(b))?(a):(b)) + u_int32_t imask(u_int8_t b) { @@ -140,7 +142,7 @@ range2cidrlist(struct cidr *list, u_int *cli, u_int *cls, u_int32_t start, maxsize = maxblock(start, 32); diff = maxdiff(start, end); - maxsize = MAX(maxsize, diff); + maxsize = MAXIMUM(maxsize, diff); if (*cls <= *cli + 1) { /* one extra for terminator */ tmp = reallocarray(list, *cls + 32, sizeof(struct cidr)); diff --git a/libexec/spamd/spamd.c b/libexec/spamd/spamd.c index 87d5eeffe9f..ea6a06f15d4 100644 --- a/libexec/spamd/spamd.c +++ b/libexec/spamd/spamd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: spamd.c,v 1.121 2015/01/13 23:22:33 millert Exp $ */ +/* $OpenBSD: spamd.c,v 1.122 2015/01/16 06:39:50 deraadt Exp $ */ /* * Copyright (c) 2002-2007 Bob Beck. All rights reserved. @@ -17,10 +17,11 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#include <sys/param.h> +#include <sys/types.h> #include <sys/socket.h> #include <sys/sysctl.h> #include <sys/resource.h> +#include <sys/signal.h> #include <netinet/in.h> #include <arpa/inet.h> @@ -35,6 +36,7 @@ #include <string.h> #include <syslog.h> #include <unistd.h> +#include <limits.h> #include <netdb.h> @@ -101,7 +103,7 @@ void getcaddr(struct con *); void gethelo(char *, size_t, char *); int read_configline(FILE *); -char hostname[MAXHOSTNAMELEN]; +char hostname[HOST_NAME_MAX+1]; struct syslog_data sdata = SYSLOG_DATA_INIT; char *nreply = "450"; char *spamd = "spamd IP-based SPAM blocker"; @@ -147,6 +149,8 @@ int syncrecv; int syncsend; #define MAXTIME 400 +#define MAXIMUM(a,b) (((a)>(b))?(a):(b)) + void usage(void) { @@ -1382,16 +1386,16 @@ jail: int max, n; int writers; - max = MAX(s, conflisten); + max = MAXIMUM(s, conflisten); if (syncrecv) - max = MAX(max, syncfd); - max = MAX(max, conffd); - max = MAX(max, trapfd); + max = MAXIMUM(max, syncfd); + max = MAXIMUM(max, conffd); + max = MAXIMUM(max, trapfd); time(&t); for (i = 0; i < maxcon; i++) if (con[i].fd != -1) - max = MAX(max, con[i].fd); + max = MAXIMUM(max, con[i].fd); if (max > omax) { free(fdsr); diff --git a/libexec/spamlogd/spamlogd.c b/libexec/spamlogd/spamlogd.c index 8c4ae14f5dc..18ce44a1e94 100644 --- a/libexec/spamlogd/spamlogd.c +++ b/libexec/spamlogd/spamlogd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: spamlogd.c,v 1.23 2014/10/25 03:19:22 lteo Exp $ */ +/* $OpenBSD: spamlogd.c,v 1.24 2015/01/16 06:39:50 deraadt Exp $ */ /* * Copyright (c) 2006 Henning Brauer <henning@openbsd.org> @@ -26,6 +26,7 @@ #include <sys/types.h> #include <sys/socket.h> #include <sys/ioctl.h> +#include <sys/signal.h> #include <net/if.h> #include <net/if_pflog.h> diff --git a/libexec/talkd/announce.c b/libexec/talkd/announce.c index 1ba6286d536..421b9663fa9 100644 --- a/libexec/talkd/announce.c +++ b/libexec/talkd/announce.c @@ -1,4 +1,4 @@ -/* $OpenBSD: announce.c,v 1.22 2013/04/17 17:40:53 deraadt Exp $ */ +/* $OpenBSD: announce.c,v 1.23 2015/01/16 06:39:51 deraadt Exp $ */ /* * Copyright (c) 1983 Regents of the University of California. @@ -29,7 +29,6 @@ * SUCH DAMAGE. */ -#include <sys/param.h> #include <sys/types.h> #include <sys/stat.h> #include <sys/time.h> @@ -39,6 +38,7 @@ #include <errno.h> #include <syslog.h> #include <unistd.h> +#include <limits.h> #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -55,7 +55,7 @@ static void print_mesg(FILE *,CTL_MSG *,char *); int announce(CTL_MSG *request, char *remote_machine) { - char full_tty[MAXPATHLEN]; + char full_tty[PATH_MAX]; FILE *tf; struct stat stbuf; diff --git a/libexec/talkd/process.c b/libexec/talkd/process.c index 49c627e0f28..91b10ee4818 100644 --- a/libexec/talkd/process.c +++ b/libexec/talkd/process.c @@ -1,4 +1,4 @@ -/* $OpenBSD: process.c,v 1.20 2013/11/27 21:25:24 deraadt Exp $ */ +/* $OpenBSD: process.c,v 1.21 2015/01/16 06:39:51 deraadt Exp $ */ /* * Copyright (c) 1983 Regents of the University of California. @@ -37,7 +37,6 @@ * in the table for the local user * DELETE - delete invitation */ -#include <sys/param.h> #include <sys/stat.h> #include <sys/socket.h> #include <netinet/in.h> @@ -49,6 +48,7 @@ #include <string.h> #include <ctype.h> #include <paths.h> +#include <limits.h> #include "talkd.h" #define satosin(sa) ((struct sockaddr_in *)(sa)) @@ -192,7 +192,7 @@ find_user(char *name, char *tty, size_t ttyl) int status; FILE *fp; char line[UT_LINESIZE+1]; - char ftty[MAXPATHLEN]; + char ftty[PATH_MAX]; time_t idle, now; time(&now); diff --git a/libexec/talkd/table.c b/libexec/talkd/table.c index c75b1f76783..556ddfd4d66 100644 --- a/libexec/talkd/table.c +++ b/libexec/talkd/table.c @@ -1,4 +1,4 @@ -/* $OpenBSD: table.c,v 1.15 2014/10/08 02:10:05 deraadt Exp $ */ +/* $OpenBSD: table.c,v 1.16 2015/01/16 06:39:51 deraadt Exp $ */ /* * Copyright (c) 1983 Regents of the University of California. @@ -37,7 +37,6 @@ * * Consider this a mis-guided attempt at modularity */ -#include <sys/param.h> #include <sys/time.h> #include <sys/socket.h> #include <sys/queue.h> diff --git a/libexec/talkd/talkd.c b/libexec/talkd/talkd.c index ee2e7be2bad..f28d7acf071 100644 --- a/libexec/talkd/talkd.c +++ b/libexec/talkd/talkd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: talkd.c,v 1.22 2009/10/27 23:59:31 deraadt Exp $ */ +/* $OpenBSD: talkd.c,v 1.23 2015/01/16 06:39:51 deraadt Exp $ */ /* * Copyright (c) 1983 Regents of the University of California. @@ -35,7 +35,6 @@ * disconnect all descriptors and ttys, and then endless * loop on waiting for and processing requests */ -#include <sys/param.h> #include <sys/types.h> #include <sys/socket.h> #include <protocols/talkd.h> @@ -44,6 +43,7 @@ #include <time.h> #include <errno.h> #include <unistd.h> +#include <limits.h> #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -54,7 +54,7 @@ int debug = 0; void timeout(int); long lastmsgtime; -char hostname[MAXHOSTNAMELEN]; +char hostname[HOST_NAME_MAX+1]; #define TIMEOUT 30 #define MAXIDLE 120 diff --git a/sbin/atactl/atactl.c b/sbin/atactl/atactl.c index aa5479bd773..8d6263a81e3 100644 --- a/sbin/atactl/atactl.c +++ b/sbin/atactl/atactl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: atactl.c,v 1.44 2011/05/04 21:40:07 oga Exp $ */ +/* $OpenBSD: atactl.c,v 1.45 2015/01/16 06:39:56 deraadt Exp $ */ /* $NetBSD: atactl.c,v 1.4 1999/02/24 18:49:14 jwise Exp $ */ /*- @@ -34,7 +34,7 @@ * atactl(8) - a program to control ATA devices. */ -#include <sys/param.h> +#include <sys/param.h> /* DEV_BSIZE */ #include <sys/ioctl.h> #include <err.h> diff --git a/sbin/badsect/badsect.c b/sbin/badsect/badsect.c index 197d85d5920..42a506848bd 100644 --- a/sbin/badsect/badsect.c +++ b/sbin/badsect/badsect.c @@ -1,4 +1,4 @@ -/* $OpenBSD: badsect.c,v 1.24 2014/05/22 14:38:48 krw Exp $ */ +/* $OpenBSD: badsect.c,v 1.25 2015/01/16 06:39:56 deraadt Exp $ */ /* $NetBSD: badsect.c,v 1.10 1995/03/18 14:54:28 cgd Exp $ */ /* @@ -40,7 +40,7 @@ * this program can be used if the driver for the file system in question * does not support bad block forwarding. */ -#include <sys/param.h> +#include <sys/param.h> /* MAXFRAG MAXBSIZE DEV_BSIZE isclr */ #include <sys/stat.h> #include <ufs/ffs/fs.h> @@ -53,6 +53,7 @@ #include <stdlib.h> #include <string.h> #include <unistd.h> +#include <limits.h> #include <err.h> static int chkuse(daddr_t, int); diff --git a/sbin/bioctl/bioctl.c b/sbin/bioctl/bioctl.c index a3b92fb4fbb..4abe8495fb9 100644 --- a/sbin/bioctl/bioctl.c +++ b/sbin/bioctl/bioctl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bioctl.c,v 1.122 2014/10/08 10:08:03 jsing Exp $ */ +/* $OpenBSD: bioctl.c,v 1.123 2015/01/16 06:39:56 deraadt Exp $ */ /* * Copyright (c) 2004, 2005 Marco Peereboom @@ -27,7 +27,7 @@ * */ -#include <sys/param.h> +#include <sys/param.h> /* NODEV */ #include <sys/ioctl.h> #include <sys/dkio.h> #include <sys/stat.h> @@ -43,6 +43,7 @@ #include <stdlib.h> #include <string.h> #include <unistd.h> +#include <limits.h> #include <vis.h> #include <readpassphrase.h> @@ -931,7 +932,7 @@ bio_parse_devlist(char *lst, dev_t *dt) u_int32_t sz = 0; int no_dev = 0, i, x; struct stat sb; - char dev[MAXPATHLEN]; + char dev[PATH_MAX]; int fd; if (!lst) diff --git a/sbin/clri/clri.c b/sbin/clri/clri.c index 22bd20a5aab..70653535014 100644 --- a/sbin/clri/clri.c +++ b/sbin/clri/clri.c @@ -1,4 +1,4 @@ -/* $OpenBSD: clri.c,v 1.13 2013/04/23 17:29:26 deraadt Exp $ */ +/* $OpenBSD: clri.c,v 1.14 2015/01/16 06:39:56 deraadt Exp $ */ /* $NetBSD: clri.c,v 1.19 2005/01/20 15:50:47 xtraeme Exp $ */ /* @@ -33,7 +33,7 @@ * SUCH DAMAGE. */ -#include <sys/param.h> +#include <sys/param.h> /* MAXFRAG MAXBSIZE DEV_BSIZE */ #include <ufs/ufs/dinode.h> #include <ufs/ffs/fs.h> diff --git a/sbin/dhclient/dhclient.c b/sbin/dhclient/dhclient.c index c218a2493d7..08a188a4703 100644 --- a/sbin/dhclient/dhclient.c +++ b/sbin/dhclient/dhclient.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dhclient.c,v 1.346 2014/12/10 02:34:03 krw Exp $ */ +/* $OpenBSD: dhclient.c,v 1.347 2015/01/16 06:39:56 deraadt Exp $ */ /* * Copyright 2004 Henning Brauer <henning@openbsd.org> @@ -68,7 +68,7 @@ char *path_dhclient_conf = _PATH_DHCLIENT_CONF; char *path_dhclient_db = NULL; -char path_option_db[MAXPATHLEN]; +char path_option_db[PATH_MAX]; int log_perror = 1; int nullfd = -1; @@ -441,7 +441,7 @@ main(int argc, char *argv[]) } break; case 'L': - strlcat(path_option_db, optarg, MAXPATHLEN); + strlcat(path_option_db, optarg, PATH_MAX); if (lstat(path_option_db, &sb) != -1) { if (!S_ISREG(sb.st_mode)) error("'%s' is not a regular file", diff --git a/sbin/dhclient/dhcpd.h b/sbin/dhclient/dhcpd.h index 200ad224f24..eedb1ea54d2 100644 --- a/sbin/dhclient/dhcpd.h +++ b/sbin/dhclient/dhcpd.h @@ -1,4 +1,4 @@ -/* $OpenBSD: dhcpd.h,v 1.146 2014/12/10 02:34:03 krw Exp $ */ +/* $OpenBSD: dhcpd.h,v 1.147 2015/01/16 06:39:56 deraadt Exp $ */ /* * Copyright (c) 2004 Henning Brauer <henning@openbsd.org> @@ -65,6 +65,7 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> +#include <signal.h> #include <syslog.h> #include <time.h> #include <unistd.h> diff --git a/sbin/dhclient/privsep.h b/sbin/dhclient/privsep.h index 4f4ff2965be..eae657aafff 100644 --- a/sbin/dhclient/privsep.h +++ b/sbin/dhclient/privsep.h @@ -1,4 +1,4 @@ -/* $OpenBSD: privsep.h,v 1.23 2013/12/10 17:02:35 krw Exp $ */ +/* $OpenBSD: privsep.h,v 1.24 2015/01/16 06:39:56 deraadt Exp $ */ /* * Copyright (c) 2004 Henning Brauer <henning@openbsd.org> @@ -65,7 +65,7 @@ struct imsg_hup { }; struct imsg_write_file { - char path[MAXPATHLEN]; + char path[PATH_MAX]; int rdomain; int flags; mode_t mode; diff --git a/sbin/disklabel/disklabel.c b/sbin/disklabel/disklabel.c index 6955b45db66..5bbc14804cf 100644 --- a/sbin/disklabel/disklabel.c +++ b/sbin/disklabel/disklabel.c @@ -1,4 +1,4 @@ -/* $OpenBSD: disklabel.c,v 1.196 2014/07/20 01:38:40 guenther Exp $ */ +/* $OpenBSD: disklabel.c,v 1.197 2015/01/16 06:39:57 deraadt Exp $ */ /* * Copyright (c) 1987, 1993 @@ -32,7 +32,7 @@ * SUCH DAMAGE. */ -#include <sys/param.h> +#include <sys/param.h> /* MAXFRAG DEV_BSIZE */ #include <sys/ioctl.h> #include <sys/dkio.h> #include <sys/stat.h> diff --git a/sbin/disklabel/editor.c b/sbin/disklabel/editor.c index f323e623db5..ef8c3475e65 100644 --- a/sbin/disklabel/editor.c +++ b/sbin/disklabel/editor.c @@ -1,4 +1,4 @@ -/* $OpenBSD: editor.c,v 1.288 2014/10/11 03:08:26 doug Exp $ */ +/* $OpenBSD: editor.c,v 1.289 2015/01/16 06:39:57 deraadt Exp $ */ /* * Copyright (c) 1997-2000 Todd C. Miller <Todd.Miller@courtesan.com> @@ -16,8 +16,9 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#include <sys/param.h> /* MAXBSIZE DEV_BSIZE MAXFRAG */ #include <sys/types.h> -#include <sys/param.h> +#include <sys/signal.h> #include <sys/stat.h> #include <sys/ioctl.h> #include <sys/dkio.h> @@ -35,10 +36,13 @@ #include <stdio.h> #include <stdlib.h> #include <unistd.h> +#include <limits.h> #include "extern.h" #include "pathnames.h" +#define MAXIMUM(a, b) (((a) > (b)) ? (a) : (b)) + /* flags for getuint64() */ #define DO_CONVERSIONS 0x00000001 #define DO_ROUNDING 0x00000002 @@ -1465,7 +1469,7 @@ edit_parms(struct disklabel *lp) /* total sectors */ for (;;) { - u_int64_t nsec = MAX(DL_GETDSIZE(lp), + u_int64_t nsec = MAXIMUM(DL_GETDSIZE(lp), (u_int64_t)lp->d_ncylinders * lp->d_secpercyl); ui = getuint64(lp, "total sectors", "The total number of sectors on the disk.", @@ -1832,7 +1836,7 @@ void mpsave(struct disklabel *lp) { int i, j; - char bdev[MAXPATHLEN], *p; + char bdev[PATH_MAX], *p; struct mountinfo mi[MAXPARTITIONS]; FILE *fp; u_int8_t fstype; diff --git a/sbin/dmesg/dmesg.c b/sbin/dmesg/dmesg.c index a83c9fe81a7..53455ec3318 100644 --- a/sbin/dmesg/dmesg.c +++ b/sbin/dmesg/dmesg.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dmesg.c,v 1.24 2015/01/13 10:07:58 mpf Exp $ */ +/* $OpenBSD: dmesg.c,v 1.25 2015/01/16 06:39:57 deraadt Exp $ */ /* $NetBSD: dmesg.c,v 1.8 1995/03/18 14:54:49 cgd Exp $ */ /*- @@ -30,7 +30,7 @@ * SUCH DAMAGE. */ -#include <sys/param.h> +#include <sys/types.h> #include <sys/msgbuf.h> #include <sys/sysctl.h> diff --git a/sbin/dump/dumprmt.c b/sbin/dump/dumprmt.c index 0b6e2ca3172..108bd9ae4d0 100644 --- a/sbin/dump/dumprmt.c +++ b/sbin/dump/dumprmt.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dumprmt.c,v 1.28 2013/11/22 04:12:47 deraadt Exp $ */ +/* $OpenBSD: dumprmt.c,v 1.29 2015/01/16 06:39:57 deraadt Exp $ */ /* $NetBSD: dumprmt.c,v 1.17 1997/06/05 16:10:47 mrg Exp $ */ /*- @@ -30,7 +30,7 @@ * SUCH DAMAGE. */ -#include <sys/param.h> +#include <sys/param.h> /* MAXBSIZE */ #include <sys/mtio.h> #include <sys/ioctl.h> #include <sys/socket.h> @@ -52,6 +52,7 @@ #include <stdlib.h> #include <string.h> #include <unistd.h> +#include <limits.h> #include "pathnames.h" #include "dump.h" diff --git a/sbin/dump/itime.c b/sbin/dump/itime.c index b8c5edb0e48..2392c300969 100644 --- a/sbin/dump/itime.c +++ b/sbin/dump/itime.c @@ -1,4 +1,4 @@ -/* $OpenBSD: itime.c,v 1.18 2014/07/11 16:01:41 halex Exp $ */ +/* $OpenBSD: itime.c,v 1.19 2015/01/16 06:39:57 deraadt Exp $ */ /* $NetBSD: itime.c,v 1.4 1997/04/15 01:09:50 lukem Exp $ */ /*- @@ -30,7 +30,7 @@ * SUCH DAMAGE. */ -#include <sys/param.h> +#include <sys/param.h> /* MAXBSIZE */ #include <sys/time.h> #include <ufs/ufs/dinode.h> @@ -43,6 +43,7 @@ #include <stdlib.h> #include <string.h> #include <unistd.h> +#include <limits.h> #include "dump.h" diff --git a/sbin/dump/main.c b/sbin/dump/main.c index cdc62885d28..65101a9f38a 100644 --- a/sbin/dump/main.c +++ b/sbin/dump/main.c @@ -1,4 +1,4 @@ -/* $OpenBSD: main.c,v 1.52 2014/07/11 16:01:41 halex Exp $ */ +/* $OpenBSD: main.c,v 1.53 2015/01/16 06:39:57 deraadt Exp $ */ /* $NetBSD: main.c,v 1.14 1997/06/05 11:13:24 lukem Exp $ */ /*- @@ -30,7 +30,7 @@ * SUCH DAMAGE. */ -#include <sys/param.h> +#include <sys/param.h> /* MAXFRAG MAXBSIZE DEV_BSIZE roundup */ #include <sys/mount.h> #include <sys/stat.h> #include <sys/time.h> @@ -54,6 +54,7 @@ #include <string.h> #include <time.h> #include <unistd.h> +#include <limits.h> #include <util.h> #include "dump.h" @@ -652,7 +653,7 @@ sig(int signo) char * rawname(char *cp) { - static char rawbuf[MAXPATHLEN]; + static char rawbuf[PATH_MAX]; char *dp = strrchr(cp, '/'); if (dp == NULL) diff --git a/sbin/dump/optr.c b/sbin/dump/optr.c index 4e67f11bb77..74416bd9184 100644 --- a/sbin/dump/optr.c +++ b/sbin/dump/optr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: optr.c,v 1.34 2013/11/12 04:59:02 deraadt Exp $ */ +/* $OpenBSD: optr.c,v 1.35 2015/01/16 06:39:57 deraadt Exp $ */ /* $NetBSD: optr.c,v 1.11 1997/05/27 08:34:36 mrg Exp $ */ /*- @@ -30,7 +30,7 @@ * SUCH DAMAGE. */ -#include <sys/param.h> +#include <sys/param.h> /* MAXBSIZE */ #include <sys/wait.h> #include <sys/time.h> @@ -46,6 +46,7 @@ #include <stdarg.h> #include <tzfile.h> #include <unistd.h> +#include <limits.h> #include <utmp.h> #include "dump.h" diff --git a/sbin/dump/tape.c b/sbin/dump/tape.c index 14b4df1602d..ddecaecda36 100644 --- a/sbin/dump/tape.c +++ b/sbin/dump/tape.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tape.c,v 1.40 2014/06/13 20:43:06 naddy Exp $ */ +/* $OpenBSD: tape.c,v 1.41 2015/01/16 06:39:57 deraadt Exp $ */ /* $NetBSD: tape.c,v 1.11 1997/06/05 11:13:26 lukem Exp $ */ /*- @@ -30,8 +30,7 @@ * SUCH DAMAGE. */ -#include <sys/types.h> -#include <sys/param.h> +#include <sys/param.h> /* MAXFRAG MAXBSIZE DEV_BSIZE */ #include <sys/socket.h> #include <sys/time.h> #include <sys/wait.h> @@ -49,10 +48,13 @@ #include <string.h> #include <time.h> #include <unistd.h> +#include <limits.h> #include "dump.h" #include "pathnames.h" +#define MINIMUM(a, b) (((a) < (b)) ? (a) : (b)) + int writesize; /* size of malloc()ed buffer for tape */ int64_t lastspclrec = -1; /* tape block number of last written header */ int trecno = 0; /* next record to write in current block */ @@ -175,7 +177,7 @@ dumpblock(daddr_t blkno, int size) dblkno = fsbtodb(sblock, blkno); tpblks = size >> tp_bshift; - while ((avail = MIN(tpblks, ntrec - trecno)) > 0) { + while ((avail = MINIMUM(tpblks, ntrec - trecno)) > 0) { slp->req[trecno].dblk = dblkno; slp->req[trecno].count = avail; trecno += avail; diff --git a/sbin/dump/traverse.c b/sbin/dump/traverse.c index 97faff55214..3a49a7aae7a 100644 --- a/sbin/dump/traverse.c +++ b/sbin/dump/traverse.c @@ -1,4 +1,4 @@ -/* $OpenBSD: traverse.c,v 1.36 2014/07/10 09:33:43 krw Exp $ */ +/* $OpenBSD: traverse.c,v 1.37 2015/01/16 06:39:57 deraadt Exp $ */ /* $NetBSD: traverse.c,v 1.17 1997/06/05 11:13:27 lukem Exp $ */ /*- @@ -30,7 +30,7 @@ * SUCH DAMAGE. */ -#include <sys/param.h> +#include <sys/param.h> /* MAXFRAG MAXBSIZE DEV_BSIZE dbtob */ #include <sys/time.h> #include <sys/stat.h> #include <sys/disklabel.h> @@ -47,6 +47,7 @@ #include <stdlib.h> #include <string.h> #include <unistd.h> +#include <limits.h> #include "dump.h" @@ -209,7 +210,7 @@ mapfiles(ino_t maxino, int64_t *tapesize, char *disk, char * const *dirv) int anydirskipped = 0; if (dirv != NULL) { - char curdir[MAXPATHLEN]; + char curdir[PATH_MAX]; FTS *dirh; FTSENT *entry; int d; @@ -247,7 +248,7 @@ mapfiles(ino_t maxino, int64_t *tapesize, char *disk, char * const *dirv) * Add any parent directories */ for (d = 0 ; dirv[d] != NULL ; d++) { - char path[MAXPATHLEN]; + char path[PATH_MAX]; if (dirv[d][0] != '/') (void)snprintf(path, sizeof(path), "%s/%s", diff --git a/sbin/dumpfs/dumpfs.c b/sbin/dumpfs/dumpfs.c index 7633b89fc23..f7cdb38768e 100644 --- a/sbin/dumpfs/dumpfs.c +++ b/sbin/dumpfs/dumpfs.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dumpfs.c,v 1.30 2014/05/13 12:51:40 krw Exp $ */ +/* $OpenBSD: dumpfs.c,v 1.31 2015/01/16 06:39:57 deraadt Exp $ */ /* * Copyright (c) 2002 Networks Associates Technology, Inc. @@ -38,7 +38,7 @@ * SUCH DAMAGE. */ -#include <sys/param.h> +#include <sys/param.h> /* DEV_BSIZE MAXFRAG MAXBSIZE isset */ #include <sys/time.h> #include <ufs/ufs/dinode.h> @@ -54,6 +54,8 @@ #include <unistd.h> #include <util.h> +#define MINIMUM(a, b) (((a) < (b)) ? (a) : (b)) + union { struct fs fs; char pad[MAXBSIZE]; @@ -184,7 +186,7 @@ dumpfs(int fd, const char *name) max = afs.fs_maxcontig; size = afs.fs_contigsumsize; if ((max < 2 && size == 0) || - (max > 1 && size >= MIN(max, FS_MAXCONTIG))) + (max > 1 && size >= MINIMUM(max, FS_MAXCONTIG))) i++; } } diff --git a/sbin/fdisk/mbr.c b/sbin/fdisk/mbr.c index bde9732bfd8..95d4ec104a0 100644 --- a/sbin/fdisk/mbr.c +++ b/sbin/fdisk/mbr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mbr.c,v 1.41 2015/01/03 15:50:50 jsing Exp $ */ +/* $OpenBSD: mbr.c,v 1.42 2015/01/16 06:39:57 deraadt Exp $ */ /* * Copyright (c) 1997 Tobias Weingartner @@ -25,11 +25,10 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include <sys/types.h> +#include <sys/param.h> /* DEV_BSIZE */ #include <sys/fcntl.h> #include <sys/ioctl.h> #include <sys/stat.h> -#include <sys/param.h> #include <sys/disklabel.h> #include <sys/dkio.h> #include <err.h> diff --git a/sbin/fsck/fsck.c b/sbin/fsck/fsck.c index a006cd9c838..6ce454391bf 100644 --- a/sbin/fsck/fsck.c +++ b/sbin/fsck/fsck.c @@ -1,4 +1,4 @@ -/* $OpenBSD: fsck.c,v 1.32 2014/10/17 06:33:35 deraadt Exp $ */ +/* $OpenBSD: fsck.c,v 1.33 2015/01/16 06:39:57 deraadt Exp $ */ /* $NetBSD: fsck.c,v 1.7 1996/10/03 20:06:30 christos Exp $ */ /* @@ -35,7 +35,7 @@ * */ -#include <sys/param.h> +#include <sys/types.h> #include <sys/mount.h> #include <sys/queue.h> #include <sys/resource.h> @@ -49,6 +49,7 @@ #include <stdlib.h> #include <string.h> #include <unistd.h> +#include <limits.h> #include <util.h> #include "pathnames.h" @@ -243,7 +244,7 @@ checkfs(const char *vfstype, const char *spec, const char *mntpt, void *auxarg, const char **argv, **edir; pid_t pid; int argc, i, status, maxargc; - char *optbuf = NULL, fsname[MAXPATHLEN], execname[MAXPATHLEN]; + char *optbuf = NULL, fsname[PATH_MAX], execname[PATH_MAX]; const char *extra = getoptions(vfstype); if (strcmp(vfstype, "ufs") == 0) diff --git a/sbin/fsck/fsutil.c b/sbin/fsck/fsutil.c index 6b9adff3d11..e18335d1a95 100644 --- a/sbin/fsck/fsutil.c +++ b/sbin/fsck/fsutil.c @@ -1,4 +1,4 @@ -/* $OpenBSD: fsutil.c,v 1.19 2014/10/08 16:27:53 deraadt Exp $ */ +/* $OpenBSD: fsutil.c,v 1.20 2015/01/16 06:39:57 deraadt Exp $ */ /* $NetBSD: fsutil.c,v 1.2 1996/10/03 20:06:31 christos Exp $ */ /* @@ -30,13 +30,13 @@ * SUCH DAMAGE. */ -#include <sys/param.h> #include <stdio.h> #include <string.h> #include <stdlib.h> #include <stdarg.h> #include <errno.h> #include <fstab.h> +#include <limits.h> #include <err.h> #include <sys/types.h> @@ -169,7 +169,7 @@ unrawname(char *name) char * rawname(char *name) { - static char rawbuf[MAXPATHLEN]; + static char rawbuf[PATH_MAX]; char *dp; if ((dp = strrchr(name, '/')) == NULL) diff --git a/sbin/fsck/preen.c b/sbin/fsck/preen.c index 342695c75c6..9e635d91cce 100644 --- a/sbin/fsck/preen.c +++ b/sbin/fsck/preen.c @@ -1,4 +1,4 @@ -/* $OpenBSD: preen.c,v 1.19 2013/11/22 04:14:00 deraadt Exp $ */ +/* $OpenBSD: preen.c,v 1.20 2015/01/16 06:39:57 deraadt Exp $ */ /* $NetBSD: preen.c,v 1.15 1996/09/28 19:21:42 christos Exp $ */ /* @@ -30,7 +30,6 @@ * SUCH DAMAGE. */ -#include <sys/param.h> #include <sys/stat.h> #include <sys/wait.h> #include <sys/queue.h> diff --git a/sbin/fsck_ext2fs/dir.c b/sbin/fsck_ext2fs/dir.c index cda8b6f3c9d..9864bacd0d3 100644 --- a/sbin/fsck_ext2fs/dir.c +++ b/sbin/fsck_ext2fs/dir.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dir.c,v 1.19 2014/07/13 16:08:53 pelikan Exp $ */ +/* $OpenBSD: dir.c,v 1.20 2015/01/16 06:39:57 deraadt Exp $ */ /* $NetBSD: dir.c,v 1.5 2000/01/28 16:01:46 bouyer Exp $ */ /* @@ -31,7 +31,7 @@ * SUCH DAMAGE. */ -#include <sys/param.h> +#include <sys/param.h> /* DEV_BSIZE roundup */ #include <sys/time.h> #include <ufs/ufs/dir.h> #include <ufs/ext2fs/ext2fs_dinode.h> @@ -43,6 +43,7 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> +#include <limits.h> #include "fsck.h" #include "fsutil.h" @@ -256,7 +257,7 @@ void fileerror(ino_t cwd, ino_t ino, char *errmesg) { struct ext2fs_dinode *dp; - char pathbuf[MAXPATHLEN + 1]; + char pathbuf[PATH_MAX + 1]; pwarn("%s ", errmesg); pinode(ino); @@ -480,7 +481,7 @@ makeentry(ino_t parent, ino_t ino, char *name) { struct ext2fs_dinode *dp; struct inodesc idesc; - char pathbuf[MAXPATHLEN + 1]; + char pathbuf[PATH_MAX + 1]; if ((parent < EXT2_FIRSTINO && parent != EXT2_ROOTINO) || parent >= maxino || diff --git a/sbin/fsck_ext2fs/inode.c b/sbin/fsck_ext2fs/inode.c index 9327388906e..f3a78a8750d 100644 --- a/sbin/fsck_ext2fs/inode.c +++ b/sbin/fsck_ext2fs/inode.c @@ -1,4 +1,4 @@ -/* $OpenBSD: inode.c,v 1.24 2014/10/29 06:31:58 deraadt Exp $ */ +/* $OpenBSD: inode.c,v 1.25 2015/01/16 06:39:57 deraadt Exp $ */ /* $NetBSD: inode.c,v 1.8 2000/01/28 16:01:46 bouyer Exp $ */ /* @@ -31,7 +31,7 @@ * SUCH DAMAGE. */ -#include <sys/param.h> +#include <sys/param.h> /* btodb */ #include <sys/time.h> #include <ufs/ext2fs/ext2fs_dinode.h> #include <ufs/ext2fs/ext2fs_dir.h> @@ -45,6 +45,7 @@ #include <stdlib.h> #include <string.h> #include <time.h> +#include <limits.h> #include "fsck.h" #include "fsutil.h" @@ -118,7 +119,7 @@ ckinode(struct ext2fs_dinode *dp, struct inodesc *idesc) struct ext2fs_dinode dino; u_int64_t remsize, sizepb; mode_t mode; - char pathbuf[MAXPATHLEN + 1]; + char pathbuf[PATH_MAX + 1]; if (idesc->id_fix != IGNORE) idesc->id_fix = DONTKNOW; @@ -204,7 +205,7 @@ iblock(struct inodesc *idesc, long ilevel, u_int64_t isize) int i, n, (*func)(struct inodesc *), nif; u_int64_t sizepb; char buf[BUFSIZ]; - char pathbuf[MAXPATHLEN + 1]; + char pathbuf[PATH_MAX + 1]; struct ext2fs_dinode *dp; if (idesc->id_type == ADDR) { diff --git a/sbin/fsck_ext2fs/main.c b/sbin/fsck_ext2fs/main.c index 830379dff03..1db5abfe35e 100644 --- a/sbin/fsck_ext2fs/main.c +++ b/sbin/fsck_ext2fs/main.c @@ -1,4 +1,4 @@ -/* $OpenBSD: main.c,v 1.20 2014/05/21 17:52:26 krw Exp $ */ +/* $OpenBSD: main.c,v 1.21 2015/01/16 06:39:57 deraadt Exp $ */ /* $NetBSD: main.c,v 1.1 1997/06/11 11:21:50 bouyer Exp $ */ /* @@ -31,7 +31,8 @@ * SUCH DAMAGE. */ -#include <sys/param.h> +#include <sys/types.h> +#include <sys/signal.h> #include <sys/time.h> #include <sys/mount.h> #include <ufs/ext2fs/ext2fs_dinode.h> diff --git a/sbin/fsck_ext2fs/pass1.c b/sbin/fsck_ext2fs/pass1.c index 6f463e9bf57..608d45e3f37 100644 --- a/sbin/fsck_ext2fs/pass1.c +++ b/sbin/fsck_ext2fs/pass1.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pass1.c,v 1.14 2014/07/13 16:08:53 pelikan Exp $ */ +/* $OpenBSD: pass1.c,v 1.15 2015/01/16 06:39:57 deraadt Exp $ */ /* $NetBSD: pass1.c,v 1.9 2000/01/31 11:40:12 bouyer Exp $ */ /* @@ -31,7 +31,7 @@ * SUCH DAMAGE. */ -#include <sys/param.h> +#include <sys/param.h> /* setbit btodb isset */ #include <sys/time.h> #include <ufs/ext2fs/ext2fs_dinode.h> #include <ufs/ext2fs/ext2fs_dir.h> diff --git a/sbin/fsck_ext2fs/pass1b.c b/sbin/fsck_ext2fs/pass1b.c index e650e2f4920..1e30f194188 100644 --- a/sbin/fsck_ext2fs/pass1b.c +++ b/sbin/fsck_ext2fs/pass1b.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pass1b.c,v 1.8 2011/03/12 17:50:47 deraadt Exp $ */ +/* $OpenBSD: pass1b.c,v 1.9 2015/01/16 06:39:57 deraadt Exp $ */ /* $NetBSD: pass1b.c,v 1.2 1997/09/14 14:27:26 lukem Exp $ */ /* @@ -31,7 +31,6 @@ * SUCH DAMAGE. */ -#include <sys/param.h> #include <sys/time.h> #include <ufs/ext2fs/ext2fs_dinode.h> #include <ufs/ext2fs/ext2fs.h> diff --git a/sbin/fsck_ext2fs/pass2.c b/sbin/fsck_ext2fs/pass2.c index 81d06949b37..b568d0888e5 100644 --- a/sbin/fsck_ext2fs/pass2.c +++ b/sbin/fsck_ext2fs/pass2.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pass2.c,v 1.13 2014/07/13 16:08:53 pelikan Exp $ */ +/* $OpenBSD: pass2.c,v 1.14 2015/01/16 06:39:57 deraadt Exp $ */ /* $NetBSD: pass2.c,v 1.6 2000/01/28 16:01:46 bouyer Exp $ */ /* @@ -31,7 +31,7 @@ * SUCH DAMAGE. */ -#include <sys/param.h> +#include <sys/param.h> /* roundup */ #include <sys/time.h> #include <ufs/ext2fs/ext2fs_dinode.h> #include <ufs/ext2fs/ext2fs_dir.h> @@ -42,6 +42,7 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> +#include <limits.h> #include "fsck.h" #include "fsutil.h" @@ -60,7 +61,7 @@ pass2(void) struct inoinfo **inpend; struct inodesc curino; struct ext2fs_dinode dino; - char pathbuf[MAXPATHLEN + 1]; + char pathbuf[PATH_MAX + 1]; switch (statemap[EXT2_ROOTINO]) { @@ -196,8 +197,8 @@ pass2check(struct inodesc *idesc) struct ext2fs_dinode *dp; char *errmsg; struct ext2fs_direct proto; - char namebuf[MAXPATHLEN + 1]; - char pathbuf[MAXPATHLEN + 1]; + char namebuf[PATH_MAX + 1]; + char pathbuf[PATH_MAX + 1]; /* * check for "." diff --git a/sbin/fsck_ext2fs/pass3.c b/sbin/fsck_ext2fs/pass3.c index 5de22eb2c4f..1f857e36096 100644 --- a/sbin/fsck_ext2fs/pass3.c +++ b/sbin/fsck_ext2fs/pass3.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pass3.c,v 1.6 2003/06/11 06:22:13 deraadt Exp $ */ +/* $OpenBSD: pass3.c,v 1.7 2015/01/16 06:39:57 deraadt Exp $ */ /* $NetBSD: pass3.c,v 1.2 1997/09/14 14:27:28 lukem Exp $ */ /* @@ -31,7 +31,6 @@ * SUCH DAMAGE. */ -#include <sys/param.h> #include <sys/time.h> #include <ufs/ext2fs/ext2fs_dinode.h> #include <ufs/ext2fs/ext2fs.h> diff --git a/sbin/fsck_ext2fs/pass4.c b/sbin/fsck_ext2fs/pass4.c index f85ef044a23..6956a7d257d 100644 --- a/sbin/fsck_ext2fs/pass4.c +++ b/sbin/fsck_ext2fs/pass4.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pass4.c,v 1.9 2013/04/24 13:46:27 deraadt Exp $ */ +/* $OpenBSD: pass4.c,v 1.10 2015/01/16 06:39:57 deraadt Exp $ */ /* $NetBSD: pass4.c,v 1.2 1997/09/14 14:27:29 lukem Exp $ */ /* @@ -31,7 +31,7 @@ * SUCH DAMAGE. */ -#include <sys/param.h> +#include <sys/param.h> /* isset clrbit */ #include <sys/time.h> #include <ufs/ext2fs/ext2fs_dinode.h> #include <ufs/ext2fs/ext2fs.h> diff --git a/sbin/fsck_ext2fs/pass5.c b/sbin/fsck_ext2fs/pass5.c index 151bda78aa3..2ea1327cf81 100644 --- a/sbin/fsck_ext2fs/pass5.c +++ b/sbin/fsck_ext2fs/pass5.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pass5.c,v 1.17 2014/07/13 16:08:53 pelikan Exp $ */ +/* $OpenBSD: pass5.c,v 1.18 2015/01/16 06:39:57 deraadt Exp $ */ /* $NetBSD: pass5.c,v 1.7 2000/01/28 16:01:46 bouyer Exp $ */ /* @@ -31,7 +31,7 @@ * SUCH DAMAGE. */ -#include <sys/param.h> +#include <sys/param.h> /* setbit isset */ #include <sys/time.h> #include <ufs/ufs/dinode.h> #include <ufs/ext2fs/ext2fs_dinode.h> diff --git a/sbin/fsck_ext2fs/setup.c b/sbin/fsck_ext2fs/setup.c index b4c2f9d9204..7f2404f5f28 100644 --- a/sbin/fsck_ext2fs/setup.c +++ b/sbin/fsck_ext2fs/setup.c @@ -1,4 +1,4 @@ -/* $OpenBSD: setup.c,v 1.24 2014/11/20 15:22:39 tedu Exp $ */ +/* $OpenBSD: setup.c,v 1.25 2015/01/16 06:39:57 deraadt Exp $ */ /* $NetBSD: setup.c,v 1.1 1997/06/11 11:22:01 bouyer Exp $ */ /* @@ -32,7 +32,7 @@ */ #define DKTYPENAMES -#include <sys/param.h> +#include <sys/param.h> /* DEV_BSIZE roundup */ #include <sys/time.h> #include <ufs/ext2fs/ext2fs_dinode.h> #include <ufs/ext2fs/ext2fs.h> diff --git a/sbin/fsck_ext2fs/utilities.c b/sbin/fsck_ext2fs/utilities.c index 7601ec6ea76..3eb2daa4753 100644 --- a/sbin/fsck_ext2fs/utilities.c +++ b/sbin/fsck_ext2fs/utilities.c @@ -1,4 +1,4 @@ -/* $OpenBSD: utilities.c,v 1.23 2014/07/13 16:08:53 pelikan Exp $ */ +/* $OpenBSD: utilities.c,v 1.24 2015/01/16 06:39:57 deraadt Exp $ */ /* $NetBSD: utilities.c,v 1.6 2001/02/04 21:19:34 christos Exp $ */ /* @@ -31,8 +31,9 @@ * SUCH DAMAGE. */ -#include <sys/param.h> +#include <sys/param.h> /* DEV_BSIZE isset setbit */ #include <sys/time.h> +#include <sys/signal.h> #include <ufs/ext2fs/ext2fs_dinode.h> #include <ufs/ext2fs/ext2fs_dir.h> #include <ufs/ext2fs/ext2fs.h> diff --git a/sbin/fsck_ffs/dir.c b/sbin/fsck_ffs/dir.c index d0c4fe4f903..afbbd3a128f 100644 --- a/sbin/fsck_ffs/dir.c +++ b/sbin/fsck_ffs/dir.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dir.c,v 1.30 2014/09/06 04:05:40 guenther Exp $ */ +/* $OpenBSD: dir.c,v 1.31 2015/01/16 06:39:57 deraadt Exp $ */ /* $NetBSD: dir.c,v 1.20 1996/09/27 22:45:11 christos Exp $ */ /* @@ -30,7 +30,7 @@ * SUCH DAMAGE. */ -#include <sys/param.h> +#include <sys/param.h> /* MAXFRAG DEV_BSIZE roundup btodb */ #include <sys/time.h> #include <ufs/ufs/dinode.h> #include <ufs/ufs/dir.h> @@ -39,6 +39,7 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> +#include <limits.h> #include "fsck.h" #include "fsutil.h" @@ -234,7 +235,7 @@ void fileerror(ino_t cwd, ino_t ino, char *errmesg) { union dinode *dp; - char pathbuf[MAXPATHLEN + 1]; + char pathbuf[PATH_MAX + 1]; pwarn("%s ", errmesg); pinode(ino); @@ -463,7 +464,7 @@ makeentry(ino_t parent, ino_t ino, char *name) { union dinode *dp; struct inodesc idesc; - char pathbuf[MAXPATHLEN + 1]; + char pathbuf[PATH_MAX + 1]; if (parent < ROOTINO || parent >= maxino || ino < ROOTINO || ino >= maxino) diff --git a/sbin/fsck_ffs/inode.c b/sbin/fsck_ffs/inode.c index c38c05a2d40..13a8be66561 100644 --- a/sbin/fsck_ffs/inode.c +++ b/sbin/fsck_ffs/inode.c @@ -1,4 +1,4 @@ -/* $OpenBSD: inode.c,v 1.44 2014/10/08 16:28:38 deraadt Exp $ */ +/* $OpenBSD: inode.c,v 1.45 2015/01/16 06:39:57 deraadt Exp $ */ /* $NetBSD: inode.c,v 1.23 1996/10/11 20:15:47 thorpej Exp $ */ /* @@ -30,7 +30,7 @@ * SUCH DAMAGE. */ -#include <sys/param.h> +#include <sys/param.h> /* MAXFRAG setbit btodb */ #include <sys/time.h> #include <ufs/ufs/dinode.h> #include <ufs/ufs/dir.h> @@ -42,11 +42,15 @@ #include <stdlib.h> #include <string.h> #include <unistd.h> +#include <limits.h> #include "fsck.h" #include "fsutil.h" #include "extern.h" +#define MINIMUM(a, b) (((a) < (b)) ? (a) : (b)) +#define MAXIMUM(a, b) (((a) > (b)) ? (a) : (b)) + static ino_t startinum; static int iblock(struct inodesc *, long, off_t); @@ -59,7 +63,7 @@ ckinode(union dinode *dp, struct inodesc *idesc) off_t sizepb, remsize; mode_t mode; int i; - char pathbuf[MAXPATHLEN + 1]; + char pathbuf[PATH_MAX + 1]; if (idesc->id_fix != IGNORE) idesc->id_fix = DONTKNOW; @@ -151,7 +155,7 @@ iblock(struct inodesc *idesc, long ilevel, off_t isize) int i, n, (*func)(struct inodesc *), nif; off_t sizepb; char buf[BUFSIZ]; - char pathbuf[MAXPATHLEN + 1]; + char pathbuf[PATH_MAX + 1]; union dinode *dp; if (idesc->id_type == ADDR) { @@ -598,8 +602,8 @@ allocino(ino_t request, int type) /* If necessary, extend the inoinfo array. grow exponentially */ if ((ino % sblock.fs_ipg) >= (uint64_t)inostathead[cg].il_numalloced) { unsigned long newalloced, i; - newalloced = MIN(sblock.fs_ipg, - MAX(2 * inostathead[cg].il_numalloced, 10)); + newalloced = MINIMUM(sblock.fs_ipg, + MAXIMUM(2 * inostathead[cg].il_numalloced, 10)); info = calloc(newalloced, sizeof(struct inostat)); if (info == NULL) { pwarn("cannot alloc %zu bytes to extend inoinfo\n", diff --git a/sbin/fsck_ffs/main.c b/sbin/fsck_ffs/main.c index 1fec03cff23..9aa65d429b5 100644 --- a/sbin/fsck_ffs/main.c +++ b/sbin/fsck_ffs/main.c @@ -1,4 +1,4 @@ -/* $OpenBSD: main.c,v 1.41 2013/11/01 17:36:18 krw Exp $ */ +/* $OpenBSD: main.c,v 1.42 2015/01/16 06:39:57 deraadt Exp $ */ /* $NetBSD: main.c,v 1.22 1996/10/11 20:15:48 thorpej Exp $ */ /* @@ -30,8 +30,9 @@ * SUCH DAMAGE. */ -#include <sys/param.h> +#include <sys/param.h> /* MAXFRAG */ #include <sys/time.h> +#include <sys/signal.h> #include <sys/mount.h> #include <ufs/ufs/dinode.h> #include <ufs/ffs/fs.h> diff --git a/sbin/fsck_ffs/pass1.c b/sbin/fsck_ffs/pass1.c index 1b73643e6e0..e8d5c3e5a86 100644 --- a/sbin/fsck_ffs/pass1.c +++ b/sbin/fsck_ffs/pass1.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pass1.c,v 1.40 2014/10/14 15:01:51 deraadt Exp $ */ +/* $OpenBSD: pass1.c,v 1.41 2015/01/16 06:39:57 deraadt Exp $ */ /* $NetBSD: pass1.c,v 1.16 1996/09/27 22:45:15 christos Exp $ */ /* @@ -30,7 +30,7 @@ * SUCH DAMAGE. */ -#include <sys/param.h> +#include <sys/param.h> /* MAXFRAG MIN setbit btodb isset */ #include <sys/time.h> #include <ufs/ufs/dinode.h> #include <ufs/ufs/dir.h> @@ -40,6 +40,7 @@ #include <stdlib.h> #include <string.h> #include <unistd.h> +#include <limits.h> #include "fsck.h" #include "extern.h" diff --git a/sbin/fsck_ffs/pass1b.c b/sbin/fsck_ffs/pass1b.c index 6d33c402ea3..442695d3f20 100644 --- a/sbin/fsck_ffs/pass1b.c +++ b/sbin/fsck_ffs/pass1b.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pass1b.c,v 1.19 2013/06/11 16:42:04 deraadt Exp $ */ +/* $OpenBSD: pass1b.c,v 1.20 2015/01/16 06:39:57 deraadt Exp $ */ /* $NetBSD: pass1b.c,v 1.10 1996/09/23 16:18:37 christos Exp $ */ /* @@ -30,7 +30,7 @@ * SUCH DAMAGE. */ -#include <sys/param.h> +#include <sys/param.h> /* MAXFRAG */ #include <sys/time.h> #include <ufs/ufs/dinode.h> #include <ufs/ffs/fs.h> diff --git a/sbin/fsck_ffs/pass2.c b/sbin/fsck_ffs/pass2.c index dc86f6bc37f..02d150cd8b8 100644 --- a/sbin/fsck_ffs/pass2.c +++ b/sbin/fsck_ffs/pass2.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pass2.c,v 1.35 2014/09/06 04:05:40 guenther Exp $ */ +/* $OpenBSD: pass2.c,v 1.36 2015/01/16 06:39:57 deraadt Exp $ */ /* $NetBSD: pass2.c,v 1.17 1996/09/27 22:45:15 christos Exp $ */ /* @@ -30,7 +30,7 @@ * SUCH DAMAGE. */ -#include <sys/param.h> +#include <sys/param.h> /* MAXFRAG DEV_BSIZE roundup */ #include <sys/time.h> #include <ufs/ufs/dinode.h> #include <ufs/ufs/dir.h> @@ -39,6 +39,7 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> +#include <limits.h> #include "fsck.h" #include "fsutil.h" @@ -76,7 +77,7 @@ pass2(void) struct inoinfo **inpend; struct inodesc curino; union dinode dino; - char pathbuf[MAXPATHLEN + 1]; + char pathbuf[PATH_MAX + 1]; int i; switch (GET_ISTATE(ROOTINO)) { @@ -254,8 +255,8 @@ pass2check(struct inodesc *idesc) union dinode *dp; char *errmsg; struct direct proto; - char namebuf[MAXPATHLEN + 1]; - char pathbuf[MAXPATHLEN + 1]; + char namebuf[PATH_MAX + 1]; + char pathbuf[PATH_MAX + 1]; /* * check for "." diff --git a/sbin/fsck_ffs/pass3.c b/sbin/fsck_ffs/pass3.c index 7b9f4d97e99..ba04d7d0568 100644 --- a/sbin/fsck_ffs/pass3.c +++ b/sbin/fsck_ffs/pass3.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pass3.c,v 1.16 2011/05/08 14:38:40 otto Exp $ */ +/* $OpenBSD: pass3.c,v 1.17 2015/01/16 06:39:57 deraadt Exp $ */ /* $NetBSD: pass3.c,v 1.8 1995/03/18 14:55:54 cgd Exp $ */ /* @@ -30,7 +30,7 @@ * SUCH DAMAGE. */ -#include <sys/param.h> +#include <sys/param.h> /* MAXFRAG */ #include <sys/time.h> #include <ufs/ufs/dinode.h> #include <ufs/ffs/fs.h> diff --git a/sbin/fsck_ffs/pass4.c b/sbin/fsck_ffs/pass4.c index 4dcc44dad50..91645762537 100644 --- a/sbin/fsck_ffs/pass4.c +++ b/sbin/fsck_ffs/pass4.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pass4.c,v 1.22 2013/06/11 16:42:04 deraadt Exp $ */ +/* $OpenBSD: pass4.c,v 1.23 2015/01/16 06:39:57 deraadt Exp $ */ /* $NetBSD: pass4.c,v 1.11 1996/09/27 22:45:17 christos Exp $ */ /* @@ -30,7 +30,7 @@ * SUCH DAMAGE. */ -#include <sys/param.h> +#include <sys/param.h> /* MAXFRAG isset clrbit */ #include <sys/time.h> #include <ufs/ufs/dinode.h> #include <ufs/ffs/fs.h> diff --git a/sbin/fsck_ffs/pass5.c b/sbin/fsck_ffs/pass5.c index 052753651f2..edb08644eba 100644 --- a/sbin/fsck_ffs/pass5.c +++ b/sbin/fsck_ffs/pass5.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pass5.c,v 1.46 2014/09/06 04:05:40 guenther Exp $ */ +/* $OpenBSD: pass5.c,v 1.47 2015/01/16 06:39:57 deraadt Exp $ */ /* $NetBSD: pass5.c,v 1.16 1996/09/27 22:45:18 christos Exp $ */ /* @@ -30,7 +30,7 @@ * SUCH DAMAGE. */ -#include <sys/param.h> +#include <sys/param.h> /* MAXFRAG MAXBSIZE roundup setbit */ #include <sys/time.h> #include <sys/lock.h> #include <sys/ucred.h> @@ -40,11 +40,14 @@ #include <ufs/ffs/ffs_extern.h> #include <stdio.h> #include <string.h> +#include <limits.h> #include "fsutil.h" #include "fsck.h" #include "extern.h" +#define MINIMUM(a, b) (((a) < (b)) ? (a) : (b)) + static int info_cg; static int info_maxcg; @@ -95,7 +98,7 @@ pass5(void) if (doit) { i = fs->fs_contigsumsize; fs->fs_contigsumsize = - MIN(fs->fs_maxcontig, FS_MAXCONTIG); + MINIMUM(fs->fs_maxcontig, FS_MAXCONTIG); if (CGSIZE(fs) > fs->fs_bsize) { pwarn("CANNOT %s CLUSTER MAPS\n", doit); fs->fs_contigsumsize = i; diff --git a/sbin/fsck_ffs/setup.c b/sbin/fsck_ffs/setup.c index 68290caaa5c..91bfb782368 100644 --- a/sbin/fsck_ffs/setup.c +++ b/sbin/fsck_ffs/setup.c @@ -1,4 +1,4 @@ -/* $OpenBSD: setup.c,v 1.55 2014/09/06 04:05:40 guenther Exp $ */ +/* $OpenBSD: setup.c,v 1.56 2015/01/16 06:39:57 deraadt Exp $ */ /* $NetBSD: setup.c,v 1.27 1996/09/27 22:45:19 christos Exp $ */ /* @@ -30,8 +30,8 @@ * SUCH DAMAGE. */ +#include <sys/param.h> /* MAXFRAG MAXBSIZE DEV_BSIZE roundup */ #define DKTYPENAMES -#include <sys/param.h> #include <sys/time.h> #include <ufs/ufs/dinode.h> #include <ufs/ffs/fs.h> @@ -47,12 +47,15 @@ #include <string.h> #include <util.h> #include <unistd.h> +#include <limits.h> #include <ctype.h> #include "fsck.h" #include "extern.h" #include "fsutil.h" +#define MAXIMUM(a, b) (((a) > (b)) ? (a) : (b)) + #define altsblock (*asblk.b_un.b_fs) #define POWEROF2(num) (((num) & ((num) - 1)) == 0) @@ -61,7 +64,7 @@ int calcsb(char *, int, struct fs *); static struct disklabel *getdisklabel(char *, int); static int readsb(int); static int cmpsb(struct fs *, struct fs *); -static char rdevname[MAXPATHLEN]; +static char rdevname[PATH_MAX]; long numdirs, listmax, inplast; @@ -395,7 +398,7 @@ found: (unsigned)sblock.fs_ncg * sizeof(struct inostatlist)); goto badsblabel; } - numdirs = MAX(sblock.fs_cstotal.cs_ndir, 128); + numdirs = MAXIMUM(sblock.fs_cstotal.cs_ndir, 128); inplast = 0; listmax = numdirs + 10; inpsort = calloc((unsigned)listmax, sizeof(struct inoinfo *)); diff --git a/sbin/fsck_ffs/utilities.c b/sbin/fsck_ffs/utilities.c index 1a83fdc9893..913f5aea581 100644 --- a/sbin/fsck_ffs/utilities.c +++ b/sbin/fsck_ffs/utilities.c @@ -1,4 +1,4 @@ -/* $OpenBSD: utilities.c,v 1.47 2014/09/06 04:05:40 guenther Exp $ */ +/* $OpenBSD: utilities.c,v 1.48 2015/01/16 06:39:57 deraadt Exp $ */ /* $NetBSD: utilities.c,v 1.18 1996/09/27 22:45:20 christos Exp $ */ /* @@ -30,9 +30,8 @@ * SUCH DAMAGE. */ -#include <sys/param.h> +#include <sys/param.h> /* MAXFRAG DEV_BSIZE isset setbit clrbit */ #include <sys/time.h> -#include <sys/types.h> #include <sys/uio.h> #include <ufs/ufs/dinode.h> #include <ufs/ufs/dir.h> @@ -43,6 +42,7 @@ #include <string.h> #include <ctype.h> #include <unistd.h> +#include <limits.h> #include <errno.h> #include <fcntl.h> #include <paths.h> @@ -473,7 +473,7 @@ getpathname(char *namebuf, size_t namebuflen, ino_t curdir, ino_t ino) memset(&idesc, 0, sizeof(struct inodesc)); idesc.id_type = DATA; idesc.id_fix = IGNORE; - cp = &namebuf[MAXPATHLEN - 1]; + cp = &namebuf[PATH_MAX - 1]; *cp = '\0'; if (curdir != ino) { idesc.id_parent = curdir; @@ -503,7 +503,7 @@ getpathname(char *namebuf, size_t namebuflen, ino_t curdir, ino_t ino) busy = 0; if (ino != ROOTINO) *--cp = '?'; - memcpy(namebuf, cp, (size_t)(&namebuf[MAXPATHLEN] - cp)); + memcpy(namebuf, cp, (size_t)(&namebuf[PATH_MAX] - cp)); } /*ARGSUSED*/ diff --git a/sbin/fsck_msdos/boot.c b/sbin/fsck_msdos/boot.c index 7c654867734..16b84805b41 100644 --- a/sbin/fsck_msdos/boot.c +++ b/sbin/fsck_msdos/boot.c @@ -1,4 +1,4 @@ -/* $OpenBSD: boot.c,v 1.22 2014/07/10 17:12:05 tobias Exp $ */ +/* $OpenBSD: boot.c,v 1.23 2015/01/16 06:39:58 deraadt Exp $ */ /* $NetBSD: boot.c,v 1.5 1997/10/17 11:19:23 ws Exp $ */ /* @@ -26,7 +26,7 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include <sys/param.h> +#include <sys/param.h> /* DEV_BSIZE powerof2 */ #include <sys/disklabel.h> #include <stdlib.h> diff --git a/sbin/fsck_msdos/check.c b/sbin/fsck_msdos/check.c index 29aa9d66250..952e0901f1a 100644 --- a/sbin/fsck_msdos/check.c +++ b/sbin/fsck_msdos/check.c @@ -1,4 +1,4 @@ -/* $OpenBSD: check.c,v 1.16 2014/06/16 18:33:33 tobias Exp $ */ +/* $OpenBSD: check.c,v 1.17 2015/01/16 06:39:58 deraadt Exp $ */ /* $NetBSD: check.c,v 1.8 1997/10/17 11:19:29 ws Exp $ */ /* @@ -26,7 +26,7 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include <sys/param.h> +#include <sys/types.h> #include <sys/ioctl.h> #include <sys/dkio.h> #include <sys/disklabel.h> @@ -35,6 +35,7 @@ #include <ctype.h> #include <stdio.h> #include <unistd.h> +#include <limits.h> #include <fcntl.h> #include <util.h> diff --git a/sbin/fsck_msdos/dir.c b/sbin/fsck_msdos/dir.c index d756ccac994..39c6ff35ce1 100644 --- a/sbin/fsck_msdos/dir.c +++ b/sbin/fsck_msdos/dir.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dir.c,v 1.27 2014/11/18 20:51:00 krw Exp $ */ +/* $OpenBSD: dir.c,v 1.28 2015/01/16 06:39:58 deraadt Exp $ */ /* $NetBSD: dir.c,v 1.11 1997/10/17 11:19:35 ws Exp $ */ /* @@ -33,10 +33,9 @@ #include <string.h> #include <ctype.h> #include <unistd.h> +#include <limits.h> #include <time.h> -#include <sys/param.h> - #include "ext.h" #define SLOT_EMPTY 0x00 /* slot has never been used */ @@ -154,7 +153,7 @@ static struct dirTodoNode *pendingDirectories = NULL; static char * fullpath(struct dosDirEntry *dir) { - static char namebuf[MAXPATHLEN + 1]; + static char namebuf[PATH_MAX + 1]; char *cp, *np; int nl; diff --git a/sbin/fsdb/fsdb.c b/sbin/fsdb/fsdb.c index e65286dbed6..d3063bafc61 100644 --- a/sbin/fsdb/fsdb.c +++ b/sbin/fsdb/fsdb.c @@ -1,4 +1,4 @@ -/* $OpenBSD: fsdb.c,v 1.27 2013/04/25 06:43:20 otto Exp $ */ +/* $OpenBSD: fsdb.c,v 1.28 2015/01/16 06:39:58 deraadt Exp $ */ /* $NetBSD: fsdb.c,v 1.7 1997/01/11 06:50:53 lukem Exp $ */ /*- @@ -30,9 +30,8 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include <sys/types.h> +#include <sys/param.h> /* MAXFRAG */ #include <sys/stat.h> -#include <sys/param.h> #include <sys/time.h> #include <sys/mount.h> #include <ctype.h> diff --git a/sbin/fsdb/fsdbutil.c b/sbin/fsdb/fsdbutil.c index 886af3760e1..1efdf03bd2e 100644 --- a/sbin/fsdb/fsdbutil.c +++ b/sbin/fsdb/fsdbutil.c @@ -1,4 +1,4 @@ -/* $OpenBSD: fsdbutil.c,v 1.15 2013/04/24 13:46:29 deraadt Exp $ */ +/* $OpenBSD: fsdbutil.c,v 1.16 2015/01/16 06:39:58 deraadt Exp $ */ /* $NetBSD: fsdbutil.c,v 1.5 1996/09/28 19:30:37 christos Exp $ */ /*- @@ -30,9 +30,8 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include <sys/types.h> +#include <sys/param.h> /* MAXFRAG */ #include <sys/stat.h> -#include <sys/param.h> #include <sys/time.h> #include <sys/mount.h> #include <ctype.h> diff --git a/sbin/fsirand/fsirand.c b/sbin/fsirand/fsirand.c index 35bd18717a8..66355f1ff16 100644 --- a/sbin/fsirand/fsirand.c +++ b/sbin/fsirand/fsirand.c @@ -1,4 +1,4 @@ -/* $OpenBSD: fsirand.c,v 1.30 2014/10/11 03:48:49 deraadt Exp $ */ +/* $OpenBSD: fsirand.c,v 1.31 2015/01/16 06:39:58 deraadt Exp $ */ /* * Copyright (c) 1997 Todd C. Miller <Todd.Miller@courtesan.com> @@ -16,11 +16,10 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#include <sys/types.h> +#include <sys/param.h> /* MAXFRAG DEV_BSIZE */ #include <sys/disklabel.h> #include <sys/ioctl.h> #include <sys/dkio.h> -#include <sys/param.h> #include <sys/resource.h> #include <sys/time.h> diff --git a/sbin/growfs/debug.c b/sbin/growfs/debug.c index 03181fbfb97..7b999528eae 100644 --- a/sbin/growfs/debug.c +++ b/sbin/growfs/debug.c @@ -1,4 +1,4 @@ -/* $OpenBSD: debug.c,v 1.10 2014/05/24 17:56:17 krw Exp $ */ +/* $OpenBSD: debug.c,v 1.11 2015/01/16 06:39:58 deraadt Exp $ */ /* * Copyright (c) 2000 Christoph Herrmann, Thomas-Henning von Kamptz * Copyright (c) 1980, 1989, 1993 The Regents of the University of California. @@ -42,7 +42,6 @@ */ /* ********************************************************** INCLUDES ***** */ -#include <sys/param.h> #include <limits.h> #include <stdio.h> @@ -51,6 +50,9 @@ #include <ufs/ufs/dinode.h> #include <ufs/ffs/fs.h> +#define MINIMUM(a, b) (((a) < (b)) ? (a) : (b)) +#define MAXIMUM(a, b) (((a) > (b)) ? (a) : (b)) + #include "debug.h" #ifdef FS_DEBUG @@ -721,7 +723,7 @@ dbg_dump_ino(struct fs *sb, const char *comment, struct ufs1_dinode *ino) ino->di_ctimensec); remaining_blocks = howmany(ino->di_size, sb->fs_bsize); /* XXX ts - +1? */ - for (ictr = 0; ictr < MIN(NDADDR, remaining_blocks); ictr++) { + for (ictr = 0; ictr < MINIMUM(NDADDR, remaining_blocks); ictr++) { fprintf(dbg_log, "db int32_t[%x] 0x%08x\n", ictr, ino->di_db[ictr]); } @@ -799,7 +801,7 @@ dbg_dump_ufs2_ino(struct fs *sb, const char *comment, struct ufs2_dinode *ino) /* XXX: What do we do with di_extb[NXADDR]? */ remaining_blocks = howmany(ino->di_size, sb->fs_bsize); /* XXX ts - +1? */ - for (ictr = 0; ictr < MIN(NDADDR, remaining_blocks); ictr++) { + for (ictr = 0; ictr < MINIMUM(NDADDR, remaining_blocks); ictr++) { fprintf(dbg_log, "db daddr_t[%x] 0x%16jx\n", ictr, ino->di_db[ictr]); } @@ -851,7 +853,7 @@ dbg_dump_iblk(struct fs *sb, const char *comment, char *block, size_t length) size = sizeof(int64_t); mem = (unsigned int *)block; - for (i = 0; (size_t)i < MIN(howmany(sb->fs_bsize, size), length); i += 8) { + for (i = 0; (size_t)i < MINIMUM(howmany(sb->fs_bsize, size), length); i += 8) { fprintf(dbg_log, "%04x: ", i); for (j = 0; j < 8; j++) { if ((size_t)(i + j) < length) { diff --git a/sbin/growfs/growfs.c b/sbin/growfs/growfs.c index 8b7f9e5946f..c0b41bfb325 100644 --- a/sbin/growfs/growfs.c +++ b/sbin/growfs/growfs.c @@ -1,4 +1,4 @@ -/* $OpenBSD: growfs.c,v 1.36 2014/05/15 19:18:23 chl Exp $ */ +/* $OpenBSD: growfs.c,v 1.37 2015/01/16 06:39:58 deraadt Exp $ */ /* * Copyright (c) 2000 Christoph Herrmann, Thomas-Henning von Kamptz * Copyright (c) 1980, 1989, 1993 The Regents of the University of California. @@ -42,7 +42,8 @@ */ /* ********************************************************** INCLUDES ***** */ -#include <sys/param.h> +#include <sys/param.h> /* DEV_BSIZE MAXFRAG MAXBSIZE setbit isset isclr clrbit */ +#include <sys/types.h> #include <sys/disklabel.h> #include <sys/ioctl.h> #include <sys/dkio.h> @@ -64,6 +65,9 @@ #include <ufs/ufs/dinode.h> #include <ufs/ffs/fs.h> +#define MINIMUM(a, b) (((a) < (b)) ? (a) : (b)) +#define MAXIMUM(a, b) (((a) > (b)) ? (a) : (b)) + #include "debug.h" #define rounddown(x, y) (((x)/(y))*(y)) @@ -190,7 +194,7 @@ growfs(int fsi, int fso, unsigned int Nflag) errx(1, "calloc failed"); for (i = 0; i < osblock.fs_cssize; i += osblock.fs_bsize) { rdfs(fsbtodb(&osblock, osblock.fs_csaddr + - numfrags(&osblock, i)), (size_t)MIN(osblock.fs_cssize - i, + numfrags(&osblock, i)), (size_t)MINIMUM(osblock.fs_cssize - i, osblock.fs_bsize), (void *)(((char *)fscs)+i), fsi); } @@ -273,7 +277,7 @@ growfs(int fsi, int fso, unsigned int Nflag) */ for (i = 0; i < sblock.fs_cssize; i += sblock.fs_bsize) { wtfs(fsbtodb(&sblock, sblock.fs_csaddr + numfrags(&sblock, i)), - (size_t)MIN(sblock.fs_cssize - i, sblock.fs_bsize), + (size_t)MINIMUM(sblock.fs_cssize - i, sblock.fs_bsize), (void *)(((char *)fscs) + i), fso, Nflag); } DBG_PRINT0("fscs written\n"); @@ -411,7 +415,7 @@ initcg(int cylno, time_t utime, int fso, unsigned int Nflag) acg.cg_magic = CG_MAGIC; acg.cg_cgx = cylno; acg.cg_ffs2_niblk = sblock.fs_ipg; - acg.cg_initediblk = MIN(sblock.fs_ipg, 2 * INOPB(&sblock)); + acg.cg_initediblk = MINIMUM(sblock.fs_ipg, 2 * INOPB(&sblock)); acg.cg_ndblk = dmax - cbase; if (sblock.fs_contigsumsize > 0) acg.cg_nclusterblks = acg.cg_ndblk / sblock.fs_frag; @@ -541,7 +545,7 @@ initcg(int cylno, time_t utime, int fso, unsigned int Nflag) start += sblock.fs_bsize; dp1 = (struct ufs1_dinode *)&iobuf[start]; dp2 = (struct ufs2_dinode *)&iobuf[start]; - for (i = MIN(sblock.fs_ipg, 2 * INOPB(&sblock)); i != 0; i--) { + for (i = MINIMUM(sblock.fs_ipg, 2 * INOPB(&sblock)); i != 0; i--) { if (sblock.fs_magic == FS_UFS1_MAGIC) { dp1->di_gen = arc4random(); dp1++; @@ -1669,7 +1673,7 @@ alloc(void) /* * Now update all counters. */ - cg_clustersum(&acg)[MIN(lcs1 + lcs2 + 1, sblock.fs_contigsumsize)]--; + cg_clustersum(&acg)[MINIMUM(lcs1 + lcs2 + 1, sblock.fs_contigsumsize)]--; if (lcs1) cg_clustersum(&acg)[lcs1]++; if (lcs2) diff --git a/sbin/ifconfig/ifconfig.c b/sbin/ifconfig/ifconfig.c index 755048a83ea..4df0bf33634 100644 --- a/sbin/ifconfig/ifconfig.c +++ b/sbin/ifconfig/ifconfig.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ifconfig.c,v 1.294 2015/01/09 20:34:21 sthen Exp $ */ +/* $OpenBSD: ifconfig.c,v 1.295 2015/01/16 06:39:58 deraadt Exp $ */ /* $NetBSD: ifconfig.c,v 1.40 1997/10/01 02:19:43 enami Exp $ */ /* @@ -101,11 +101,15 @@ #include <stdlib.h> #include <string.h> #include <unistd.h> +#include <limits.h> #include <util.h> #include <ifaddrs.h> #include "brconfig.h" +#define MINIMUM(a, b) (((a) < (b)) ? (a) : (b)) +#define MAXIMUM(a, b) (((a) > (b)) ? (a) : (b)) + #define HWFEATURESBITS \ "\024\1CSUM_IPv4\2CSUM_TCPv4\3CSUM_UDPv4" \ "\5VLAN_MTU\6VLAN_HWTAGGING\10CSUM_TCPv6" \ @@ -968,14 +972,14 @@ printif(char *ifname, int ifaliases) if (ifa->ifa_addr->sa_family == AF_INET6) { memset(&ifr6, 0, sizeof(ifr6)); memcpy(&ifr6.ifr_addr, ifa->ifa_addr, - MIN(sizeof(ifr6.ifr_addr), ifa->ifa_addr->sa_len)); + MINIMUM(sizeof(ifr6.ifr_addr), ifa->ifa_addr->sa_len)); ifrp = (struct ifreq *)&ifr6; } else #endif { memset(&ifr, 0, sizeof(ifr)); memcpy(&ifr.ifr_addr, ifa->ifa_addr, - MIN(sizeof(ifr.ifr_addr), ifa->ifa_addr->sa_len)); + MINIMUM(sizeof(ifr.ifr_addr), ifa->ifa_addr->sa_len)); ifrp = 𝔦 } strlcpy(name, ifa->ifa_name, sizeof(name)); @@ -3261,7 +3265,7 @@ in6_status(int force) void settunnel(const char *src, const char *dst) { - char buf[MAXHOSTNAMELEN+sizeof (":65535")], *dstport; + char buf[HOST_NAME_MAX+1 + sizeof (":65535")], *dstport; const char *dstip; struct addrinfo *srcres, *dstres; int ecode; @@ -4155,7 +4159,7 @@ setpflow_receiver(const char *val, int d) struct pflowreq preq; struct addrinfo hints, *receiver; int ecode; - char *ip, *port, buf[MAXHOSTNAMELEN+sizeof (":65535")]; + char *ip, *port, buf[HOST_NAME_MAX+1 + sizeof (":65535")]; if (strchr (val, ':') == NULL) errx(1, "%s bad value", val); @@ -4721,7 +4725,7 @@ in6_getaddr(const char *s, int which) { struct sockaddr_in6 *sin6 = sin6tab[which]; struct addrinfo hints, *res; - char buf[MAXHOSTNAMELEN+sizeof("/128")], *pfxlen; + char buf[HOST_NAME_MAX+1 + sizeof("/128")], *pfxlen; int error; memset(&hints, 0, sizeof(hints)); diff --git a/sbin/iked/ca.c b/sbin/iked/ca.c index fec5e8ff426..10b8b302b38 100644 --- a/sbin/iked/ca.c +++ b/sbin/iked/ca.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ca.c,v 1.32 2014/12/05 07:24:45 mikeb Exp $ */ +/* $OpenBSD: ca.c,v 1.33 2015/01/16 06:39:58 deraadt Exp $ */ /* * Copyright (c) 2010-2013 Reyk Floeter <reyk@openbsd.org> @@ -16,7 +16,6 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#include <sys/param.h> #include <sys/queue.h> #include <sys/socket.h> #include <sys/wait.h> @@ -1024,7 +1023,7 @@ ca_validate_pubkey(struct iked *env, struct iked_static_id *id, int ret = -1; FILE *fp = NULL; char idstr[IKED_ID_SIZE]; - char file[MAXPATHLEN]; + char file[PATH_MAX]; struct iked_id idp; if (len == 0 && data == NULL) diff --git a/sbin/iked/config.c b/sbin/iked/config.c index a19d21b2d70..a3eb0aeaf0e 100644 --- a/sbin/iked/config.c +++ b/sbin/iked/config.c @@ -1,4 +1,4 @@ -/* $OpenBSD: config.c,v 1.33 2014/12/03 23:18:21 deraadt Exp $ */ +/* $OpenBSD: config.c,v 1.34 2015/01/16 06:39:58 deraadt Exp $ */ /* * Copyright (c) 2010-2013 Reyk Floeter <reyk@openbsd.org> @@ -16,7 +16,6 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#include <sys/param.h> #include <sys/queue.h> #include <sys/wait.h> #include <sys/socket.h> diff --git a/sbin/iked/control.c b/sbin/iked/control.c index 47b8cc12e97..393200819d5 100644 --- a/sbin/iked/control.c +++ b/sbin/iked/control.c @@ -1,4 +1,4 @@ -/* $OpenBSD: control.c,v 1.15 2014/06/03 06:25:47 yasuoka Exp $ */ +/* $OpenBSD: control.c,v 1.16 2015/01/16 06:39:58 deraadt Exp $ */ /* * Copyright (c) 2010-2013 Reyk Floeter <reyk@openbsd.org> @@ -18,7 +18,6 @@ */ #include <sys/queue.h> -#include <sys/param.h> #include <sys/stat.h> #include <sys/socket.h> #include <sys/un.h> diff --git a/sbin/iked/crypto.c b/sbin/iked/crypto.c index fc2019dc46d..3d6f6a29583 100644 --- a/sbin/iked/crypto.c +++ b/sbin/iked/crypto.c @@ -1,4 +1,4 @@ -/* $OpenBSD: crypto.c,v 1.14 2014/07/10 12:50:05 jsg Exp $ */ +/* $OpenBSD: crypto.c,v 1.15 2015/01/16 06:39:58 deraadt Exp $ */ /* * Copyright (c) 2010-2013 Reyk Floeter <reyk@openbsd.org> @@ -16,7 +16,7 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#include <sys/param.h> +#include <sys/param.h> /* roundup */ #include <sys/queue.h> #include <sys/socket.h> #include <sys/uio.h> diff --git a/sbin/iked/dh.c b/sbin/iked/dh.c index 8fe965dfa46..5c5ae383fe5 100644 --- a/sbin/iked/dh.c +++ b/sbin/iked/dh.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dh.c,v 1.15 2014/10/12 15:57:00 jsg Exp $ */ +/* $OpenBSD: dh.c,v 1.16 2015/01/16 06:39:58 deraadt Exp $ */ /* * Copyright (c) 2010-2014 Reyk Floeter <reyk@openbsd.org> @@ -16,7 +16,7 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#include <sys/param.h> +#include <sys/param.h> /* roundup */ #include <string.h> #include <openssl/obj_mac.h> diff --git a/sbin/iked/eap.c b/sbin/iked/eap.c index 371c17046eb..734b09cb9b3 100644 --- a/sbin/iked/eap.c +++ b/sbin/iked/eap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: eap.c,v 1.10 2014/02/17 11:00:14 reyk Exp $ */ +/* $OpenBSD: eap.c,v 1.11 2015/01/16 06:39:58 deraadt Exp $ */ /* * Copyright (c) 2010-2013 Reyk Floeter <reyk@openbsd.org> @@ -16,7 +16,6 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#include <sys/param.h> #include <sys/queue.h> #include <sys/socket.h> #include <sys/wait.h> diff --git a/sbin/iked/genmap.sh b/sbin/iked/genmap.sh index 685f42e1e15..9cd4ba045fd 100644 --- a/sbin/iked/genmap.sh +++ b/sbin/iked/genmap.sh @@ -1,5 +1,5 @@ #!/bin/sh -# $OpenBSD: genmap.sh,v 1.6 2013/01/08 10:38:19 reyk Exp $ +# $OpenBSD: genmap.sh,v 1.7 2015/01/16 06:39:58 deraadt Exp $ # Copyright (c) 2010-2013 Reyk Floeter <reyk@openbsd.org> # @@ -28,7 +28,6 @@ EOF sed -n '1,/^ \*\//p' $1 cat <<EOF -#include <sys/param.h> #include <sys/types.h> #include "types.h" diff --git a/sbin/iked/iked.c b/sbin/iked/iked.c index 22bc0c5aec8..182b756dc02 100644 --- a/sbin/iked/iked.c +++ b/sbin/iked/iked.c @@ -1,4 +1,4 @@ -/* $OpenBSD: iked.c,v 1.22 2014/08/18 09:43:02 reyk Exp $ */ +/* $OpenBSD: iked.c,v 1.23 2015/01/16 06:39:58 deraadt Exp $ */ /* * Copyright (c) 2010-2013 Reyk Floeter <reyk@openbsd.org> @@ -16,7 +16,6 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#include <sys/param.h> #include <sys/queue.h> #include <sys/socket.h> #include <sys/wait.h> @@ -124,8 +123,8 @@ main(int argc, char *argv[]) (IKED_OPT_NONATT|IKED_OPT_NATT)) errx(1, "conflicting NAT-T options"); - if (strlcpy(env->sc_conffile, conffile, MAXPATHLEN) >= MAXPATHLEN) - errx(1, "config file exceeds MAXPATHLEN"); + if (strlcpy(env->sc_conffile, conffile, PATH_MAX) >= PATH_MAX) + errx(1, "config file exceeds PATH_MAX"); ca_sslinit(); policy_init(env); diff --git a/sbin/iked/iked.h b/sbin/iked/iked.h index ad1e9818489..ab0525c6776 100644 --- a/sbin/iked/iked.h +++ b/sbin/iked/iked.h @@ -1,4 +1,4 @@ -/* $OpenBSD: iked.h,v 1.82 2014/08/18 09:43:02 reyk Exp $ */ +/* $OpenBSD: iked.h,v 1.83 2015/01/16 06:39:58 deraadt Exp $ */ /* * Copyright (c) 2010-2013 Reyk Floeter <reyk@openbsd.org> @@ -19,6 +19,7 @@ #include <sys/types.h> #include <sys/tree.h> #include <sys/queue.h> +#include <limits.h> #include <imsg.h> #include "types.h" @@ -499,7 +500,7 @@ struct iked_message { }; struct iked_user { - char usr_name[MAXLOGNAME]; + char usr_name[LOGIN_NAME_MAX]; char usr_pass[IKED_PASSWORD_SIZE]; RB_ENTRY(iked_user) usr_entry; }; @@ -562,7 +563,7 @@ TAILQ_HEAD(iked_ocsp_requests, iked_ocsp_entry); */ struct iked { - char sc_conffile[MAXPATHLEN]; + char sc_conffile[PATH_MAX]; u_int32_t sc_opts; u_int8_t sc_passive; diff --git a/sbin/iked/ikev1.c b/sbin/iked/ikev1.c index 832dceff62a..35b0a2787d1 100644 --- a/sbin/iked/ikev1.c +++ b/sbin/iked/ikev1.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ikev1.c,v 1.15 2014/04/22 12:00:03 reyk Exp $ */ +/* $OpenBSD: ikev1.c,v 1.16 2015/01/16 06:39:58 deraadt Exp $ */ /* * Copyright (c) 2010-2013 Reyk Floeter <reyk@openbsd.org> @@ -22,7 +22,6 @@ * XXX or remove this file and ikev1 from the iked tree. */ -#include <sys/param.h> #include <sys/queue.h> #include <sys/socket.h> #include <sys/wait.h> diff --git a/sbin/iked/ikev2.c b/sbin/iked/ikev2.c index 08b84b25125..7ec18b8427a 100644 --- a/sbin/iked/ikev2.c +++ b/sbin/iked/ikev2.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ikev2.c,v 1.117 2014/12/05 13:40:44 mikeb Exp $ */ +/* $OpenBSD: ikev2.c,v 1.118 2015/01/16 06:39:58 deraadt Exp $ */ /* * Copyright (c) 2010-2013 Reyk Floeter <reyk@openbsd.org> @@ -16,7 +16,7 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#include <sys/param.h> +#include <sys/param.h> /* roundup */ #include <sys/queue.h> #include <sys/socket.h> #include <sys/wait.h> diff --git a/sbin/iked/ikev2_msg.c b/sbin/iked/ikev2_msg.c index 08ed571be82..ec69fef1531 100644 --- a/sbin/iked/ikev2_msg.c +++ b/sbin/iked/ikev2_msg.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ikev2_msg.c,v 1.37 2014/11/07 14:02:32 mikeb Exp $ */ +/* $OpenBSD: ikev2_msg.c,v 1.38 2015/01/16 06:39:58 deraadt Exp $ */ /* * Copyright (c) 2010-2013 Reyk Floeter <reyk@openbsd.org> @@ -16,7 +16,7 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#include <sys/param.h> +#include <sys/param.h> /* roundup */ #include <sys/queue.h> #include <sys/socket.h> #include <sys/wait.h> diff --git a/sbin/iked/ikev2_pld.c b/sbin/iked/ikev2_pld.c index f7e035b30df..98b9fb2e75f 100644 --- a/sbin/iked/ikev2_pld.c +++ b/sbin/iked/ikev2_pld.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ikev2_pld.c,v 1.46 2014/11/07 14:05:58 mikeb Exp $ */ +/* $OpenBSD: ikev2_pld.c,v 1.47 2015/01/16 06:39:58 deraadt Exp $ */ /* * Copyright (c) 2010-2013 Reyk Floeter <reyk@openbsd.org> @@ -17,7 +17,6 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#include <sys/param.h> #include <sys/queue.h> #include <sys/socket.h> #include <sys/wait.h> diff --git a/sbin/iked/log.c b/sbin/iked/log.c index 1ee91648580..61256f3f8ba 100644 --- a/sbin/iked/log.c +++ b/sbin/iked/log.c @@ -1,4 +1,4 @@ -/* $OpenBSD: log.c,v 1.3 2013/01/08 10:38:19 reyk Exp $ */ +/* $OpenBSD: log.c,v 1.4 2015/01/16 06:39:58 deraadt Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org> @@ -16,7 +16,6 @@ * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#include <sys/param.h> #include <sys/queue.h> #include <sys/socket.h> #include <sys/tree.h> diff --git a/sbin/iked/ocsp.c b/sbin/iked/ocsp.c index fb60ba34d86..76827abec96 100644 --- a/sbin/iked/ocsp.c +++ b/sbin/iked/ocsp.c @@ -14,7 +14,7 @@ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#include <sys/param.h> + #include <sys/queue.h> #include <sys/socket.h> #include <sys/uio.h> diff --git a/sbin/iked/parse.y b/sbin/iked/parse.y index a79234191a8..1e331772423 100644 --- a/sbin/iked/parse.y +++ b/sbin/iked/parse.y @@ -1,4 +1,4 @@ -/* $OpenBSD: parse.y,v 1.43 2015/01/12 11:24:58 mikeb Exp $ */ +/* $OpenBSD: parse.y,v 1.44 2015/01/16 06:39:58 deraadt Exp $ */ /* * Copyright (c) 2010-2013 Reyk Floeter <reyk@openbsd.org> @@ -1653,7 +1653,7 @@ get_id_type(char *string) int check_pubkey(char *idstr, int type) { - char keyfile[MAXPATHLEN]; + char keyfile[PATH_MAX]; FILE *fp = NULL; const char *suffix = NULL; diff --git a/sbin/iked/pfkey.c b/sbin/iked/pfkey.c index 2b826957436..cd245eba626 100644 --- a/sbin/iked/pfkey.c +++ b/sbin/iked/pfkey.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pfkey.c,v 1.40 2014/10/29 06:26:39 deraadt Exp $ */ +/* $OpenBSD: pfkey.c,v 1.41 2015/01/16 06:39:58 deraadt Exp $ */ /* * Copyright (c) 2010-2013 Reyk Floeter <reyk@openbsd.org> @@ -19,7 +19,6 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#include <sys/param.h> #include <sys/queue.h> #include <sys/uio.h> #include <sys/socket.h> diff --git a/sbin/iked/policy.c b/sbin/iked/policy.c index b70fd4b2110..99e55dccf6b 100644 --- a/sbin/iked/policy.c +++ b/sbin/iked/policy.c @@ -1,4 +1,4 @@ -/* $OpenBSD: policy.c,v 1.35 2014/11/07 14:12:57 mikeb Exp $ */ +/* $OpenBSD: policy.c,v 1.36 2015/01/16 06:39:58 deraadt Exp $ */ /* * Copyright (c) 2010-2013 Reyk Floeter <reyk@openbsd.org> @@ -17,7 +17,6 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#include <sys/param.h> #include <sys/queue.h> #include <sys/socket.h> #include <sys/uio.h> diff --git a/sbin/iked/proc.c b/sbin/iked/proc.c index c64463efa7f..2e1fdf61249 100644 --- a/sbin/iked/proc.c +++ b/sbin/iked/proc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: proc.c,v 1.21 2014/12/16 03:35:49 millert Exp $ */ +/* $OpenBSD: proc.c,v 1.22 2015/01/16 06:39:58 deraadt Exp $ */ /* * Copyright (c) 2010 - 2014 Reyk Floeter <reyk@openbsd.org> @@ -17,7 +17,6 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#include <sys/param.h> #include <sys/queue.h> #include <sys/socket.h> #include <sys/wait.h> diff --git a/sbin/iked/timer.c b/sbin/iked/timer.c index 0ffa21cb8fd..01341cbb6e0 100644 --- a/sbin/iked/timer.c +++ b/sbin/iked/timer.c @@ -1,4 +1,4 @@ -/* $OpenBSD: timer.c,v 1.11 2014/01/24 05:58:52 mikeb Exp $ */ +/* $OpenBSD: timer.c,v 1.12 2015/01/16 06:39:58 deraadt Exp $ */ /* * Copyright (c) 2010-2013 Reyk Floeter <reyk@openbsd.org> @@ -16,7 +16,6 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#include <sys/param.h> #include <sys/queue.h> #include <sys/socket.h> #include <sys/uio.h> diff --git a/sbin/iked/util.c b/sbin/iked/util.c index 5228c713525..b7044c00cc8 100644 --- a/sbin/iked/util.c +++ b/sbin/iked/util.c @@ -1,4 +1,4 @@ -/* $OpenBSD: util.c,v 1.25 2014/02/21 20:52:38 markus Exp $ */ +/* $OpenBSD: util.c,v 1.26 2015/01/16 06:39:58 deraadt Exp $ */ /* * Copyright (c) 2010-2013 Reyk Floeter <reyk@openbsd.org> @@ -27,6 +27,7 @@ #include <unistd.h> #include <string.h> #include <errno.h> +#include <limits.h> #include <fcntl.h> #include <ctype.h> #include <event.h> diff --git a/sbin/init/init.c b/sbin/init/init.c index 62b9f6ce18a..a9ec322d5eb 100644 --- a/sbin/init/init.c +++ b/sbin/init/init.c @@ -1,4 +1,4 @@ -/* $OpenBSD: init.c,v 1.51 2014/12/06 00:20:22 bluhm Exp $ */ +/* $OpenBSD: init.c,v 1.52 2015/01/16 06:39:58 deraadt Exp $ */ /* $NetBSD: init.c,v 1.22 1996/05/15 23:29:33 jtc Exp $ */ /*- @@ -33,7 +33,7 @@ * SUCH DAMAGE. */ -#include <sys/param.h> +#include <sys/types.h> #include <sys/sysctl.h> #include <sys/wait.h> #include <sys/reboot.h> @@ -488,8 +488,8 @@ single_user(void) pid_t pid, wpid; int status; sigset_t mask; - char shell[MAXPATHLEN]; /* Allocate space here */ - char name[MAXPATHLEN]; /* Name (argv[0]) of shell */ + char shell[PATH_MAX]; /* Allocate space here */ + char name[PATH_MAX]; /* Name (argv[0]) of shell */ char *argv[2]; #ifdef SECURE struct ttyent *typ; diff --git a/sbin/ipsecctl/ike.c b/sbin/ipsecctl/ike.c index 366a078ba6f..f638d987cdd 100644 --- a/sbin/ipsecctl/ike.c +++ b/sbin/ipsecctl/ike.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ike.c,v 1.78 2013/08/25 23:15:20 mikeb Exp $ */ +/* $OpenBSD: ike.c,v 1.79 2015/01/16 06:39:58 deraadt Exp $ */ /* * Copyright (c) 2005 Hans-Joerg Hoexer <hshoexer@openbsd.org> * @@ -29,6 +29,7 @@ #include <stdlib.h> #include <string.h> #include <unistd.h> +#include <limits.h> #include "ipsecctl.h" @@ -93,7 +94,7 @@ ike_section_peer(struct ipsec_rule *r, FILE *fd) static void ike_section_ids(struct ipsec_rule *r, FILE *fd) { - char myname[MAXHOSTNAMELEN]; + char myname[HOST_NAME_MAX+1]; if (r->auth == NULL) return; diff --git a/sbin/ipsecctl/ipsecctl.c b/sbin/ipsecctl/ipsecctl.c index 13d15072d69..ba2a90670c3 100644 --- a/sbin/ipsecctl/ipsecctl.c +++ b/sbin/ipsecctl/ipsecctl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ipsecctl.c,v 1.78 2014/11/20 14:51:42 krw Exp $ */ +/* $OpenBSD: ipsecctl.c,v 1.79 2015/01/16 06:39:58 deraadt Exp $ */ /* * Copyright (c) 2004, 2005 Hans-Joerg Hoexer <hshoexer@openbsd.org> * @@ -15,7 +15,6 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#include <sys/param.h> #include <sys/socket.h> #include <sys/sysctl.h> #include <sys/queue.h> diff --git a/sbin/ipsecctl/pfkdump.c b/sbin/ipsecctl/pfkdump.c index 7531f49d34d..7c7ec2f9906 100644 --- a/sbin/ipsecctl/pfkdump.c +++ b/sbin/ipsecctl/pfkdump.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pfkdump.c,v 1.36 2014/12/28 14:19:31 claudio Exp $ */ +/* $OpenBSD: pfkdump.c,v 1.37 2015/01/16 06:39:58 deraadt Exp $ */ /* * Copyright (c) 2003 Markus Friedl. All rights reserved. @@ -23,7 +23,7 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include <sys/param.h> + #include <sys/socket.h> #include <sys/time.h> #include <sys/sysctl.h> diff --git a/sbin/isakmpd/cert.h b/sbin/isakmpd/cert.h index d805f4b7a44..a9e3a430b80 100644 --- a/sbin/isakmpd/cert.h +++ b/sbin/isakmpd/cert.h @@ -1,4 +1,4 @@ -/* $OpenBSD: cert.h,v 1.15 2007/08/05 09:43:09 tom Exp $ */ +/* $OpenBSD: cert.h,v 1.16 2015/01/16 06:39:58 deraadt Exp $ */ /* $EOM: cert.h,v 1.8 2000/09/28 12:53:27 niklas Exp $ */ /* @@ -33,7 +33,6 @@ #ifndef _CERT_H_ #define _CERT_H_ -#include <sys/param.h> #include <sys/types.h> #include <sys/queue.h> diff --git a/sbin/isakmpd/dh.c b/sbin/isakmpd/dh.c index d15856b7210..aeb355a6695 100644 --- a/sbin/isakmpd/dh.c +++ b/sbin/isakmpd/dh.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dh.c,v 1.18 2014/10/12 15:57:00 jsg Exp $ */ +/* $OpenBSD: dh.c,v 1.19 2015/01/16 06:39:58 deraadt Exp $ */ /* * Copyright (c) 2010-2014 Reyk Floeter <reyk@openbsd.org> @@ -16,7 +16,7 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#include <sys/param.h> +#include <sys/param.h> /* roundup */ #include <string.h> #include <openssl/obj_mac.h> diff --git a/sbin/isakmpd/dnssec.c b/sbin/isakmpd/dnssec.c index 01d4eba8706..ab7fc32f696 100644 --- a/sbin/isakmpd/dnssec.c +++ b/sbin/isakmpd/dnssec.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dnssec.c,v 1.23 2005/04/08 22:32:09 cloder Exp $ */ +/* $OpenBSD: dnssec.c,v 1.24 2015/01/16 06:39:58 deraadt Exp $ */ /* * Copyright (c) 2001 Håkan Olsson. All rights reserved. @@ -67,7 +67,7 @@ dns_get_key(int type, struct message *msg, int *keylen) struct exchange *exchange = msg->exchange; struct rrsetinfo *rr; struct dns_rdata_key key_rr; - char name[MAXHOSTNAMELEN]; + char name[HOST_NAME_MAX+1]; in_addr_t ip4; u_int8_t algorithm, *id, *umark; size_t id_len; diff --git a/sbin/isakmpd/exchange.h b/sbin/isakmpd/exchange.h index 5a06f4a23f4..35119c9fce8 100644 --- a/sbin/isakmpd/exchange.h +++ b/sbin/isakmpd/exchange.h @@ -1,4 +1,4 @@ -/* $OpenBSD: exchange.h,v 1.33 2007/08/05 09:43:09 tom Exp $ */ +/* $OpenBSD: exchange.h,v 1.34 2015/01/16 06:39:58 deraadt Exp $ */ /* $EOM: exchange.h,v 1.28 2000/09/28 12:54:28 niklas Exp $ */ /* @@ -32,7 +32,6 @@ #ifndef _EXCHANGE_H_ #define _EXCHANGE_H_ -#include <sys/param.h> #include <sys/types.h> #include <sys/queue.h> diff --git a/sbin/isakmpd/ipsec.c b/sbin/isakmpd/ipsec.c index 4222ea8240a..4a415a70819 100644 --- a/sbin/isakmpd/ipsec.c +++ b/sbin/isakmpd/ipsec.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ipsec.c,v 1.142 2015/01/13 04:19:00 deraadt Exp $ */ +/* $OpenBSD: ipsec.c,v 1.143 2015/01/16 06:39:58 deraadt Exp $ */ /* $EOM: ipsec.c,v 1.143 2000/12/11 23:57:42 niklas Exp $ */ /* @@ -75,6 +75,9 @@ extern int acquire_only; +#define MINIMUM(a, b) (((a) < (b)) ? (a) : (b)) +#define MAXIMUM(a, b) (((a) > (b)) ? (a) : (b)) + /* The replay window size used for all IPsec protocols if not overridden. */ #define DEFAULT_REPLAY_WINDOW 16 @@ -2128,7 +2131,7 @@ ipsec_decode_id(char *buf, size_t size, u_int8_t *id, size_t id_len, case IPSEC_ID_USER_FQDN: /* String is not NUL terminated, be careful */ id_len -= ISAKMP_ID_DATA_OFF; - id_len = MIN(id_len, size - 1); + id_len = MINIMUM(id_len, size - 1); memcpy(buf, id + ISAKMP_ID_DATA_OFF, id_len); buf[id_len] = '\0'; break; @@ -2300,7 +2303,7 @@ static int addr_cmp(const void *a, const void *b) { const struct contact *x = a, *y = b; - int minlen = MIN(x->len, y->len); + int minlen = MINIMUM(x->len, y->len); int rv = memcmp(x->addr, y->addr, minlen); return rv ? rv : (x->len - y->len); @@ -2529,7 +2532,7 @@ ipsec_id_string(u_int8_t *id, size_t id_len) * XXX I think the ASN1 DN case can be thought through to give a better * estimate. */ - size = MAX(sizeof "ipv6/ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff", + size = MAXIMUM(sizeof "ipv6/ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff", sizeof "asn1_dn/" + id_len); buf = malloc(size); if (!buf) diff --git a/sbin/isakmpd/message.h b/sbin/isakmpd/message.h index 04cf6bfac3e..c202651e55b 100644 --- a/sbin/isakmpd/message.h +++ b/sbin/isakmpd/message.h @@ -1,4 +1,4 @@ -/* $OpenBSD: message.h,v 1.25 2007/04/15 19:37:46 hshoexer Exp $ */ +/* $OpenBSD: message.h,v 1.26 2015/01/16 06:39:59 deraadt Exp $ */ /* $EOM: message.h,v 1.51 2000/10/10 12:36:39 provos Exp $ */ /* @@ -34,7 +34,6 @@ #ifndef _MESSAGE_H_ #define _MESSAGE_H_ -#include <sys/param.h> #include <sys/queue.h> #include <sys/socket.h> #include <sys/uio.h> diff --git a/sbin/isakmpd/monitor.c b/sbin/isakmpd/monitor.c index 83a372e226e..4d4737f1e4e 100644 --- a/sbin/isakmpd/monitor.c +++ b/sbin/isakmpd/monitor.c @@ -1,4 +1,4 @@ -/* $OpenBSD: monitor.c,v 1.72 2010/05/10 02:00:50 krw Exp $ */ +/* $OpenBSD: monitor.c,v 1.73 2015/01/16 06:39:59 deraadt Exp $ */ /* * Copyright (c) 2003 Håkan Olsson. All rights reserved. @@ -24,7 +24,6 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include <sys/param.h> #include <sys/types.h> #include <sys/socket.h> #include <sys/ioctl.h> @@ -40,6 +39,7 @@ #include <stdlib.h> #include <string.h> #include <unistd.h> +#include <limits.h> #include <regex.h> #include <keynote.h> @@ -55,7 +55,7 @@ struct monitor_state { pid_t pid; int s; - char root[MAXPATHLEN]; + char root[PATH_MAX]; } m_state; extern char *pid_file; @@ -194,7 +194,7 @@ monitor_open(const char *path, int flags, mode_t mode) { size_t len; int fd, err, cmd; - char pathreal[MAXPATHLEN]; + char pathreal[PATH_MAX]; if (path[0] == '/') strlcpy(pathreal, path, sizeof pathreal); @@ -498,7 +498,7 @@ m_priv_pfkey_open(void) static void m_priv_getfd(void) { - char path[MAXPATHLEN]; + char path[PATH_MAX]; size_t len; int v, flags, ret; int err = 0; @@ -804,7 +804,7 @@ static void m_priv_req_readdir() { size_t len; - char path[MAXPATHLEN]; + char path[PATH_MAX]; DIR *dp; struct dirent *file; struct stat sb; diff --git a/sbin/isakmpd/sa.h b/sbin/isakmpd/sa.h index 6331f0eba04..adca02f41d1 100644 --- a/sbin/isakmpd/sa.h +++ b/sbin/isakmpd/sa.h @@ -1,4 +1,4 @@ -/* $OpenBSD: sa.h,v 1.50 2013/11/21 22:25:02 yasuoka Exp $ */ +/* $OpenBSD: sa.h,v 1.51 2015/01/16 06:39:59 deraadt Exp $ */ /* $EOM: sa.h,v 1.58 2000/10/10 12:39:01 provos Exp $ */ /* @@ -34,7 +34,6 @@ #ifndef _SA_H_ #define _SA_H_ -#include <sys/param.h> #include <sys/types.h> #include <sys/queue.h> #include <sys/socket.h> diff --git a/sbin/isakmpd/timer.h b/sbin/isakmpd/timer.h index 2e890a37cec..6ddbcea6bb3 100644 --- a/sbin/isakmpd/timer.h +++ b/sbin/isakmpd/timer.h @@ -1,4 +1,4 @@ -/* $OpenBSD: timer.h,v 1.7 2004/05/23 18:17:56 hshoexer Exp $ */ +/* $OpenBSD: timer.h,v 1.8 2015/01/16 06:39:59 deraadt Exp $ */ /* $EOM: timer.h,v 1.6 1999/04/11 22:35:55 ho Exp $ */ /* @@ -32,7 +32,6 @@ #ifndef _TIMER_H_ #define _TIMER_H_ -#include <sys/param.h> #include <sys/queue.h> #include <sys/time.h> diff --git a/sbin/isakmpd/transport.h b/sbin/isakmpd/transport.h index 4ef75f567c3..8341139e69f 100644 --- a/sbin/isakmpd/transport.h +++ b/sbin/isakmpd/transport.h @@ -1,4 +1,4 @@ -/* $OpenBSD: transport.h,v 1.18 2006/06/02 19:35:55 hshoexer Exp $ */ +/* $OpenBSD: transport.h,v 1.19 2015/01/16 06:39:59 deraadt Exp $ */ /* $EOM: transport.h,v 1.16 2000/07/17 18:57:59 provos Exp $ */ /* @@ -38,7 +38,6 @@ #ifndef _TRANSPORT_H_ #define _TRANSPORT_H_ -#include <sys/param.h> #include <sys/queue.h> #include <sys/types.h> #include <sys/socket.h> diff --git a/sbin/isakmpd/x509.c b/sbin/isakmpd/x509.c index 72202ee779f..96abb36815f 100644 --- a/sbin/isakmpd/x509.c +++ b/sbin/isakmpd/x509.c @@ -1,4 +1,4 @@ -/* $OpenBSD: x509.c,v 1.117 2014/05/01 07:35:57 jsg Exp $ */ +/* $OpenBSD: x509.c,v 1.118 2015/01/16 06:39:59 deraadt Exp $ */ /* $EOM: x509.c,v 1.54 2001/01/16 18:42:16 ho Exp $ */ /* @@ -31,8 +31,6 @@ * This code was written under funding by Ericsson Radio Systems. */ - -#include <sys/param.h> #include <sys/types.h> #include <sys/stat.h> #include <dirent.h> @@ -42,6 +40,7 @@ #include <stdlib.h> #include <string.h> #include <unistd.h> +#include <limits.h> #include <regex.h> #include <keynote.h> diff --git a/sbin/kbd/kbd_wscons.c b/sbin/kbd/kbd_wscons.c index 8247cd1553a..3351273a2b1 100644 --- a/sbin/kbd/kbd_wscons.c +++ b/sbin/kbd/kbd_wscons.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kbd_wscons.c,v 1.27 2014/03/26 05:22:26 miod Exp $ */ +/* $OpenBSD: kbd_wscons.c,v 1.28 2015/01/16 06:39:59 deraadt Exp $ */ /* * Copyright (c) 2001 Mats O Jansson. All rights reserved. @@ -24,7 +24,6 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include <sys/param.h> #include <sys/ioctl.h> #include <sys/time.h> #include <dev/wscons/wsconsio.h> @@ -179,7 +178,7 @@ kbd_list(void) { int kbds[SA_MAX]; int fd, i, kbtype; - char device[MAXPATHLEN]; + char device[PATH_MAX]; kvm_t *kd = NULL; #ifndef NOKVM char errbuf[LINE_MAX]; diff --git a/sbin/lmccontrol/lmccontrol.c b/sbin/lmccontrol/lmccontrol.c index d4c3facb400..c5bc3b04786 100644 --- a/sbin/lmccontrol/lmccontrol.c +++ b/sbin/lmccontrol/lmccontrol.c @@ -1,4 +1,4 @@ -/* $OpenBSD: lmccontrol.c,v 1.10 2013/11/15 22:20:04 millert Exp $ */ +/* $OpenBSD: lmccontrol.c,v 1.11 2015/01/16 06:39:59 deraadt Exp $ */ /*- * Copyright (c) 1997-1999 LAN Media Corporation (LMC) @@ -38,6 +38,12 @@ * POSSIBILITY OF SUCH DAMAGE. */ +#include <sys/types.h> +#include <sys/ioctl.h> +#include <sys/socket.h> + +#include <net/if.h> +#include <netinet/in.h> #include <stdio.h> #include <stdlib.h> @@ -45,14 +51,7 @@ #include <errno.h> #include <string.h> #include <unistd.h> - -#include <sys/param.h> -#include <sys/types.h> -#include <sys/ioctl.h> -#include <sys/socket.h> - -#include <net/if.h> -#include <netinet/in.h> +#include <limits.h> typedef struct lmc___ctl lmc_ctl_t; #include <dev/pci/if_lmcioctl.h> diff --git a/sbin/mount/getmntopts.c b/sbin/mount/getmntopts.c index 629dd5de653..19e185f061e 100644 --- a/sbin/mount/getmntopts.c +++ b/sbin/mount/getmntopts.c @@ -1,4 +1,4 @@ -/* $OpenBSD: getmntopts.c,v 1.11 2009/10/27 23:59:33 deraadt Exp $ */ +/* $OpenBSD: getmntopts.c,v 1.12 2015/01/16 06:39:59 deraadt Exp $ */ /* $NetBSD: getmntopts.c,v 1.3 1995/03/18 14:56:58 cgd Exp $ */ /*- @@ -30,7 +30,7 @@ * SUCH DAMAGE. */ -#include <sys/param.h> +#include <sys/types.h> #include <sys/mount.h> #include <err.h> @@ -38,6 +38,7 @@ #include <fstab.h> #include <stdlib.h> #include <string.h> +#include <limits.h> #include "mntopts.h" diff --git a/sbin/mount/mount.c b/sbin/mount/mount.c index 35e24e68c4a..4a9b6052fb5 100644 --- a/sbin/mount/mount.c +++ b/sbin/mount/mount.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mount.c,v 1.59 2014/09/08 01:47:05 guenther Exp $ */ +/* $OpenBSD: mount.c,v 1.60 2015/01/16 06:39:59 deraadt Exp $ */ /* $NetBSD: mount.c,v 1.24 1995/11/18 03:34:29 cgd Exp $ */ /* @@ -30,7 +30,7 @@ * SUCH DAMAGE. */ -#include <sys/param.h> +#include <sys/types.h> #include <sys/mount.h> #include <sys/socket.h> #include <sys/wait.h> @@ -48,6 +48,7 @@ #include <stdlib.h> #include <string.h> #include <unistd.h> +#include <limits.h> #include <util.h> #include "pathnames.h" @@ -105,7 +106,7 @@ main(int argc, char * const argv[]) FILE *mountdfp; pid_t pid; int all, ch, forceall, i, mntsize, rval, new; - char *options, mntpath[MAXPATHLEN]; + char *options, mntpath[PATH_MAX]; all = forceall = 0; options = NULL; @@ -345,7 +346,7 @@ mountfs(const char *vfstype, const char *spec, const char *name, struct statfs sf; pid_t pid; int argc, i, status, argvsize; - char *optbuf, execname[MAXPATHLEN], mntpath[MAXPATHLEN]; + char *optbuf, execname[PATH_MAX], mntpath[PATH_MAX]; if (realpath(name, mntpath) == NULL) { warn("realpath %s", name); diff --git a/sbin/mount_cd9660/mount_cd9660.c b/sbin/mount_cd9660/mount_cd9660.c index 854a2ffef64..9c6b59725e5 100644 --- a/sbin/mount_cd9660/mount_cd9660.c +++ b/sbin/mount_cd9660/mount_cd9660.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mount_cd9660.c,v 1.20 2011/06/27 19:48:27 tedu Exp $ */ +/* $OpenBSD: mount_cd9660.c,v 1.21 2015/01/16 06:39:59 deraadt Exp $ */ /* $NetBSD: mount_cd9660.c,v 1.3 1996/04/13 01:31:08 jtc Exp $ */ /* @@ -35,7 +35,7 @@ * SUCH DAMAGE. */ -#include <sys/param.h> +#include <sys/types.h> #define CD9660 #include <sys/mount.h> @@ -46,6 +46,7 @@ #include <stdio.h> #include <string.h> #include <unistd.h> +#include <limits.h> #include "mntopts.h" @@ -62,7 +63,7 @@ main(int argc, char *argv[]) { struct iso_args args; int ch, mntflags, opts, sess = 0; - char *dev, dir[MAXPATHLEN]; + char *dev, dir[PATH_MAX]; const char *errstr; mntflags = opts = 0; diff --git a/sbin/mount_ext2fs/mount_ext2fs.c b/sbin/mount_ext2fs/mount_ext2fs.c index ee1d34d2e2c..652175a5744 100644 --- a/sbin/mount_ext2fs/mount_ext2fs.c +++ b/sbin/mount_ext2fs/mount_ext2fs.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mount_ext2fs.c,v 1.16 2012/07/09 12:58:01 krw Exp $ */ +/* $OpenBSD: mount_ext2fs.c,v 1.17 2015/01/16 06:39:59 deraadt Exp $ */ /* $NetBSD: mount_ffs.c,v 1.3 1996/04/13 01:31:19 jtc Exp $ */ /*- @@ -30,7 +30,7 @@ * SUCH DAMAGE. */ -#include <sys/param.h> +#include <sys/types.h> #include <sys/mount.h> #include <err.h> @@ -39,6 +39,7 @@ #include <stdlib.h> #include <string.h> #include <unistd.h> +#include <limits.h> #include "mntopts.h" @@ -55,7 +56,7 @@ main(int argc, char *argv[]) { struct ufs_args args; /* XXX ffs_args */ int ch, mntflags; - char fs_name[MAXPATHLEN], *errcause; + char fs_name[PATH_MAX], *errcause; mntflags = 0; optind = optreset = 1; /* Reset for parse of new argv. */ diff --git a/sbin/mount_ffs/mount_ffs.c b/sbin/mount_ffs/mount_ffs.c index 02bf63460a7..ddea908fc0b 100644 --- a/sbin/mount_ffs/mount_ffs.c +++ b/sbin/mount_ffs/mount_ffs.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mount_ffs.c,v 1.20 2009/10/27 23:59:33 deraadt Exp $ */ +/* $OpenBSD: mount_ffs.c,v 1.21 2015/01/16 06:39:59 deraadt Exp $ */ /* $NetBSD: mount_ffs.c,v 1.3 1996/04/13 01:31:19 jtc Exp $ */ /*- @@ -30,7 +30,7 @@ * SUCH DAMAGE. */ -#include <sys/param.h> +#include <sys/types.h> #include <sys/mount.h> #include <err.h> @@ -39,6 +39,7 @@ #include <stdlib.h> #include <string.h> #include <unistd.h> +#include <limits.h> #include "mntopts.h" @@ -60,7 +61,7 @@ main(int argc, char *argv[]) { struct ufs_args args; /* XXX ffs_args */ int ch, mntflags; - char fs_name[MAXPATHLEN], *errcause; + char fs_name[PATH_MAX], *errcause; mntflags = 0; optind = optreset = 1; /* Reset for parse of new argv. */ diff --git a/sbin/mount_msdos/mount_msdos.c b/sbin/mount_msdos/mount_msdos.c index 9cd5876b779..3057b45828f 100644 --- a/sbin/mount_msdos/mount_msdos.c +++ b/sbin/mount_msdos/mount_msdos.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mount_msdos.c,v 1.28 2013/11/22 04:12:48 deraadt Exp $ */ +/* $OpenBSD: mount_msdos.c,v 1.29 2015/01/16 06:39:59 deraadt Exp $ */ /* $NetBSD: mount_msdos.c,v 1.16 1996/10/24 00:12:50 cgd Exp $ */ /* @@ -31,7 +31,7 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include <sys/param.h> +#include <sys/types.h> #include <sys/mount.h> #include <sys/stat.h> #include <ctype.h> @@ -42,6 +42,7 @@ #include <stdlib.h> #include <string.h> #include <unistd.h> +#include <limits.h> #include <errno.h> #include "mntopts.h" @@ -64,7 +65,7 @@ main(int argc, char **argv) struct msdosfs_args args; struct stat sb; int c, mntflags, set_gid, set_uid, set_mask; - char *dev, dir[MAXPATHLEN]; + char *dev, dir[PATH_MAX]; char *errcause; mntflags = set_gid = set_uid = set_mask = 0; diff --git a/sbin/mount_nfs/mount_nfs.c b/sbin/mount_nfs/mount_nfs.c index 74a10d6359d..8d3094a8fa9 100644 --- a/sbin/mount_nfs/mount_nfs.c +++ b/sbin/mount_nfs/mount_nfs.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mount_nfs.c,v 1.51 2014/05/21 06:23:01 guenther Exp $ */ +/* $OpenBSD: mount_nfs.c,v 1.52 2015/01/16 06:39:59 deraadt Exp $ */ /* $NetBSD: mount_nfs.c,v 1.12.4.1 1996/05/25 22:48:05 fvdl Exp $ */ /* @@ -33,7 +33,7 @@ * SUCH DAMAGE. */ -#include <sys/param.h> +#include <sys/types.h> #include <sys/mount.h> #include <sys/socket.h> #include <sys/socketvar.h> @@ -60,6 +60,7 @@ #include <stdlib.h> #include <string.h> #include <unistd.h> +#include <limits.h> #include "mntopts.h" @@ -163,7 +164,7 @@ main(int argc, char *argv[]) struct nfs_args *nfsargsp; struct nfs_args nfsargs; int mntflags, num; - char name[MAXPATHLEN], *options = NULL, *spec; + char name[PATH_MAX], *options = NULL, *spec; const char *p; union mntval value; diff --git a/sbin/mount_ntfs/mount_ntfs.c b/sbin/mount_ntfs/mount_ntfs.c index 12553e4e6b0..10be734f5a2 100644 --- a/sbin/mount_ntfs/mount_ntfs.c +++ b/sbin/mount_ntfs/mount_ntfs.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mount_ntfs.c,v 1.14 2011/06/27 23:40:07 tedu Exp $ */ +/* $OpenBSD: mount_ntfs.c,v 1.15 2015/01/16 06:39:59 deraadt Exp $ */ /* $NetBSD: mount_ntfs.c,v 1.9 2003/05/03 15:37:08 christos Exp $ */ /* @@ -34,7 +34,7 @@ * Id: mount_ntfs.c,v 1.1.1.1 1999/02/03 03:51:19 semenu Exp */ -#include <sys/param.h> +#include <sys/types.h> #include <sys/mount.h> #include <sys/stat.h> @@ -44,6 +44,7 @@ #include <string.h> #include <sysexits.h> #include <unistd.h> +#include <limits.h> #include <mntopts.h> @@ -61,7 +62,7 @@ main(int argc, char *argv[]) struct ntfs_args args; struct stat sb; int c, mntflags, set_gid, set_uid, set_mask; - char *dev, dir[MAXPATHLEN]; + char *dev, dir[PATH_MAX]; mntflags = set_gid = set_uid = set_mask = 0; memset(&args, 0, sizeof(args)); diff --git a/sbin/mount_tmpfs/mount_tmpfs.c b/sbin/mount_tmpfs/mount_tmpfs.c index 3f469eef3a8..911e0104fb0 100644 --- a/sbin/mount_tmpfs/mount_tmpfs.c +++ b/sbin/mount_tmpfs/mount_tmpfs.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mount_tmpfs.c,v 1.4 2014/01/21 21:58:27 jsg Exp $ */ +/* $OpenBSD: mount_tmpfs.c,v 1.5 2015/01/16 06:39:59 deraadt Exp $ */ /* $NetBSD: mount_tmpfs.c,v 1.24 2008/08/05 20:57:45 pooka Exp $ */ /* @@ -31,12 +31,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include <sys/cdefs.h> -#if 0 -__RCSID("$NetBSD: mount_tmpfs.c,v 1.24 2008/08/05 20:57:45 pooka Exp $"); -#endif - -#include <sys/param.h> +#include <sys/types.h> #include <sys/mount.h> #include <sys/stat.h> @@ -50,6 +45,7 @@ __RCSID("$NetBSD: mount_tmpfs.c,v 1.24 2008/08/05 20:57:45 pooka Exp $"); #include <stdlib.h> #include <string.h> #include <unistd.h> +#include <limits.h> #include <util.h> #include "mount_tmpfs.h" @@ -146,7 +142,7 @@ mount_tmpfs_parseargs(int argc, char *argv[], if (argc != 2) usage(); - strlcpy(canon_dev, argv[0], MAXPATHLEN); + strlcpy(canon_dev, argv[0], PATH_MAX); pathadj(argv[1], canon_dir); if (stat(canon_dir, &sb) == -1) @@ -175,7 +171,7 @@ int mount_tmpfs(int argc, char *argv[]) { struct tmpfs_args args; - char canon_dev[MAXPATHLEN], canon_dir[MAXPATHLEN]; + char canon_dev[PATH_MAX], canon_dir[PATH_MAX]; int mntflags; mount_tmpfs_parseargs(argc, argv, &args, &mntflags, @@ -245,7 +241,7 @@ pathadj(const char *input, char *adjusted) if (realpath(input, adjusted) == NULL) warn("Warning: realpath %s", input); - if (strncmp(input, adjusted, MAXPATHLEN)) { + if (strncmp(input, adjusted, PATH_MAX)) { warnx("\"%s\" is a non-resolved or relative path.", input); warnx("using \"%s\" instead.", adjusted); } diff --git a/sbin/mount_udf/mount_udf.c b/sbin/mount_udf/mount_udf.c index 64c44d4e677..121146b5b7f 100644 --- a/sbin/mount_udf/mount_udf.c +++ b/sbin/mount_udf/mount_udf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mount_udf.c,v 1.6 2013/11/12 04:59:02 deraadt Exp $ */ +/* $OpenBSD: mount_udf.c,v 1.7 2015/01/16 06:39:59 deraadt Exp $ */ /* * Copyright (c) 2005 Pedro Martelletto <pedro@ambientworks.net> @@ -17,7 +17,7 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#include <sys/param.h> +#include <sys/types.h> #include <sys/mount.h> #include <sys/ioctl.h> #include <sys/cdio.h> @@ -25,6 +25,7 @@ #include <err.h> #include <fcntl.h> #include <unistd.h> +#include <limits.h> #include <stdlib.h> #include <stdio.h> @@ -74,7 +75,7 @@ int main(int argc, char **argv) { struct udf_args args; - char node[MAXPATHLEN]; + char node[PATH_MAX]; int ch, flags = 0; while ((ch = getopt(argc, argv, "o:")) != -1) diff --git a/sbin/mount_vnd/mount_vnd.c b/sbin/mount_vnd/mount_vnd.c index 4a9f85d3a17..362d0413c16 100644 --- a/sbin/mount_vnd/mount_vnd.c +++ b/sbin/mount_vnd/mount_vnd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mount_vnd.c,v 1.16 2014/10/29 21:30:10 tedu Exp $ */ +/* $OpenBSD: mount_vnd.c,v 1.17 2015/01/16 06:39:59 deraadt Exp $ */ /* * Copyright (c) 1993 University of Utah. * Copyright (c) 1990, 1993 @@ -37,7 +37,7 @@ * @(#)vnconfig.c 8.1 (Berkeley) 12/15/93 */ -#include <sys/param.h> +#include <sys/param.h> /* DEV_BSIZE */ #include <sys/ioctl.h> #include <sys/mount.h> #include <sys/stat.h> @@ -54,6 +54,7 @@ #include <stdlib.h> #include <string.h> #include <unistd.h> +#include <limits.h> #include <util.h> #define DEFAULT_VND "vnd0" diff --git a/sbin/mountd/mountd.c b/sbin/mountd/mountd.c index c021f65580c..5c324a769a9 100644 --- a/sbin/mountd/mountd.c +++ b/sbin/mountd/mountd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mountd.c,v 1.78 2014/11/20 15:22:39 tedu Exp $ */ +/* $OpenBSD: mountd.c,v 1.79 2015/01/16 06:39:59 deraadt Exp $ */ /* $NetBSD: mountd.c,v 1.31 1996/02/18 11:57:53 fvdl Exp $ */ /* @@ -33,7 +33,7 @@ * SUCH DAMAGE. */ -#include <sys/param.h> +#include <sys/types.h> #include <sys/ioctl.h> #include <sys/mount.h> #include <sys/socket.h> @@ -60,6 +60,7 @@ #include <stdlib.h> #include <string.h> #include <unistd.h> +#include <limits.h> #include "pathnames.h" #include <stdarg.h> @@ -177,7 +178,7 @@ void mountd_svc_run(void); struct exportlist *exphead; struct mountlist *mlhead; struct grouplist *grphead; -char exname[MAXPATHLEN]; +char exname[PATH_MAX]; struct xucred def_anon = { .cr_uid = (uid_t) -2, .cr_gid = (gid_t) -2, @@ -339,7 +340,7 @@ mountd_svc_run(void) void mntsrv(struct svc_req *rqstp, SVCXPRT *transp) { - char rpcpath[RPCMNT_PATHLEN+1], dirpath[MAXPATHLEN]; + char rpcpath[RPCMNT_PATHLEN+1], dirpath[PATH_MAX]; struct hostent *hp = NULL; struct exportlist *ep; sigset_t sighup_mask; @@ -1798,7 +1799,7 @@ get_line(void) void parsecred(char *namelist, struct xucred *cr) { - gid_t groups[NGROUPS + 1]; + gid_t groups[NGROUPS_MAX + 1]; char *name, *names; struct passwd *pw; struct group *gr; @@ -1827,7 +1828,7 @@ parsecred(char *namelist, struct xucred *cr) return; } cr->cr_uid = pw->pw_uid; - ngroups = NGROUPS + 1; + ngroups = NGROUPS_MAX + 1; if (getgrouplist(pw->pw_name, pw->pw_gid, groups, &ngroups)) syslog(LOG_ERR, "Too many groups for %s: %m", pw->pw_name); /* @@ -1852,7 +1853,7 @@ parsecred(char *namelist, struct xucred *cr) return; } cr->cr_ngroups = 0; - while (names != NULL && *names != '\0' && cr->cr_ngroups < NGROUPS) { + while (names != NULL && *names != '\0' && cr->cr_ngroups < NGROUPS_MAX) { name = strsep(&names, ":"); if (isdigit((unsigned char)*name) || *name == '-') { cr->cr_groups[cr->cr_ngroups++] = atoi(name); @@ -1864,7 +1865,7 @@ parsecred(char *namelist, struct xucred *cr) cr->cr_groups[cr->cr_ngroups++] = gr->gr_gid; } } - if (names != NULL && *names != '\0' && cr->cr_ngroups == NGROUPS) + if (names != NULL && *names != '\0' && cr->cr_ngroups == NGROUPS_MAX) syslog(LOG_ERR, "Too many groups"); } diff --git a/sbin/ncheck_ffs/ncheck_ffs.c b/sbin/ncheck_ffs/ncheck_ffs.c index bb35aa939f3..cb483f99485 100644 --- a/sbin/ncheck_ffs/ncheck_ffs.c +++ b/sbin/ncheck_ffs/ncheck_ffs.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ncheck_ffs.c,v 1.47 2014/10/09 02:41:22 deraadt Exp $ */ +/* $OpenBSD: ncheck_ffs.c,v 1.48 2015/01/16 06:39:59 deraadt Exp $ */ /*- * Copyright (c) 1995, 1996 SigmaSoft, Th. Lockert <tholo@sigmasoft.com> @@ -54,7 +54,7 @@ * SUCH DAMAGE. */ -#include <sys/param.h> +#include <sys/param.h> /* MAXFRAG MAXBSIZE DEV_BSIZE */ #include <sys/time.h> #include <sys/stat.h> #include <sys/ioctl.h> @@ -70,6 +70,7 @@ #include <string.h> #include <ctype.h> #include <unistd.h> +#include <limits.h> #include <fstab.h> #include <errno.h> #include <err.h> @@ -475,7 +476,7 @@ searchdir(ufsino_t ino, daddr_t blkno, long size, off_t filesize, char * rawname(char *name) { - static char newname[MAXPATHLEN]; + static char newname[PATH_MAX]; char *p; if ((p = strrchr(name, '/')) == NULL) diff --git a/sbin/newfs/mkfs.c b/sbin/newfs/mkfs.c index 45a16a96a9c..a36b694fa7d 100644 --- a/sbin/newfs/mkfs.c +++ b/sbin/newfs/mkfs.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mkfs.c,v 1.86 2014/06/30 19:19:17 otto Exp $ */ +/* $OpenBSD: mkfs.c,v 1.87 2015/01/16 06:40:00 deraadt Exp $ */ /* $NetBSD: mkfs.c,v 1.25 1995/06/18 21:35:38 cgd Exp $ */ /* @@ -39,7 +39,8 @@ * SUCH DAMAGE. */ -#include <sys/param.h> +#include <sys/param.h> /* MAXFRAG MAXBSIZE DEV_BSIZE roundup btodb setbit */ +#include <sys/signal.h> #include <sys/time.h> #include <sys/disklabel.h> #include <sys/ioctl.h> @@ -56,6 +57,7 @@ #include <stdlib.h> #include <stdint.h> #include <unistd.h> +#include <limits.h> #ifndef STANDALONE #include <a.out.h> @@ -63,6 +65,9 @@ #include <errno.h> #endif +#define MINIMUM(a, b) (((a) < (b)) ? (a) : (b)) +#define MAXIMUM(a, b) (((a) > (b)) ? (a) : (b)) + /* * Default directory umask. */ @@ -330,7 +335,7 @@ mkfs(struct partition *pp, char *fsys, int fi, int fo, mode_t mfsmode, */ origdensity = density; for (;;) { - fragsperinode = MAX(numfrags(&sblock, density), 1); + fragsperinode = MAXIMUM(numfrags(&sblock, density), 1); minfpg = fragsperinode * INOPB(&sblock); if (minfpg > sblock.fs_size) @@ -642,7 +647,7 @@ initcg(int cylno, time_t utime) acg.cg_magic = CG_MAGIC; acg.cg_cgx = cylno; acg.cg_ffs2_niblk = sblock.fs_ipg; - acg.cg_initediblk = MIN(sblock.fs_ipg, 2 * INOPB(&sblock)); + acg.cg_initediblk = MINIMUM(sblock.fs_ipg, 2 * INOPB(&sblock)); acg.cg_ndblk = dmax - cbase; start = sizeof(struct cg); @@ -729,7 +734,7 @@ initcg(int cylno, time_t utime) start += sblock.fs_bsize; dp1 = (struct ufs1_dinode *)(&iobuf[start]); dp2 = (struct ufs2_dinode *)(&iobuf[start]); - for (i = MIN(sblock.fs_ipg, 2 * INOPB(&sblock)); i != 0; i--) { + for (i = MINIMUM(sblock.fs_ipg, 2 * INOPB(&sblock)); i != 0; i--) { if (sblock.fs_magic == FS_UFS1_MAGIC) { dp1->di_gen = (u_int32_t)arc4random(); dp1++; @@ -1190,7 +1195,7 @@ checksz(void) err(1, "can't get physmem"); if (getrlimit(RLIMIT_DATA, &datasz) != 0) err(1, "can't get rlimit"); - bound = MIN(datasz.rlim_max, bound); + bound = MINIMUM(datasz.rlim_max, bound); allocate = 0; maxino = sblock.fs_ncg * (unsigned long long)sblock.fs_ipg; @@ -1200,8 +1205,8 @@ checksz(void) allocate += roundup(howmany(maxfsblock, NBBY), sizeof(int16_t)); allocate += (maxino + 1) * 3; allocate += sblock.fs_ncg * sizeof(long); - allocate += (MAX(ndir, 128) + 10) * sizeof(struct inoinfo); - allocate += MAX(ndir, 128) * sizeof(struct inoinfo); + allocate += (MAXIMUM(ndir, 128) + 10) * sizeof(struct inoinfo); + allocate += MAXIMUM(ndir, 128) * sizeof(struct inoinfo); if (allocate > bound) warnx("warning: fsck_ffs will need %lluMB; " diff --git a/sbin/newfs/newfs.c b/sbin/newfs/newfs.c index c5dd125fec7..78b5fa12ae7 100644 --- a/sbin/newfs/newfs.c +++ b/sbin/newfs/newfs.c @@ -1,4 +1,4 @@ -/* $OpenBSD: newfs.c,v 1.97 2014/07/20 01:38:40 guenther Exp $ */ +/* $OpenBSD: newfs.c,v 1.98 2015/01/16 06:40:00 deraadt Exp $ */ /* $NetBSD: newfs.c,v 1.20 1996/05/16 07:13:03 thorpej Exp $ */ /* @@ -39,7 +39,7 @@ * SUCH DAMAGE. */ -#include <sys/param.h> +#include <sys/param.h> /* MAXFRAG DEV_BSIZE MAXBSIZE */ #include <sys/types.h> #include <sys/stat.h> #include <sys/ioctl.h> @@ -65,12 +65,16 @@ #include <string.h> #include <syslog.h> #include <unistd.h> +#include <limits.h> #include <signal.h> #include <util.h> #include "mntopts.h" #include "pathnames.h" +#define MINIMUM(a, b) (((a) < (b)) ? (a) : (b)) +#define MAXIMUM(a, b) (((a) > (b)) ? (a) : (b)) + struct mntopt mopts[] = { MOPT_STDOPTS, MOPT_ASYNC, @@ -158,7 +162,7 @@ main(int argc, char *argv[]) char *cp = NULL, *s1, *s2, *special, *opstring, *realdev; #ifdef MFS char mountfromname[BUFSIZ]; - char *pop = NULL, node[MAXPATHLEN]; + char *pop = NULL, node[PATH_MAX]; pid_t pid, res; struct statfs sf; struct stat mountpoint; @@ -314,7 +318,7 @@ main(int argc, char *argv[]) special = argv[0]; if (!mfs) { - char execname[MAXPATHLEN], name[MAXPATHLEN]; + char execname[PATH_MAX], name[PATH_MAX]; if (fstype == NULL) fstype = readlabelfs(special, 0); @@ -450,12 +454,12 @@ havelabel: if (fsize == 0) { fsize = DISKLABELV1_FFS_FSIZE(pp->p_fragblock); if (fsize <= 0) - fsize = MAX(DFL_FRAGSIZE, lp->d_secsize); + fsize = MAXIMUM(DFL_FRAGSIZE, lp->d_secsize); } if (bsize == 0) { bsize = DISKLABELV1_FFS_BSIZE(pp->p_fragblock); if (bsize <= 0) - bsize = MIN(DFL_BLKSIZE, 8 * fsize); + bsize = MINIMUM(DFL_BLKSIZE, 8 * fsize); } if (density == 0) density = NFPI * fsize; diff --git a/sbin/newfs_ext2fs/mke2fs.c b/sbin/newfs_ext2fs/mke2fs.c index e47ffe42adb..fb49bed59af 100644 --- a/sbin/newfs_ext2fs/mke2fs.c +++ b/sbin/newfs_ext2fs/mke2fs.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mke2fs.c,v 1.12 2014/09/27 06:28:45 doug Exp $ */ +/* $OpenBSD: mke2fs.c,v 1.13 2015/01/16 06:40:00 deraadt Exp $ */ /* $NetBSD: mke2fs.c,v 1.13 2009/10/19 18:41:08 bouyer Exp $ */ /*- @@ -97,7 +97,8 @@ * in the Linux kernel distribution */ -#include <sys/param.h> +#include <sys/param.h> /* MAXBSIZE powerof2 roundup setbit isset MIN */ +#include <sys/types.h> #include <sys/mman.h> #include <sys/time.h> #include <ufs/ext2fs/ext2fs_dinode.h> diff --git a/sbin/newfs_ext2fs/newfs_ext2fs.c b/sbin/newfs_ext2fs/newfs_ext2fs.c index 56c9fc42ffe..4fdae02f3b0 100644 --- a/sbin/newfs_ext2fs/newfs_ext2fs.c +++ b/sbin/newfs_ext2fs/newfs_ext2fs.c @@ -1,4 +1,4 @@ -/* $OpenBSD: newfs_ext2fs.c,v 1.14 2014/11/20 15:22:39 tedu Exp $ */ +/* $OpenBSD: newfs_ext2fs.c,v 1.15 2015/01/16 06:40:00 deraadt Exp $ */ /* $NetBSD: newfs_ext2fs.c,v 1.8 2009/03/02 10:38:13 tsutsui Exp $ */ /* @@ -33,7 +33,8 @@ /* * newfs: friendly front end to mke2fs */ -#include <sys/param.h> +#include <sys/param.h> /* powerof2 */ +#include <sys/types.h> #include <sys/ioctl.h> #include <sys/dkio.h> #include <sys/disklabel.h> @@ -56,6 +57,8 @@ #include <unistd.h> #include <util.h> +#define MINIMUM(a, b) (((a) < (b)) ? (a) : (b)) + #include "extern.h" static int64_t strsuftoi64(const char *, const char *, int64_t, int64_t, int *); @@ -101,7 +104,7 @@ uint num_inodes; /* number of inodes (overrides density) */ char *volname = NULL; /* volume name */ static char *disktype = NULL; -static char device[MAXPATHLEN]; +static char device[PATH_MAX]; struct disklabel *getdisklabel(const char *, int); struct partition *getpartition(int, const char *, char *[], struct disklabel **); @@ -344,7 +347,7 @@ main(int argc, char *argv[]) "size %" PRId64 " bytes, in %d byte chunks.\n", special, bufrem, bufsize); while (bufrem > 0) { - i = write(fso, buf, MIN(bufsize, bufrem)); + i = write(fso, buf, MINIMUM(bufsize, bufrem)); if (i == -1) err(1, "writing image"); bufrem -= i; diff --git a/sbin/newfs_msdos/newfs_msdos.c b/sbin/newfs_msdos/newfs_msdos.c index 682e0527e11..6006fe96e27 100644 --- a/sbin/newfs_msdos/newfs_msdos.c +++ b/sbin/newfs_msdos/newfs_msdos.c @@ -1,4 +1,4 @@ -/* $OpenBSD: newfs_msdos.c,v 1.24 2014/07/10 20:09:53 tobias Exp $ */ +/* $OpenBSD: newfs_msdos.c,v 1.25 2015/01/16 06:40:00 deraadt Exp $ */ /* * Copyright (c) 1998 Robert Nordier @@ -27,7 +27,7 @@ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include <sys/param.h> +#include <sys/param.h> /* powerof2 */ #include <sys/stat.h> #include <sys/disklabel.h> #include <sys/ioctl.h> @@ -43,8 +43,12 @@ #include <stdlib.h> #include <string.h> #include <unistd.h> +#include <limits.h> #include <util.h> +#define MINIMUM(a, b) (((a) < (b)) ? (a) : (b)) +#define MAXIMUM(a, b) (((a) > (b)) ? (a) : (b)) + #define MAXU16 0xffff /* maximum unsigned 16-bit quantity */ #define BPN 4 /* bits per nibble */ #define NPB 2 /* nibbles per byte */ @@ -229,7 +233,7 @@ main(int argc, char *argv[]) static u_int opt_s, opt_u; static int opt_N; static int Iflag, mflag, oflag; - char buf[MAXPATHLEN]; + char buf[PATH_MAX]; struct stat sb; struct timeval tv; struct bpb bpb; @@ -479,7 +483,7 @@ main(int argc, char *argv[]) x = bpb.bkbs + 1; } if (!bpb.res) - bpb.res = fat == 32 ? MAX(x, MAX(16384 / bpb.bps, 4)) : x; + bpb.res = fat == 32 ? MAXIMUM(x, MAXIMUM(16384 / bpb.bps, 4)) : x; else if (bpb.res < x) errx(1, "too few reserved sectors"); if (fat != 32 && !bpb.rde) @@ -503,7 +507,7 @@ main(int argc, char *argv[]) x1 += x * bpb.nft; x = (u_int64_t)(bpb.bsec - x1) * bpb.bps * NPB / (bpb.spc * bpb.bps * NPB + fat / BPN * bpb.nft); - x2 = howmany((RESFTE + MIN(x, maxcls(fat))) * (fat / BPN), + x2 = howmany((RESFTE + MINIMUM(x, maxcls(fat))) * (fat / BPN), bpb.bps * NPB); if (!bpb.bspf) { bpb.bspf = x2; diff --git a/sbin/nfsd/nfsd.c b/sbin/nfsd/nfsd.c index d4deb7dd0f9..a20240e390a 100644 --- a/sbin/nfsd/nfsd.c +++ b/sbin/nfsd/nfsd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: nfsd.c,v 1.34 2014/05/11 00:03:14 chl Exp $ */ +/* $OpenBSD: nfsd.c,v 1.35 2015/01/16 06:40:00 deraadt Exp $ */ /* $NetBSD: nfsd.c,v 1.19 1996/02/18 23:18:56 mycroft Exp $ */ /* @@ -33,7 +33,6 @@ * SUCH DAMAGE. */ -#include <sys/param.h> #include <sys/ioctl.h> #include <sys/stat.h> #include <sys/wait.h> diff --git a/sbin/pfctl/parse.y b/sbin/pfctl/parse.y index 083c2ddbb73..bf2dbbce540 100644 --- a/sbin/pfctl/parse.y +++ b/sbin/pfctl/parse.y @@ -1,4 +1,4 @@ -/* $OpenBSD: parse.y,v 1.643 2014/12/19 13:04:07 reyk Exp $ */ +/* $OpenBSD: parse.y,v 1.644 2015/01/16 06:40:00 deraadt Exp $ */ /* * Copyright (c) 2001 Markus Friedl. All rights reserved. @@ -903,23 +903,23 @@ loadrule : LOAD ANCHOR string FROM string { struct loadanchors *loadanchor; if (strlen(pf->anchor->name) + 1 + - strlen($3) >= MAXPATHLEN) { + strlen($3) >= PATH_MAX) { yyerror("anchorname %s too long, max %u\n", - $3, MAXPATHLEN - 1); + $3, PATH_MAX - 1); free($3); YYERROR; } loadanchor = calloc(1, sizeof(struct loadanchors)); if (loadanchor == NULL) err(1, "loadrule: calloc"); - if ((loadanchor->anchorname = malloc(MAXPATHLEN)) == + if ((loadanchor->anchorname = malloc(PATH_MAX)) == NULL) err(1, "loadrule: malloc"); if (pf->anchor->name[0]) - snprintf(loadanchor->anchorname, MAXPATHLEN, + snprintf(loadanchor->anchorname, PATH_MAX, "%s/%s", pf->anchor->name, $3); else - strlcpy(loadanchor->anchorname, $3, MAXPATHLEN); + strlcpy(loadanchor->anchorname, $3, PATH_MAX); if ((loadanchor->filename = strdup($5)) == NULL) err(1, "loadrule: strdup"); diff --git a/sbin/pfctl/pfctl.c b/sbin/pfctl/pfctl.c index 34fde7eb159..bccb8e24b80 100644 --- a/sbin/pfctl/pfctl.c +++ b/sbin/pfctl/pfctl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pfctl.c,v 1.328 2014/12/10 13:59:29 bluhm Exp $ */ +/* $OpenBSD: pfctl.c,v 1.329 2015/01/16 06:40:00 deraadt Exp $ */ /* * Copyright (c) 2001 Daniel Hartmeier @@ -749,14 +749,14 @@ pfctl_show_rules(int dev, char *path, int opts, enum pfctl_show format, memset(&pr, 0, sizeof(pr)); if (anchorname[0] == '/') { - if ((npath = calloc(1, MAXPATHLEN)) == NULL) + if ((npath = calloc(1, PATH_MAX)) == NULL) errx(1, "pfctl_rules: calloc"); - strlcpy(npath, anchorname, MAXPATHLEN); + strlcpy(npath, anchorname, PATH_MAX); } else { if (path[0]) - snprintf(&path[len], MAXPATHLEN - len, "/%s", anchorname); + snprintf(&path[len], PATH_MAX - len, "/%s", anchorname); else - snprintf(&path[len], MAXPATHLEN - len, "%s", anchorname); + snprintf(&path[len], PATH_MAX - len, "%s", anchorname); npath = path; } @@ -1330,9 +1330,9 @@ pfctl_load_ruleset(struct pfctl *pf, char *path, struct pf_ruleset *rs, pf->anchor = rs->anchor; if (path[0]) - snprintf(&path[len], MAXPATHLEN - len, "/%s", pf->anchor->name); + snprintf(&path[len], PATH_MAX - len, "/%s", pf->anchor->name); else - snprintf(&path[len], MAXPATHLEN - len, "%s", pf->anchor->name); + snprintf(&path[len], PATH_MAX - len, "%s", pf->anchor->name); if (depth) { if (TAILQ_FIRST(rs->rules.active.ptr) != NULL) { @@ -1396,10 +1396,10 @@ pfctl_load_rule(struct pfctl *pf, char *path, struct pf_rule *r, int depth) if (r->anchor) { if (r->anchor->match) { if (path[0]) - snprintf(&path[len], MAXPATHLEN - len, + snprintf(&path[len], PATH_MAX - len, "/%s", r->anchor->name); else - snprintf(&path[len], MAXPATHLEN - len, + snprintf(&path[len], PATH_MAX - len, "%s", r->anchor->name); name = r->anchor->name; } else @@ -1455,7 +1455,7 @@ pfctl_rules(int dev, char *filename, int opts, int optimize, memset(&pf, 0, sizeof(pf)); memset(&trs, 0, sizeof(trs)); - if ((path = calloc(1, MAXPATHLEN)) == NULL) + if ((path = calloc(1, PATH_MAX)) == NULL) ERRX("pfctl_rules: calloc"); if (strlcpy(trs.pfrt_anchor, anchorname, sizeof(trs.pfrt_anchor)) >= sizeof(trs.pfrt_anchor)) @@ -1980,7 +1980,7 @@ pfctl_show_anchors(int dev, int opts, char *anchorname) } mnr = pr.nr; for (nr = 0; nr < mnr; ++nr) { - char sub[MAXPATHLEN]; + char sub[PATH_MAX]; pr.nr = nr; if (ioctl(dev, DIOCGETRULESET, &pr)) @@ -2097,7 +2097,7 @@ main(int argc, char *argv[]) int opts = 0; int optimize = PF_OPTIMIZE_BASIC; int level; - char anchorname[MAXPATHLEN]; + char anchorname[PATH_MAX]; int anchor_wildcard = 0; char *path; char *lfile = NULL, *sfile = NULL; @@ -2252,7 +2252,7 @@ main(int argc, char *argv[]) /* NOTREACHED */ } - if ((path = calloc(1, MAXPATHLEN)) == NULL) + if ((path = calloc(1, PATH_MAX)) == NULL) errx(1, "pfctl: calloc"); memset(anchorname, 0, sizeof(anchorname)); if (anchoropt != NULL) { diff --git a/sbin/pfctl/pfctl_osfp.c b/sbin/pfctl/pfctl_osfp.c index 44d43ef43d2..2a151469127 100644 --- a/sbin/pfctl/pfctl_osfp.c +++ b/sbin/pfctl/pfctl_osfp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pfctl_osfp.c,v 1.20 2014/10/25 03:18:13 lteo Exp $ */ +/* $OpenBSD: pfctl_osfp.c,v 1.21 2015/01/16 06:40:00 deraadt Exp $ */ /* * Copyright (c) 2003 Mike Frantzen <frantzen@openbsd.org> @@ -36,13 +36,7 @@ #include "pfctl_parser.h" #include "pfctl.h" -#ifndef MIN -# define MIN(a,b) (((a) < (b)) ? (a) : (b)) -#endif /* MIN */ -#ifndef MAX -# define MAX(a,b) (((a) > (b)) ? (a) : (b)) -#endif /* MAX */ - +#define MAXIMUM(a, b) (((a) > (b)) ? (a) : (b)) #if 0 # define DEBUG(fp, str, v...) \ @@ -665,7 +659,7 @@ import_fingerprint(struct pf_osfp_ioctl *fp) nm_class = fingerprint_name_entry(&classes, fp->fp_os.fp_class_nm); if (nm_class->nm_num == 0) { nm_class->nm_num = class; - class_count = MAX(class_count, class); + class_count = MAXIMUM(class_count, class); } nm_version = fingerprint_name_entry(&nm_class->nm_sublist, @@ -673,7 +667,7 @@ import_fingerprint(struct pf_osfp_ioctl *fp) if (nm_version) { if (nm_version->nm_num == 0) { nm_version->nm_num = version; - nm_class->nm_sublist_num = MAX(nm_class->nm_sublist_num, + nm_class->nm_sublist_num = MAXIMUM(nm_class->nm_sublist_num, version); } nm_subtype = fingerprint_name_entry(&nm_version->nm_sublist, @@ -682,7 +676,7 @@ import_fingerprint(struct pf_osfp_ioctl *fp) if (nm_subtype->nm_num == 0) { nm_subtype->nm_num = subtype; nm_version->nm_sublist_num = - MAX(nm_version->nm_sublist_num, subtype); + MAXIMUM(nm_version->nm_sublist_num, subtype); } } } diff --git a/sbin/pfctl/pfctl_parser.c b/sbin/pfctl/pfctl_parser.c index ca7780b95bf..3aacf1223c9 100644 --- a/sbin/pfctl/pfctl_parser.c +++ b/sbin/pfctl/pfctl_parser.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pfctl_parser.c,v 1.300 2014/10/27 21:51:32 mikeb Exp $ */ +/* $OpenBSD: pfctl_parser.c,v 1.301 2015/01/16 06:40:00 deraadt Exp $ */ /* * Copyright (c) 2001 Daniel Hartmeier @@ -54,6 +54,7 @@ #include <err.h> #include <ifaddrs.h> #include <unistd.h> +#include <limits.h> #define SYSLOG_NAMES #include <syslog.h> diff --git a/sbin/pfctl/pfctl_table.c b/sbin/pfctl/pfctl_table.c index afe4d7f9075..e6b7c7565ab 100644 --- a/sbin/pfctl/pfctl_table.c +++ b/sbin/pfctl/pfctl_table.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pfctl_table.c,v 1.72 2013/07/05 13:07:57 blambert Exp $ */ +/* $OpenBSD: pfctl_table.c,v 1.73 2015/01/16 06:40:00 deraadt Exp $ */ /* * Copyright (c) 2002 Cedric Berger @@ -47,6 +47,7 @@ #include <stdlib.h> #include <string.h> #include <time.h> +#include <limits.h> #include "pfctl_parser.h" #include "pfctl.h" diff --git a/sbin/ping/ping.c b/sbin/ping/ping.c index f9d37c14af5..46750461d79 100644 --- a/sbin/ping/ping.c +++ b/sbin/ping/ping.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ping.c,v 1.113 2014/11/20 15:22:39 tedu Exp $ */ +/* $OpenBSD: ping.c,v 1.114 2015/01/16 06:40:00 deraadt Exp $ */ /* $NetBSD: ping.c,v 1.20 1995/08/11 22:37:58 cgd Exp $ */ /* @@ -70,6 +70,7 @@ #include <errno.h> #include <poll.h> #include <string.h> +#include <limits.h> #include <stdlib.h> struct tv32 { @@ -179,7 +180,7 @@ main(int argc, char *argv[]) struct in_addr saddr; int ch, i, optval = 1, packlen, preload, maxsize, df = 0, tos = 0; u_char *datap, *packet, ttl = MAXTTL, loop = 1; - char *target, hnamebuf[MAXHOSTNAMELEN]; + char *target, hnamebuf[HOST_NAME_MAX+1]; char rspace[3 + 4 * NROUTES + 1]; /* record route space */ socklen_t maxsizelen; const char *errstr; @@ -1207,7 +1208,7 @@ pr_addr(in_addr_t a) { struct hostent *hp; struct in_addr in; - static char buf[16+3+MAXHOSTNAMELEN]; + static char buf[16+3+HOST_NAME_MAX+1]; in.s_addr = a; if ((options & F_NUMERIC) || diff --git a/sbin/ping6/ping6.c b/sbin/ping6/ping6.c index 70043a5ac87..812a10a489e 100644 --- a/sbin/ping6/ping6.c +++ b/sbin/ping6/ping6.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ping6.c,v 1.100 2014/12/03 23:04:52 deraadt Exp $ */ +/* $OpenBSD: ping6.c,v 1.101 2015/01/16 06:40:00 deraadt Exp $ */ /* $KAME: ping6.c,v 1.163 2002/10/25 02:19:06 itojun Exp $ */ /* @@ -1185,6 +1185,8 @@ dnsdecode(const u_char **sp, const u_char *ep, const u_char *base, return buf; } +#define MINIMUM(a,b) (((a)<(b))?(a):(b)) + /* * pr_pack -- * Print out the packet, if it came from us. This logic is necessary @@ -1305,7 +1307,7 @@ pr_pack(u_char *buf, int cc, struct msghdr *mhdr) (void)printf(" (%d bytes %s)", abs(delta), delta > 0 ? "extra" : "short"); - end = buf + MIN(cc, ICMP6ECHOLEN + datalen); + end = buf + MINIMUM(cc, ICMP6ECHOLEN + datalen); } for (i = 8; cp < end; ++i, ++cp, ++dp) { if (*cp != *dp) { diff --git a/sbin/quotacheck/quotacheck.c b/sbin/quotacheck/quotacheck.c index fc7e98f46de..018fcb0bcbd 100644 --- a/sbin/quotacheck/quotacheck.c +++ b/sbin/quotacheck/quotacheck.c @@ -1,4 +1,4 @@ -/* $OpenBSD: quotacheck.c,v 1.34 2014/07/22 18:28:40 jca Exp $ */ +/* $OpenBSD: quotacheck.c,v 1.35 2015/01/16 06:40:00 deraadt Exp $ */ /* $NetBSD: quotacheck.c,v 1.12 1996/03/30 22:34:25 mark Exp $ */ /* @@ -36,7 +36,7 @@ /* * Fix up / report on disk quotas & usage */ -#include <sys/param.h> +#include <sys/param.h> /* MAXFRAG DEV_BSIZE MAXBSIZE */ #include <sys/stat.h> #include <sys/wait.h> @@ -50,6 +50,7 @@ #include <grp.h> #include <errno.h> #include <unistd.h> +#include <limits.h> #include <util.h> #include <stdio.h> #include <stdlib.h> @@ -84,8 +85,8 @@ union dinode { struct quotaname { long flags; - char grpqfname[MAXPATHLEN + 1]; - char usrqfname[MAXPATHLEN + 1]; + char grpqfname[PATH_MAX + 1]; + char usrqfname[PATH_MAX + 1]; }; #define HASUSR 1 #define HASGRP 2 diff --git a/sbin/reboot/reboot.c b/sbin/reboot/reboot.c index 1ad102c6eb9..eb28ad184f1 100644 --- a/sbin/reboot/reboot.c +++ b/sbin/reboot/reboot.c @@ -1,4 +1,4 @@ -/* $OpenBSD: reboot.c,v 1.33 2013/02/09 21:21:27 millert Exp $ */ +/* $OpenBSD: reboot.c,v 1.34 2015/01/16 06:40:00 deraadt Exp $ */ /* $NetBSD: reboot.c,v 1.8 1995/10/05 05:36:22 mycroft Exp $ */ /* @@ -33,7 +33,6 @@ #include <sys/types.h> #include <sys/reboot.h> #include <sys/fcntl.h> -#include <sys/param.h> #include <sys/sysctl.h> #include <sys/wait.h> #include <machine/cpu.h> diff --git a/sbin/restore/dirs.c b/sbin/restore/dirs.c index 00fc9ff47d4..8c8aa10c698 100644 --- a/sbin/restore/dirs.c +++ b/sbin/restore/dirs.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dirs.c,v 1.38 2014/09/07 19:43:35 guenther Exp $ */ +/* $OpenBSD: dirs.c,v 1.39 2015/01/16 06:40:00 deraadt Exp $ */ /* $NetBSD: dirs.c,v 1.26 1997/07/01 05:37:49 lukem Exp $ */ /* @@ -35,7 +35,7 @@ * SUCH DAMAGE. */ -#include <sys/param.h> +#include <sys/param.h> /* MAXFRAG */ #include <sys/stat.h> #include <sys/time.h> @@ -53,6 +53,7 @@ #include <stdlib.h> #include <string.h> #include <unistd.h> +#include <limits.h> #include "restore.h" #include "extern.h" @@ -101,8 +102,8 @@ struct rstdirdesc { static long seekpt; static FILE *df, *mf; static RST_DIR *dirp; -static char dirfile[MAXPATHLEN] = "#"; /* No file */ -static char modefile[MAXPATHLEN] = "#"; /* No file */ +static char dirfile[PATH_MAX] = "#"; /* No file */ +static char modefile[PATH_MAX] = "#"; /* No file */ static char dot[2] = "."; /* So it can be modified */ /* @@ -222,7 +223,7 @@ treescan(char *pname, ino_t ino, long (*todo)(char *, ino_t, int)) struct direct *dp; size_t namelen; long bpt; - char locname[MAXPATHLEN + 1]; + char locname[PATH_MAX + 1]; itp = inotablookup(ino); if (itp == NULL) { @@ -285,7 +286,7 @@ pathsearch(const char *pathname) { ino_t ino; struct direct *dp; - char *path, *name, buffer[MAXPATHLEN]; + char *path, *name, buffer[PATH_MAX]; strlcpy(buffer, pathname, sizeof buffer); path = buffer; diff --git a/sbin/restore/interactive.c b/sbin/restore/interactive.c index 9e0ef7521d6..a46a60bb360 100644 --- a/sbin/restore/interactive.c +++ b/sbin/restore/interactive.c @@ -1,4 +1,4 @@ -/* $OpenBSD: interactive.c,v 1.28 2013/04/25 06:43:20 otto Exp $ */ +/* $OpenBSD: interactive.c,v 1.29 2015/01/16 06:40:00 deraadt Exp $ */ /* $NetBSD: interactive.c,v 1.10 1997/03/19 08:42:52 lukem Exp $ */ /* @@ -30,7 +30,7 @@ * SUCH DAMAGE. */ -#include <sys/param.h> +#include <sys/param.h> /* MAXFRAG */ #include <sys/time.h> #include <sys/stat.h> @@ -46,6 +46,7 @@ #include <stdlib.h> #include <string.h> #include <unistd.h> +#include <limits.h> #include "restore.h" #include "extern.h" @@ -94,8 +95,8 @@ runcmdshell(void) struct entry *np; ino_t ino; struct arglist arglist; - char curdir[MAXPATHLEN]; - char name[MAXPATHLEN]; + char curdir[PATH_MAX]; + char name[PATH_MAX]; char cmd[BUFSIZ]; arglist.freeglob = 0; @@ -337,7 +338,7 @@ getcmd(char *curdir, char *cmd, size_t cmdlen, char *name, size_t namelen, * If no argument, use curdir as the default. */ if (*cp == '\0') { - (void)strlcpy(name, curdir, MAXPATHLEN); + (void)strlcpy(name, curdir, PATH_MAX); return; } nextarg = cp; @@ -389,7 +390,7 @@ getnext: retnext: strlcpy(name, ap->glob.gl_pathv[ap->glob.gl_pathc - ap->argcnt], - MAXPATHLEN); + PATH_MAX); if (--ap->argcnt == 0) { ap->freeglob = 0; globfree(&ap->glob); @@ -507,7 +508,7 @@ printlist(char *name, char *basename) RST_DIR *dirp; size_t namelen; int entries, len; - char locname[MAXPATHLEN]; + char locname[PATH_MAX]; dp = pathsearch(name); if (dp == NULL || (!dflag && TSTINO(dp->d_ino, dumpmap) == 0)) @@ -551,9 +552,9 @@ printlist(char *name, char *basename) strcmp(dp->d_name, "..") == 0)) continue; locname[namelen] = '\0'; - if (namelen + dp->d_namlen >= MAXPATHLEN) { + if (namelen + dp->d_namlen >= PATH_MAX) { fprintf(stderr, "%s%s: name exceeds %d char\n", - locname, dp->d_name, MAXPATHLEN); + locname, dp->d_name, PATH_MAX); } else { (void)strncat(locname, dp->d_name, (int)dp->d_namlen); diff --git a/sbin/restore/main.c b/sbin/restore/main.c index 7224d343947..5c0f46c5265 100644 --- a/sbin/restore/main.c +++ b/sbin/restore/main.c @@ -1,4 +1,4 @@ -/* $OpenBSD: main.c,v 1.21 2014/11/26 18:34:51 millert Exp $ */ +/* $OpenBSD: main.c,v 1.22 2015/01/16 06:40:00 deraadt Exp $ */ /* $NetBSD: main.c,v 1.13 1997/07/01 05:37:51 lukem Exp $ */ /* @@ -30,7 +30,7 @@ * SUCH DAMAGE. */ -#include <sys/param.h> +#include <sys/param.h> /* MAXFRAG */ #include <sys/stat.h> #include <sys/time.h> @@ -45,6 +45,7 @@ #include <stdlib.h> #include <string.h> #include <unistd.h> +#include <limits.h> #include "restore.h" #include "extern.h" @@ -73,7 +74,7 @@ main(int argc, char *argv[]) ino_t ino; char *inputdev; char *symtbl = "./restoresymtable"; - char *p, name[MAXPATHLEN]; + char *p, name[PATH_MAX]; /* Temp files should *not* be readable. We set permissions later. */ (void)umask(077); diff --git a/sbin/restore/symtab.c b/sbin/restore/symtab.c index 5240d2e828c..e7322dafb68 100644 --- a/sbin/restore/symtab.c +++ b/sbin/restore/symtab.c @@ -1,4 +1,4 @@ -/* $OpenBSD: symtab.c,v 1.21 2013/12/30 22:01:23 deraadt Exp $ */ +/* $OpenBSD: symtab.c,v 1.22 2015/01/16 06:40:00 deraadt Exp $ */ /* $NetBSD: symtab.c,v 1.10 1997/03/19 08:42:54 lukem Exp $ */ /* @@ -39,7 +39,6 @@ * are needed, by calling "myname". */ -#include <sys/param.h> #include <sys/stat.h> #include <ufs/ufs/dinode.h> @@ -50,6 +49,7 @@ #include <stdlib.h> #include <string.h> #include <unistd.h> +#include <limits.h> #include "restore.h" #include "extern.h" @@ -138,7 +138,7 @@ lookupname(char *name) { struct entry *ep; char *np, *cp; - char buf[MAXPATHLEN]; + char buf[PATH_MAX]; cp = name; for (ep = lookupino(ROOTINO); ep != NULL; ep = ep->e_entries) { @@ -188,9 +188,9 @@ char * myname(struct entry *ep) { char *cp; - static char namebuf[MAXPATHLEN]; + static char namebuf[PATH_MAX]; - for (cp = &namebuf[MAXPATHLEN - 2]; cp > &namebuf[ep->e_namlen]; ) { + for (cp = &namebuf[PATH_MAX - 2]; cp > &namebuf[ep->e_namlen]; ) { cp -= ep->e_namlen; memcpy(cp, ep->e_name, ep->e_namlen); if (ep == lookupino(ROOTINO)) diff --git a/sbin/restore/tape.c b/sbin/restore/tape.c index 96bce33d281..eac5ce3d9f6 100644 --- a/sbin/restore/tape.c +++ b/sbin/restore/tape.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tape.c,v 1.44 2014/09/07 19:43:35 guenther Exp $ */ +/* $OpenBSD: tape.c,v 1.45 2015/01/16 06:40:00 deraadt Exp $ */ /* $NetBSD: tape.c,v 1.26 1997/04/15 07:12:25 lukem Exp $ */ /* @@ -35,7 +35,7 @@ * SUCH DAMAGE. */ -#include <sys/param.h> +#include <sys/param.h> /* MAXBSIZE */ #include <sys/ioctl.h> #include <sys/mtio.h> #include <sys/stat.h> @@ -51,6 +51,7 @@ #include <stdlib.h> #include <string.h> #include <unistd.h> +#include <limits.h> #include "restore.h" #include "extern.h" @@ -72,7 +73,7 @@ static char *host = NULL; static int ofile; static char *map; -static char lnkbuf[MAXPATHLEN + 1]; +static char lnkbuf[PATH_MAX + 1]; static size_t pathlen; int oldinofmt; /* old inode format conversion required */ @@ -755,7 +756,7 @@ xtrlnkfile(char *buf, size_t size) { pathlen += size; - if (pathlen > MAXPATHLEN) + if (pathlen > PATH_MAX) errx(1, "symbolic link name: %s->%s%s; too long %lu", curfile.name, lnkbuf, buf, (u_long)pathlen); (void)strlcat(lnkbuf, buf, sizeof(lnkbuf)); diff --git a/sbin/restore/utilities.c b/sbin/restore/utilities.c index 8137d4ff7ee..ebaac08e981 100644 --- a/sbin/restore/utilities.c +++ b/sbin/restore/utilities.c @@ -1,4 +1,4 @@ -/* $OpenBSD: utilities.c,v 1.17 2013/04/24 13:46:29 deraadt Exp $ */ +/* $OpenBSD: utilities.c,v 1.18 2015/01/16 06:40:00 deraadt Exp $ */ /* $NetBSD: utilities.c,v 1.11 1997/03/19 08:42:56 lukem Exp $ */ /* @@ -30,7 +30,6 @@ * SUCH DAMAGE. */ -#include <sys/param.h> #include <sys/stat.h> #include <ufs/ufs/dinode.h> @@ -42,6 +41,7 @@ #include <stdlib.h> #include <string.h> #include <unistd.h> +#include <limits.h> #include "restore.h" #include "extern.h" @@ -80,7 +80,7 @@ pathcheck(char *name) void mktempname(struct entry *ep) { - char oldname[MAXPATHLEN]; + char oldname[PATH_MAX]; if (ep->e_flags & TMPNAME) badentry(ep, "mktempname: called with TMPNAME"); @@ -98,7 +98,7 @@ mktempname(struct entry *ep) char * gentempname(struct entry *ep) { - static char name[MAXPATHLEN]; + static char name[PATH_MAX]; struct entry *np; long i = 0; diff --git a/sbin/route/route.c b/sbin/route/route.c index 4c1bdfbb3c7..621852a70b1 100644 --- a/sbin/route/route.c +++ b/sbin/route/route.c @@ -1,4 +1,4 @@ -/* $OpenBSD: route.c,v 1.170 2014/08/19 12:39:36 mpi Exp $ */ +/* $OpenBSD: route.c,v 1.171 2015/01/16 06:40:00 deraadt Exp $ */ /* $NetBSD: route.c,v 1.16 1996/04/15 18:27:05 cgd Exp $ */ /* @@ -30,7 +30,6 @@ * SUCH DAMAGE. */ -#include <sys/param.h> #include <sys/socket.h> #include <sys/ioctl.h> #include <sys/sysctl.h> @@ -46,6 +45,7 @@ #include <errno.h> #include <fcntl.h> #include <unistd.h> +#include <limits.h> #include <stdio.h> #include <ctype.h> #include <stddef.h> diff --git a/sbin/route/show.c b/sbin/route/show.c index 0f9c2e5ba8e..576f6ef41f7 100644 --- a/sbin/route/show.c +++ b/sbin/route/show.c @@ -1,4 +1,4 @@ -/* $OpenBSD: show.c,v 1.96 2014/05/08 09:28:08 mpi Exp $ */ +/* $OpenBSD: show.c,v 1.97 2015/01/16 06:40:00 deraadt Exp $ */ /* $NetBSD: show.c,v 1.1 1996/11/15 18:01:41 gwr Exp $ */ /* @@ -30,7 +30,6 @@ * SUCH DAMAGE. */ -#include <sys/param.h> #include <sys/socket.h> #include <sys/sysctl.h> @@ -53,6 +52,7 @@ #include <stdlib.h> #include <string.h> #include <unistd.h> +#include <limits.h> #include "show.h" @@ -567,8 +567,8 @@ p_sockaddr(struct sockaddr *sa, struct sockaddr *mask, int flags, int width) } } -static char line[MAXHOSTNAMELEN]; -static char domain[MAXHOSTNAMELEN]; +static char line[HOST_NAME_MAX+1]; +static char domain[HOST_NAME_MAX+1]; void p_sockaddr_mpls(struct sockaddr *in, struct sockaddr *out, int flags, int width) diff --git a/sbin/savecore/savecore.c b/sbin/savecore/savecore.c index 468fc9f1ab2..7f83c5b1160 100644 --- a/sbin/savecore/savecore.c +++ b/sbin/savecore/savecore.c @@ -1,4 +1,4 @@ -/* $OpenBSD: savecore.c,v 1.49 2013/06/03 02:49:42 tedu Exp $ */ +/* $OpenBSD: savecore.c,v 1.50 2015/01/16 06:40:00 deraadt Exp $ */ /* $NetBSD: savecore.c,v 1.26 1996/03/18 21:16:05 leo Exp $ */ /*- @@ -30,7 +30,7 @@ * SUCH DAMAGE. */ -#include <sys/param.h> +#include <sys/param.h> /* NODEV DEV_BSIZE */ #include <sys/stat.h> #include <sys/mount.h> #include <sys/syslog.h> @@ -53,6 +53,8 @@ #include <kvm.h> #include <vis.h> +#define MINIMUM(a, b) (((a) < (b)) ? (a) : (b)) + extern FILE *zopen(const char *fname, const char *mode, int bits); #define KREAD(kd, addr, p)\ @@ -373,7 +375,7 @@ save_core(void) { FILE *fp; int bounds, ifd, nr, nw, ofd = -1; - char *rawp, path[MAXPATHLEN]; + char *rawp, path[PATH_MAX]; mode_t um; um = umask(S_IRWXG|S_IRWXO); @@ -439,7 +441,7 @@ err1: syslog(LOG_WARNING, "%s: %s", path, strerror(errno)); for (; dumpsize != 0; dumpsize -= nr) { (void)printf("%8luK\r", dumpsize / 1024); (void)fflush(stdout); - nr = read(ifd, buf, MIN(dumpsize, sizeof(buf))); + nr = read(ifd, buf, MINIMUM(dumpsize, sizeof(buf))); if (nr <= 0) { if (nr == 0) syslog(LOG_WARNING, @@ -507,7 +509,7 @@ find_dev(dev_t dev, int type) DIR *dfd; struct dirent *dir; struct stat sb; - char *dp, devname[MAXPATHLEN]; + char *dp, devname[PATH_MAX]; if ((dfd = opendir(_PATH_DEV)) == NULL) { syslog(LOG_ERR, "%s: %s", _PATH_DEV, strerror(errno)); @@ -540,7 +542,7 @@ find_dev(dev_t dev, int type) char * rawname(char *s) { - char *sl, name[MAXPATHLEN]; + char *sl, name[PATH_MAX]; if ((sl = strrchr(s, '/')) == NULL || sl[1] == '0') { syslog(LOG_ERR, @@ -583,7 +585,7 @@ check_space(void) off_t minfree, spacefree, kernelsize, needed; struct stat st; struct statfs fsbuf; - char buf[100], path[MAXPATHLEN]; + char buf[100], path[PATH_MAX]; int fd; tkernel = kernel ? kernel : _PATH_UNIX; diff --git a/sbin/scan_ffs/scan_ffs.c b/sbin/scan_ffs/scan_ffs.c index b2e36f84a67..a4e85d9840b 100644 --- a/sbin/scan_ffs/scan_ffs.c +++ b/sbin/scan_ffs/scan_ffs.c @@ -1,4 +1,4 @@ -/* $OpenBSD: scan_ffs.c,v 1.17 2013/11/01 17:36:19 krw Exp $ */ +/* $OpenBSD: scan_ffs.c,v 1.18 2015/01/16 06:40:00 deraadt Exp $ */ /* * Copyright (c) 1998 Niklas Hallqvist, Tobias Weingartner @@ -25,8 +25,8 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#include <sys/param.h> /* MAXFRAG */ #include <sys/types.h> -#include <sys/param.h> #include <sys/fcntl.h> #include <ufs/ffs/fs.h> #include <unistd.h> @@ -34,6 +34,7 @@ #include <stdio.h> #include <string.h> #include <time.h> +#include <limits.h> #include <err.h> #include <util.h> diff --git a/sbin/shutdown/shutdown.c b/sbin/shutdown/shutdown.c index 98c42feecff..73e7d72cf52 100644 --- a/sbin/shutdown/shutdown.c +++ b/sbin/shutdown/shutdown.c @@ -1,4 +1,4 @@ -/* $OpenBSD: shutdown.c,v 1.37 2013/11/22 04:12:48 deraadt Exp $ */ +/* $OpenBSD: shutdown.c,v 1.38 2015/01/16 06:40:01 deraadt Exp $ */ /* $NetBSD: shutdown.c,v 1.9 1995/03/18 15:01:09 cgd Exp $ */ /* @@ -30,7 +30,7 @@ * SUCH DAMAGE. */ -#include <sys/param.h> +#include <sys/types.h> #include <sys/resource.h> #include <sys/syslog.h> #include <sys/types.h> @@ -48,6 +48,7 @@ #include <time.h> #include <tzfile.h> #include <unistd.h> +#include <limits.h> #include <errno.h> #include <err.h> @@ -273,8 +274,8 @@ static char *restricted_environ[] = { void timewarn(int timeleft) { - static char hostname[MAXHOSTNAMELEN]; - char wcmd[MAXPATHLEN + 4]; + static char hostname[HOST_NAME_MAX+1]; + char wcmd[PATH_MAX + 4]; extern char **environ; static int first; FILE *pf; diff --git a/sbin/swapctl/swapctl.c b/sbin/swapctl/swapctl.c index ddf693da592..0b561f2b483 100644 --- a/sbin/swapctl/swapctl.c +++ b/sbin/swapctl/swapctl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: swapctl.c,v 1.18 2010/12/29 12:14:41 stsp Exp $ */ +/* $OpenBSD: swapctl.c,v 1.19 2015/01/16 06:40:01 deraadt Exp $ */ /* $NetBSD: swapctl.c,v 1.9 1998/07/26 20:23:15 mycroft Exp $ */ /* @@ -50,9 +50,7 @@ * <dev> add this device */ -#include <sys/param.h> #include <sys/stat.h> - #include <sys/swap.h> #include <unistd.h> diff --git a/sbin/swapctl/swaplist.c b/sbin/swapctl/swaplist.c index 83280833268..cd0b008e12f 100644 --- a/sbin/swapctl/swaplist.c +++ b/sbin/swapctl/swaplist.c @@ -1,4 +1,4 @@ -/* $OpenBSD: swaplist.c,v 1.9 2014/08/10 05:00:25 guenther Exp $ */ +/* $OpenBSD: swaplist.c,v 1.10 2015/01/16 06:40:01 deraadt Exp $ */ /* $NetBSD: swaplist.c,v 1.8 1998/10/08 10:00:31 mrg Exp $ */ /* @@ -29,7 +29,8 @@ * SUCH DAMAGE. */ -#include <sys/param.h> +#include <sys/param.h> /* dbtob */ +#include <sys/types.h> #include <sys/swap.h> #include <err.h> diff --git a/sbin/sysctl/sysctl.c b/sbin/sysctl/sysctl.c index 0616c788217..df77bca0aea 100644 --- a/sbin/sysctl/sysctl.c +++ b/sbin/sysctl/sysctl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sysctl.c,v 1.207 2014/11/19 18:04:54 tedu Exp $ */ +/* $OpenBSD: sysctl.c,v 1.208 2015/01/16 06:40:01 deraadt Exp $ */ /* $NetBSD: sysctl.c,v 1.9 1995/09/30 07:12:50 thorpej Exp $ */ /* @@ -30,7 +30,7 @@ * SUCH DAMAGE. */ -#include <sys/param.h> +#include <sys/types.h> #include <sys/gmon.h> #include <sys/mount.h> #include <sys/sem.h> diff --git a/sbin/tunefs/tunefs.c b/sbin/tunefs/tunefs.c index 68df1a8548c..7cd601ff751 100644 --- a/sbin/tunefs/tunefs.c +++ b/sbin/tunefs/tunefs.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tunefs.c,v 1.34 2014/05/20 21:11:16 krw Exp $ */ +/* $OpenBSD: tunefs.c,v 1.35 2015/01/16 06:40:01 deraadt Exp $ */ /* $NetBSD: tunefs.c,v 1.33 2005/01/19 20:46:16 xtraeme Exp $ */ /* @@ -33,7 +33,7 @@ /* * tunefs: change layout parameters to an existing file system. */ -#include <sys/param.h> +#include <sys/param.h> /* DEV_BSIZE MAXBSIZE MAXFRAG */ #include <ufs/ufs/dinode.h> #include <ufs/ffs/fs.h> @@ -48,6 +48,7 @@ #include <stdlib.h> #include <string.h> #include <unistd.h> +#include <limits.h> #include <util.h> /* the optimization warning string template */ @@ -308,7 +309,7 @@ bread(daddr_t blk, char *buffer, int cnt, const char *file) static int openpartition(char *name, int flags, char **devicep) { - char rawspec[MAXPATHLEN], *p; + char rawspec[PATH_MAX], *p; struct fstab *fs; int fd; diff --git a/sbin/umount/umount.c b/sbin/umount/umount.c index 2ba169ca7d5..5278ecfd834 100644 --- a/sbin/umount/umount.c +++ b/sbin/umount/umount.c @@ -1,4 +1,4 @@ -/* $OpenBSD: umount.c,v 1.25 2014/02/21 19:00:01 deraadt Exp $ */ +/* $OpenBSD: umount.c,v 1.26 2015/01/16 06:40:01 deraadt Exp $ */ /* $NetBSD: umount.c,v 1.16 1996/05/11 14:13:55 mycroft Exp $ */ /*- @@ -30,7 +30,6 @@ * SUCH DAMAGE. */ -#include <sys/param.h> #include <sys/stat.h> #include <sys/mount.h> #include <sys/time.h> @@ -48,6 +47,7 @@ #include <stdlib.h> #include <string.h> #include <unistd.h> +#include <limits.h> #include <util.h> typedef enum { MNTON, MNTFROM } mntwhat; @@ -151,7 +151,7 @@ umountfs(char *oname) CLIENT *clp; int so; char *delimp, *hostp, *mntpt; - char *name, *newname, rname[MAXPATHLEN], type[MFSNAMELEN]; + char *name, *newname, rname[PATH_MAX], type[MFSNAMELEN]; if (isduid(oname, 0) || realpath(oname, rname) == NULL) mntpt = name = oname; diff --git a/usr.bin/arch/arch.c b/usr.bin/arch/arch.c index e0e5ad13784..2b5a3fe584e 100644 --- a/usr.bin/arch/arch.c +++ b/usr.bin/arch/arch.c @@ -23,7 +23,7 @@ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include <sys/param.h> +#include <sys/param.h> /* MACHINE MACHINE_ARCH */ #include <err.h> #include <locale.h> diff --git a/usr.bin/aucat/aparams.c b/usr.bin/aucat/aparams.c index 8202aacde1c..7fe727ec9ac 100644 --- a/usr.bin/aucat/aparams.c +++ b/usr.bin/aucat/aparams.c @@ -1,4 +1,4 @@ -/* $OpenBSD: aparams.c,v 1.14 2012/04/11 06:05:43 ratchov Exp $ */ +/* $OpenBSD: aparams.c,v 1.15 2015/01/16 06:40:05 deraadt Exp $ */ /* * Copyright (c) 2008 Alexandre Ratchov <alex@caoua.org> * @@ -15,6 +15,8 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#include <endian.h> + #include "aparams.h" #ifdef DEBUG #include "dbg.h" diff --git a/usr.bin/aucat/aparams.h b/usr.bin/aucat/aparams.h index 3cbaf1a383b..c9c59b81862 100644 --- a/usr.bin/aucat/aparams.h +++ b/usr.bin/aucat/aparams.h @@ -1,4 +1,4 @@ -/* $OpenBSD: aparams.h,v 1.12 2012/04/11 06:05:43 ratchov Exp $ */ +/* $OpenBSD: aparams.h,v 1.13 2015/01/16 06:40:05 deraadt Exp $ */ /* * Copyright (c) 2008 Alexandre Ratchov <alex@caoua.org> * @@ -17,8 +17,6 @@ #ifndef APARAMS_H #define APARAMS_H -#include <sys/param.h> - #define NCHAN_MAX 16 /* max channel in a stream */ #define RATE_MIN 4000 /* min sample rate */ #define RATE_MAX 192000 /* max sample rate */ diff --git a/usr.bin/aucat/aucat.c b/usr.bin/aucat/aucat.c index df6ee65b2be..ea3a78816b3 100644 --- a/usr.bin/aucat/aucat.c +++ b/usr.bin/aucat/aucat.c @@ -1,4 +1,4 @@ -/* $OpenBSD: aucat.c,v 1.144 2013/11/18 17:51:59 ratchov Exp $ */ +/* $OpenBSD: aucat.c,v 1.145 2015/01/16 06:40:05 deraadt Exp $ */ /* * Copyright (c) 2008 Alexandre Ratchov <alex@caoua.org> * @@ -14,7 +14,7 @@ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#include <sys/param.h> + #include <sys/queue.h> #include <sys/stat.h> #include <sys/types.h> diff --git a/usr.bin/aucat/headers.c b/usr.bin/aucat/headers.c index 5a338a87b6b..b69e1c539a1 100644 --- a/usr.bin/aucat/headers.c +++ b/usr.bin/aucat/headers.c @@ -1,4 +1,4 @@ -/* $OpenBSD: headers.c,v 1.23 2013/11/18 17:37:45 ratchov Exp $ */ +/* $OpenBSD: headers.c,v 1.24 2015/01/16 06:40:05 deraadt Exp $ */ /* * Copyright (c) 2008 Alexandre Ratchov <alex@caoua.org> * @@ -15,8 +15,6 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#include <sys/param.h> - #include <err.h> #include <stdio.h> #include <stdint.h> diff --git a/usr.bin/bgplg/bgplg.c b/usr.bin/bgplg/bgplg.c index 5b92bdd6b17..89536ce66fa 100644 --- a/usr.bin/bgplg/bgplg.c +++ b/usr.bin/bgplg/bgplg.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bgplg.c,v 1.12 2013/11/25 18:02:50 deraadt Exp $ */ +/* $OpenBSD: bgplg.c,v 1.13 2015/01/16 06:40:06 deraadt Exp $ */ /* * Copyright (c) 2005, 2006 Reyk Floeter <reyk@openbsd.org> @@ -16,15 +16,15 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#include <sys/stat.h> #include <sys/types.h> -#include <sys/param.h> +#include <sys/stat.h> #include <stdio.h> #include <stdlib.h> #include <signal.h> #include <string.h> #include <unistd.h> +#include <limits.h> #include <ctype.h> #include <errno.h> #include <fcntl.h> @@ -247,7 +247,7 @@ main(void) { char *query, *self, *cmd = NULL, *req; char **argv = NULL; - char myname[MAXHOSTNAMELEN]; + char myname[HOST_NAME_MAX+1]; int ret = 1, argc = 0, query_length = 0; struct stat st; u_int i; diff --git a/usr.bin/bgplg/bgplgsh.c b/usr.bin/bgplg/bgplgsh.c index 85f27fbe552..22b34e9cb9a 100644 --- a/usr.bin/bgplg/bgplgsh.c +++ b/usr.bin/bgplg/bgplgsh.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bgplgsh.c,v 1.6 2013/11/25 18:02:50 deraadt Exp $ */ +/* $OpenBSD: bgplgsh.c,v 1.7 2015/01/16 06:40:06 deraadt Exp $ */ /* * Copyright (c) 2005, 2006 Reyk Floeter <reyk@openbsd.org> @@ -16,15 +16,15 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#include <sys/stat.h> #include <sys/types.h> -#include <sys/param.h> +#include <sys/stat.h> #include <stdio.h> #include <stdlib.h> #include <signal.h> #include <string.h> #include <unistd.h> +#include <limits.h> #include <ctype.h> #include <errno.h> #include <fcntl.h> @@ -215,7 +215,7 @@ int main(void) { struct cmd *cmd = NULL; - char prompt[MAXHOSTNAMELEN], *line, **argp = NULL; + char prompt[HOST_NAME_MAX+1], *line, **argp = NULL; int ncmd, ret, v = -1; u_int i; diff --git a/usr.bin/calendar/io.c b/usr.bin/calendar/io.c index 1d6ef58c8cf..31c413bb7db 100644 --- a/usr.bin/calendar/io.c +++ b/usr.bin/calendar/io.c @@ -1,4 +1,4 @@ -/* $OpenBSD: io.c,v 1.36 2013/11/26 13:18:53 deraadt Exp $ */ +/* $OpenBSD: io.c,v 1.37 2015/01/16 06:40:06 deraadt Exp $ */ /* * Copyright (c) 1989, 1993, 1994 @@ -29,7 +29,6 @@ * SUCH DAMAGE. */ -#include <sys/param.h> #include <sys/stat.h> #include <sys/time.h> #include <sys/types.h> @@ -47,6 +46,7 @@ #include <string.h> #include <tzfile.h> #include <unistd.h> +#include <limits.h> #include "pathnames.h" #include "calendar.h" diff --git a/usr.bin/cap_mkdb/cap_mkdb.c b/usr.bin/cap_mkdb/cap_mkdb.c index 1450a36ba17..7e9535ba1e3 100644 --- a/usr.bin/cap_mkdb/cap_mkdb.c +++ b/usr.bin/cap_mkdb/cap_mkdb.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cap_mkdb.c,v 1.18 2011/07/04 21:34:54 nicm Exp $ */ +/* $OpenBSD: cap_mkdb.c,v 1.19 2015/01/16 06:40:06 deraadt Exp $ */ /* $NetBSD: cap_mkdb.c,v 1.5 1995/09/02 05:47:12 jtc Exp $ */ /*- @@ -30,7 +30,6 @@ * SUCH DAMAGE. */ -#include <sys/param.h> #include <sys/stat.h> #include <db.h> @@ -44,6 +43,9 @@ #include <ctype.h> #include <unistd.h> +#define MINIMUM(a, b) (((a) < (b)) ? (a) : (b)) +#define MAXIMUM(a, b) (((a) > (b)) ? (a) : (b)) + void db_build(char **); void dounlink(void); void usage(void); @@ -162,7 +164,7 @@ db_build(char **ifiles) */ len = strlen(bp); if (bplen <= 4 * len + 2) { - int newbplen = bplen + MAX(256, 4 * len + 2); + int newbplen = bplen + MAXIMUM(256, 4 * len + 2); void *newdata; if ((newdata = realloc(data.data, newbplen)) == NULL) @@ -173,7 +175,7 @@ db_build(char **ifiles) /* Find the end of the name field. */ if ((p = strchr(bp, info ? ',' : ':')) == NULL) { - warnx("no name field: %.*s", (int)MIN(len, 20), bp); + warnx("no name field: %.*s", (int)MINIMUM(len, 20), bp); continue; } @@ -221,7 +223,7 @@ db_build(char **ifiles) } *out++ = '\0'; if (memchr((char *)data.data + 1, '\0', data.size - 2)) { - warnx("NUL in entry: %.*s", (int)MIN(len, 20), bp); + warnx("NUL in entry: %.*s", (int)MINIMUM(len, 20), bp); continue; } } else { diff --git a/usr.bin/cdio/cddb.c b/usr.bin/cdio/cddb.c index bc3e010aab7..c5ae468db5a 100644 --- a/usr.bin/cdio/cddb.c +++ b/usr.bin/cdio/cddb.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cddb.c,v 1.19 2014/01/06 12:38:10 espie Exp $ */ +/* $OpenBSD: cddb.c,v 1.20 2015/01/16 06:40:06 deraadt Exp $ */ /* * Copyright (c) 2002 Marc Espie. * @@ -24,7 +24,6 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include <sys/param.h> #include <sys/socket.h> #include <netinet/in.h> #include <sys/cdio.h> @@ -34,6 +33,7 @@ #include <stdlib.h> #include <string.h> #include <unistd.h> +#include <limits.h> #include <vis.h> #include "extern.h" @@ -76,7 +76,7 @@ cddb_discid(int n, struct cd_toc_entry *e) void send_hello(FILE *cout) { - char hostname[MAXHOSTNAMELEN]; + char hostname[HOST_NAME_MAX+1]; if (gethostname(hostname, sizeof(hostname)) == -1) strlcpy(hostname, "unknown", sizeof hostname); diff --git a/usr.bin/cdio/cdio.c b/usr.bin/cdio/cdio.c index 4be37621b16..0177630da6e 100644 --- a/usr.bin/cdio/cdio.c +++ b/usr.bin/cdio/cdio.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cdio.c,v 1.73 2013/11/20 20:54:34 deraadt Exp $ */ +/* $OpenBSD: cdio.c,v 1.74 2015/01/16 06:40:06 deraadt Exp $ */ /* Copyright (c) 1995 Serge V. Vakulenko * All rights reserved. @@ -52,7 +52,7 @@ * $FreeBSD: cdcontrol.c,v 1.13 1996/06/25 21:01:27 ache Exp $ */ -#include <sys/param.h> +#include <sys/param.h> /* isset */ #include <sys/file.h> #include <sys/cdio.h> #include <sys/ioctl.h> @@ -67,6 +67,7 @@ #include <stdlib.h> #include <string.h> #include <unistd.h> +#include <limits.h> #include <histedit.h> #include <util.h> #include <vis.h> @@ -319,7 +320,7 @@ int run(int cmd, char *arg) { int l, r, rc; - static char newcdname[MAXPATHLEN]; + static char newcdname[PATH_MAX]; switch (cmd) { diff --git a/usr.bin/cdio/mmc.c b/usr.bin/cdio/mmc.c index d34f86f44f7..2866d805064 100644 --- a/usr.bin/cdio/mmc.c +++ b/usr.bin/cdio/mmc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mmc.c,v 1.29 2013/11/12 17:57:34 deraadt Exp $ */ +/* $OpenBSD: mmc.c,v 1.30 2015/01/16 06:40:06 deraadt Exp $ */ /* * Copyright (c) 2006 Michael Coulter <mjc@openbsd.org> * @@ -18,7 +18,7 @@ #include <sys/limits.h> #include <sys/types.h> #include <sys/scsiio.h> -#include <sys/param.h> +#include <sys/param.h> /* setbit, isset */ #include <scsi/cd.h> #include <scsi/scsi_all.h> #include <scsi/scsi_disk.h> diff --git a/usr.bin/chpass/chpass.c b/usr.bin/chpass/chpass.c index 8fed8c4190a..f506ed59e5d 100644 --- a/usr.bin/chpass/chpass.c +++ b/usr.bin/chpass/chpass.c @@ -1,4 +1,4 @@ -/* $OpenBSD: chpass.c,v 1.40 2014/10/26 20:38:13 guenther Exp $ */ +/* $OpenBSD: chpass.c,v 1.41 2015/01/16 06:40:06 deraadt Exp $ */ /* $NetBSD: chpass.c,v 1.8 1996/05/15 21:50:43 jtc Exp $ */ /*- @@ -30,7 +30,6 @@ * SUCH DAMAGE. */ -#include <sys/param.h> #include <sys/resource.h> #include <sys/stat.h> #include <sys/time.h> diff --git a/usr.bin/chpass/edit.c b/usr.bin/chpass/edit.c index 2590d4c42d1..b75a47efa8a 100644 --- a/usr.bin/chpass/edit.c +++ b/usr.bin/chpass/edit.c @@ -1,4 +1,4 @@ -/* $OpenBSD: edit.c,v 1.34 2013/11/26 13:18:55 deraadt Exp $ */ +/* $OpenBSD: edit.c,v 1.35 2015/01/16 06:40:06 deraadt Exp $ */ /* $NetBSD: edit.c,v 1.6 1996/05/15 21:50:45 jtc Exp $ */ /*- @@ -30,7 +30,6 @@ * SUCH DAMAGE. */ -#include <sys/param.h> #include <sys/stat.h> #include <ctype.h> @@ -43,6 +42,7 @@ #include <stdlib.h> #include <string.h> #include <unistd.h> +#include <limits.h> #include <util.h> #include "chpass.h" diff --git a/usr.bin/chpass/field.c b/usr.bin/chpass/field.c index b48c7951e5a..90d98032e5e 100644 --- a/usr.bin/chpass/field.c +++ b/usr.bin/chpass/field.c @@ -1,4 +1,4 @@ -/* $OpenBSD: field.c,v 1.13 2013/11/26 13:18:55 deraadt Exp $ */ +/* $OpenBSD: field.c,v 1.14 2015/01/16 06:40:06 deraadt Exp $ */ /* $NetBSD: field.c,v 1.3 1995/03/26 04:55:28 glass Exp $ */ /* @@ -30,8 +30,6 @@ * SUCH DAMAGE. */ -#include <sys/param.h> - #include <ctype.h> #include <err.h> #include <errno.h> @@ -42,6 +40,7 @@ #include <stdlib.h> #include <string.h> #include <unistd.h> +#include <limits.h> #include "chpass.h" diff --git a/usr.bin/cmp/regular.c b/usr.bin/cmp/regular.c index 95ebc1bbbe0..f95f64e1e2b 100644 --- a/usr.bin/cmp/regular.c +++ b/usr.bin/cmp/regular.c @@ -1,4 +1,4 @@ -/* $OpenBSD: regular.c,v 1.10 2011/01/19 13:01:25 okan Exp $ */ +/* $OpenBSD: regular.c,v 1.11 2015/01/16 06:40:06 deraadt Exp $ */ /* $NetBSD: regular.c,v 1.2 1995/09/08 03:22:59 tls Exp $ */ /*- @@ -30,7 +30,6 @@ * SUCH DAMAGE. */ -#include <sys/param.h> #include <sys/mman.h> #include <sys/stat.h> @@ -42,6 +41,8 @@ #include "extern.h" +#define MINIMUM(a, b) (((a) < (b)) ? (a) : (b)) + void c_regular(int fd1, char *file1, off_t skip1, off_t len1, int fd2, char *file2, off_t skip2, off_t len2) @@ -60,7 +61,7 @@ c_regular(int fd1, char *file1, off_t skip1, off_t len1, eofmsg(file2); len2 -= skip2; - length = MIN(len1, len2); + length = MINIMUM(len1, len2); if (length > SIZE_T_MAX) { mmap_failed: c_special(fd1, file1, skip1, fd2, file2, skip2); diff --git a/usr.bin/compress/gzopen.c b/usr.bin/compress/gzopen.c index 2fe33b55db3..dd239534a5c 100644 --- a/usr.bin/compress/gzopen.c +++ b/usr.bin/compress/gzopen.c @@ -1,4 +1,4 @@ -/* $OpenBSD: gzopen.c,v 1.27 2011/09/22 10:41:04 deraadt Exp $ */ +/* $OpenBSD: gzopen.c,v 1.28 2015/01/16 06:40:06 deraadt Exp $ */ /* * Copyright (c) 1997 Michael Shalayeff @@ -58,7 +58,6 @@ (zlib format), rfc1951.txt (deflate format) and rfc1952.txt (gzip format). */ -#include <sys/param.h> #include <sys/stat.h> #include <sys/uio.h> #include <stdio.h> @@ -66,6 +65,7 @@ #include <string.h> #include <errno.h> #include <unistd.h> +#include <limits.h> #include <zlib.h> #include "compress.h" @@ -348,7 +348,7 @@ get_header(gz_stream *s, char *name, int gotmagic) if ((flags & ORIG_NAME) != 0) { /* read/save the original file name */ if ((ep = name) != NULL) - ep += MAXPATHLEN - 1; + ep += PATH_MAX - 1; while ((c = get_byte(s)) != EOF) { s->z_hlen++; if (c == '\0') diff --git a/usr.bin/compress/main.c b/usr.bin/compress/main.c index 493b62c31ba..c9e302598ff 100644 --- a/usr.bin/compress/main.c +++ b/usr.bin/compress/main.c @@ -1,4 +1,4 @@ -/* $OpenBSD: main.c,v 1.82 2014/10/08 03:59:11 doug Exp $ */ +/* $OpenBSD: main.c,v 1.83 2015/01/16 06:40:06 deraadt Exp $ */ /* * Copyright (c) 1992, 1993 @@ -30,7 +30,6 @@ * THE POSSIBILITY OF SUCH DAMAGE. */ -#include <sys/param.h> #include <sys/time.h> #include <sys/stat.h> @@ -44,6 +43,7 @@ #include <stdbool.h> #include <string.h> #include <unistd.h> +#include <limits.h> #include <fcntl.h> #include <paths.h> #include "compress.h" @@ -164,7 +164,7 @@ main(int argc, char *argv[]) const struct compressor *method; const char *optstr, *s; char *p, *infile; - char outfile[MAXPATHLEN], _infile[MAXPATHLEN], suffix[16]; + char outfile[PATH_MAX], _infile[PATH_MAX], suffix[16]; int bits, ch, error, rc, cflag, oflag; bits = cflag = oflag = 0; @@ -613,7 +613,7 @@ dodecompress(const char *in, char *out, const struct compressor *method, int bits, struct stat *sb) { u_char buf[Z_BUFSIZE]; - char oldname[MAXPATHLEN]; + char oldname[PATH_MAX]; int error, oreg, ifd, ofd; void *cookie; ssize_t nr; @@ -661,9 +661,9 @@ dodecompress(const char *in, char *out, const struct compressor *method, char *cp = strrchr(out, '/'); if (cp != NULL) { *(cp + 1) = '\0'; - strlcat(out, oldname, MAXPATHLEN); + strlcat(out, oldname, PATH_MAX); } else - strlcpy(out, oldname, MAXPATHLEN); + strlcpy(out, oldname, PATH_MAX); cat = 0; /* XXX should -c override? */ } diff --git a/usr.bin/compress/zopen.c b/usr.bin/compress/zopen.c index 12de049e712..919cc77eb0c 100644 --- a/usr.bin/compress/zopen.c +++ b/usr.bin/compress/zopen.c @@ -1,4 +1,4 @@ -/* $OpenBSD: zopen.c,v 1.18 2011/09/22 10:41:04 deraadt Exp $ */ +/* $OpenBSD: zopen.c,v 1.19 2015/01/16 06:40:06 deraadt Exp $ */ /* $NetBSD: zopen.c,v 1.5 1995/03/26 09:44:53 glass Exp $ */ /*- @@ -58,7 +58,6 @@ * Any file produced by compress(1) can be read. */ -#include <sys/param.h> #include <sys/stat.h> #include <ctype.h> @@ -71,6 +70,8 @@ #include <fcntl.h> #include "compress.h" +#define MINIMUM(a, b) (((a) < (b)) ? (a) : (b)) + #define BITS 16 /* Default bits. */ #define HSIZE 69001 /* 95% occupancy */ #define ZBUFSIZ 8192 /* I/O buffer size */ @@ -636,7 +637,7 @@ getcode(struct s_zstate *zs) zs->zs_ebp = bp + bits; } zs->zs_offset = 0; - zs->zs_size = MIN(zs->zs_n_bits, zs->zs_ebp - zs->zs_bp); + zs->zs_size = MINIMUM(zs->zs_n_bits, zs->zs_ebp - zs->zs_bp); if (zs->zs_size == 0) return -1; /* Round size down to integral number of codes. */ diff --git a/usr.bin/cu/cu.c b/usr.bin/cu/cu.c index 146025181f5..99a9b057430 100644 --- a/usr.bin/cu/cu.c +++ b/usr.bin/cu/cu.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cu.c,v 1.19 2014/04/12 12:47:43 nicm Exp $ */ +/* $OpenBSD: cu.c,v 1.20 2015/01/16 06:40:06 deraadt Exp $ */ /* * Copyright (c) 2012 Nicholas Marriott <nicm@openbsd.org> @@ -16,7 +16,6 @@ * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#include <sys/param.h> #include <sys/ioctl.h> #include <ctype.h> @@ -32,6 +31,7 @@ #include <string.h> #include <termios.h> #include <unistd.h> +#include <limits.h> #include "cu.h" @@ -391,7 +391,7 @@ tilde_expand(const char *filename1) if ((rv = asprintf(&out, "%s%s%s", pw->pw_dir, sep, filename)) == -1) cu_err(1, "asprintf"); - if (rv >= MAXPATHLEN) { + if (rv >= PATH_MAX) { free(out); goto no_change; } diff --git a/usr.bin/cvs/add.c b/usr.bin/cvs/add.c index 46cde4557dc..e744b05f797 100644 --- a/usr.bin/cvs/add.c +++ b/usr.bin/cvs/add.c @@ -1,4 +1,4 @@ -/* $OpenBSD: add.c,v 1.110 2010/11/11 21:00:59 nicm Exp $ */ +/* $OpenBSD: add.c,v 1.111 2015/01/16 06:40:06 deraadt Exp $ */ /* * Copyright (c) 2006 Joris Vink <joris@openbsd.org> * Copyright (c) 2005, 2006 Xavier Santolaria <xsa@openbsd.org> @@ -180,14 +180,14 @@ cvs_add_local(struct cvs_file *cf) void cvs_add_remote(struct cvs_file *cf) { - char path[MAXPATHLEN]; + char path[PATH_MAX]; cvs_log(LP_TRACE, "cvs_add_remote(%s)", cf->file_path); cvs_file_classify(cf, cvs_directory_tag); if (cf->file_type == CVS_DIR) { - cvs_get_repository_path(cf->file_wd, path, MAXPATHLEN); + cvs_get_repository_path(cf->file_wd, path, PATH_MAX); if (strlcat(path, "/", sizeof(path)) >= sizeof(path)) fatal("cvs_add_remote: truncation"); if (strlcat(path, cf->file_path, sizeof(path)) >= sizeof(path)) @@ -205,7 +205,7 @@ void cvs_add_loginfo(char *repo) { BUF *buf; - char pwd[MAXPATHLEN]; + char pwd[PATH_MAX]; if (getcwd(pwd, sizeof(pwd)) == NULL) fatal("Can't get working directory"); @@ -229,7 +229,7 @@ void cvs_add_tobranch(struct cvs_file *cf, char *tag) { BUF *bp; - char attic[MAXPATHLEN], repo[MAXPATHLEN]; + char attic[PATH_MAX], repo[PATH_MAX]; char *msg; struct stat st; RCSNUM *branch; @@ -242,14 +242,14 @@ cvs_add_tobranch(struct cvs_file *cf, char *tag) if (fstat(cf->fd, &st) == -1) fatal("cvs_add_tobranch: %s", strerror(errno)); - cvs_get_repository_path(cf->file_wd, repo, MAXPATHLEN); - (void)xsnprintf(attic, MAXPATHLEN, "%s/%s", + cvs_get_repository_path(cf->file_wd, repo, PATH_MAX); + (void)xsnprintf(attic, PATH_MAX, "%s/%s", repo, CVS_PATH_ATTIC); if (mkdir(attic, 0755) == -1 && errno != EEXIST) fatal("cvs_add_tobranch: failed to create Attic"); - (void)xsnprintf(attic, MAXPATHLEN, "%s/%s/%s%s", repo, + (void)xsnprintf(attic, PATH_MAX, "%s/%s/%s%s", repo, CVS_PATH_ATTIC, cf->file_name, RCS_FILE_EXT); xfree(cf->file_rpath); @@ -301,14 +301,14 @@ add_directory(struct cvs_file *cf) int added, nb; struct stat st; CVSENTRIES *entlist; - char *date, entry[MAXPATHLEN], msg[1024], repo[MAXPATHLEN], *tag, *p; + char *date, entry[PATH_MAX], msg[1024], repo[PATH_MAX], *tag, *p; struct file_info_list files_info; struct file_info *fi; struct trigger_list *line_list; cvs_log(LP_TRACE, "add_directory(%s)", cf->file_path); - (void)xsnprintf(entry, MAXPATHLEN, "%s%s", + (void)xsnprintf(entry, PATH_MAX, "%s%s", cf->file_rpath, RCS_FILE_EXT); added = 1; @@ -321,7 +321,7 @@ add_directory(struct cvs_file *cf) /* Let's see if we have any per-directory tags first. */ cvs_parse_tagfile(cf->file_wd, &tag, &date, &nb); - (void)xsnprintf(entry, MAXPATHLEN, "%s/%s", + (void)xsnprintf(entry, PATH_MAX, "%s/%s", cf->file_path, CVS_PATH_CVSDIR); if (cvs_server_active) { @@ -345,9 +345,9 @@ add_directory(struct cvs_file *cf) strerror(errno)); cvs_get_repository_name(cf->file_wd, repo, - MAXPATHLEN); + PATH_MAX); - (void)xsnprintf(entry, MAXPATHLEN, "%s/%s", + (void)xsnprintf(entry, PATH_MAX, "%s/%s", repo, cf->file_name); cvs_mkadmin(cf->file_path, current_cvsroot->cr_dir, @@ -386,7 +386,7 @@ add_directory(struct cvs_file *cf) if (date != NULL) xfree(date); - cvs_get_repository_name(cf->file_path, repo, MAXPATHLEN); + cvs_get_repository_name(cf->file_path, repo, PATH_MAX); line_list = cvs_trigger_getlines(CVS_PATH_LOGINFO, repo); if (line_list != NULL) { TAILQ_INIT(&files_info); @@ -500,7 +500,7 @@ static void add_entry(struct cvs_file *cf) { FILE *fp; - char *entry, path[MAXPATHLEN]; + char *entry, path[PATH_MAX]; char revbuf[CVS_REV_BUFSZ], tbuf[CVS_TIME_BUFSZ]; char sticky[CVS_ENT_MAXLINELEN]; CVSENTRIES *entlist; @@ -527,7 +527,7 @@ add_entry(struct cvs_file *cf) 0, 0, entry, CVS_ENT_MAXLINELEN); } else { if (logmsg != NULL) { - (void)xsnprintf(path, MAXPATHLEN, "%s/%s/%s%s", + (void)xsnprintf(path, PATH_MAX, "%s/%s/%s%s", cf->file_wd, CVS_PATH_CVSDIR, cf->file_name, CVS_DESCR_FILE_EXT); diff --git a/usr.bin/cvs/admin.c b/usr.bin/cvs/admin.c index 97269b52b19..6a3120df20b 100644 --- a/usr.bin/cvs/admin.c +++ b/usr.bin/cvs/admin.c @@ -1,4 +1,4 @@ -/* $OpenBSD: admin.c,v 1.64 2008/09/12 13:20:36 tobias Exp $ */ +/* $OpenBSD: admin.c,v 1.65 2015/01/16 06:40:06 deraadt Exp $ */ /* * Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org> * Copyright (c) 2005 Joris Vink <joris@openbsd.org> @@ -17,7 +17,7 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#include <sys/param.h> +#include <sys/types.h> #include <sys/dirent.h> #include <errno.h> @@ -245,7 +245,7 @@ cvs_admin_local(struct cvs_file *cf) struct cvs_file *ocf; struct rcs_access *acp; int ofd; - char *d, *f, fpath[MAXPATHLEN], repo[MAXPATHLEN]; + char *d, *f, fpath[PATH_MAX], repo[PATH_MAX]; if ((f = basename(oldfilename)) == NULL) @@ -253,11 +253,11 @@ cvs_admin_local(struct cvs_file *cf) if ((d = dirname(oldfilename)) == NULL) fatal("cvs_admin_local: dirname failed"); - cvs_get_repository_path(d, repo, MAXPATHLEN); + cvs_get_repository_path(d, repo, PATH_MAX); - (void)xsnprintf(fpath, MAXPATHLEN, "%s/%s", repo, f); + (void)xsnprintf(fpath, PATH_MAX, "%s/%s", repo, f); - if (strlcat(fpath, RCS_FILE_EXT, MAXPATHLEN) >= MAXPATHLEN) + if (strlcat(fpath, RCS_FILE_EXT, PATH_MAX) >= PATH_MAX) fatal("cvs_admin_local: truncation"); if ((ofd = open(fpath, O_RDONLY)) == -1) diff --git a/usr.bin/cvs/annotate.c b/usr.bin/cvs/annotate.c index f00ecc1fb12..8aaa8b3a3e5 100644 --- a/usr.bin/cvs/annotate.c +++ b/usr.bin/cvs/annotate.c @@ -1,4 +1,4 @@ -/* $OpenBSD: annotate.c,v 1.63 2011/12/27 13:59:01 nicm Exp $ */ +/* $OpenBSD: annotate.c,v 1.64 2015/01/16 06:40:06 deraadt Exp $ */ /* * Copyright (c) 2007 Tobias Stoeckmann <tobias@openbsd.org> * Copyright (c) 2006 Xavier Santolaria <xsa@openbsd.org> @@ -16,7 +16,7 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#include <sys/param.h> +#include <sys/types.h> #include <sys/dirent.h> #include <errno.h> diff --git a/usr.bin/cvs/atomicio.c b/usr.bin/cvs/atomicio.c index d872cbf4711..f05bfdb4d18 100644 --- a/usr.bin/cvs/atomicio.c +++ b/usr.bin/cvs/atomicio.c @@ -1,4 +1,4 @@ -/* $OpenBSD: atomicio.c,v 1.1 2007/09/17 10:07:21 tobias Exp $ */ +/* $OpenBSD: atomicio.c,v 1.2 2015/01/16 06:40:06 deraadt Exp $ */ /* * Copyright (c) 2006 Damien Miller. All rights reserved. * Copyright (c) 2005 Anil Madhavapeddy. All rights reserved. @@ -26,7 +26,7 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include <sys/param.h> +#include <sys/types.h> #include <errno.h> #include <poll.h> diff --git a/usr.bin/cvs/checkout.c b/usr.bin/cvs/checkout.c index 24c922ede54..ea1a0ddd0d3 100644 --- a/usr.bin/cvs/checkout.c +++ b/usr.bin/cvs/checkout.c @@ -1,4 +1,4 @@ -/* $OpenBSD: checkout.c,v 1.168 2011/12/27 13:59:01 nicm Exp $ */ +/* $OpenBSD: checkout.c,v 1.169 2015/01/16 06:40:06 deraadt Exp $ */ /* * Copyright (c) 2006 Joris Vink <joris@openbsd.org> * @@ -15,7 +15,7 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#include <sys/param.h> +#include <sys/types.h> #include <sys/dirent.h> #include <sys/stat.h> #include <sys/time.h> @@ -239,7 +239,7 @@ checkout_check_repository(int argc, char **argv) struct module_checkout *mc; struct cvs_ignpat *ip; struct cvs_filelist *fl, *nxt; - char repo[MAXPATHLEN], fpath[MAXPATHLEN], *f[1]; + char repo[PATH_MAX], fpath[PATH_MAX], *f[1]; build_dirs = print_stdout ? 0 : 1; @@ -388,7 +388,7 @@ checkout_check_repository(int argc, char **argv) static int checkout_classify(const char *repo, const char *arg) { - char *d, *f, fpath[MAXPATHLEN]; + char *d, *f, fpath[PATH_MAX]; struct stat sb; if (stat(repo, &sb) == 0) { @@ -477,7 +477,7 @@ cvs_checkout_file(struct cvs_file *cf, RCSNUM *rnum, char *tag, int co_flags) char *entry, *tosend; char kbuf[8], sticky[CVS_REV_BUFSZ], rev[CVS_REV_BUFSZ]; char timebuf[CVS_TIME_BUFSZ], tbuf[CVS_TIME_BUFSZ]; - static char lastwd[MAXPATHLEN]; + static char lastwd[PATH_MAX]; exists = 0; tosend = NULL; @@ -606,7 +606,7 @@ cvs_checkout_file(struct cvs_file *cf, RCSNUM *rnum, char *tag, int co_flags) */ if (tag != NULL && strcmp(cf->file_wd, lastwd) && !(cf->file_flags & FILE_USER_SUPPLIED)) { - strlcpy(lastwd, cf->file_wd, MAXPATHLEN); + strlcpy(lastwd, cf->file_wd, PATH_MAX); cvs_server_set_sticky(cf->file_wd, sticky); } diff --git a/usr.bin/cvs/client.c b/usr.bin/cvs/client.c index ba9184b5816..ca137abcff9 100644 --- a/usr.bin/cvs/client.c +++ b/usr.bin/cvs/client.c @@ -1,4 +1,4 @@ -/* $OpenBSD: client.c,v 1.123 2010/09/29 18:14:52 nicm Exp $ */ +/* $OpenBSD: client.c,v 1.124 2015/01/16 06:40:06 deraadt Exp $ */ /* * Copyright (c) 2006 Joris Vink <joris@openbsd.org> * @@ -15,7 +15,7 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#include <sys/param.h> +#include <sys/types.h> #include <sys/dirent.h> #include <sys/stat.h> #include <sys/time.h> @@ -399,19 +399,19 @@ cvs_client_senddir(const char *dir) { struct stat st; int nb; - char *d, *date, fpath[MAXPATHLEN], repo[MAXPATHLEN], *tag; + char *d, *date, fpath[PATH_MAX], repo[PATH_MAX], *tag; d = NULL; if (lastdir != NULL && !strcmp(dir, lastdir)) return; - cvs_get_repository_path(dir, repo, MAXPATHLEN); + cvs_get_repository_path(dir, repo, PATH_MAX); if (cvs_cmdop != CVS_OP_RLOG) cvs_client_send_request("Directory %s\n%s", dir, repo); - (void)xsnprintf(fpath, MAXPATHLEN, "%s/%s", + (void)xsnprintf(fpath, PATH_MAX, "%s/%s", dir, CVS_PATH_STATICENTRIES); if (stat(fpath, &st) == 0 && (st.st_mode & (S_IRUSR|S_IRGRP|S_IROTH))) @@ -700,10 +700,10 @@ cvs_client_updated(char *data) const char *errstr; struct tm datetm; struct timeval tv[2]; - char repo[MAXPATHLEN], *entry; + char repo[PATH_MAX], *entry; char timebuf[CVS_TIME_BUFSZ], revbuf[CVS_REV_BUFSZ]; char *en, *mode, *len, *rpath, *p; - char sticky[CVS_ENT_MAXLINELEN], fpath[MAXPATHLEN]; + char sticky[CVS_ENT_MAXLINELEN], fpath[PATH_MAX]; if (data == NULL) fatal("Missing argument for Updated"); @@ -714,7 +714,7 @@ cvs_client_updated(char *data) len = cvs_remote_input(); client_check_directory(data, rpath); - cvs_get_repository_path(".", repo, MAXPATHLEN); + cvs_get_repository_path(".", repo, PATH_MAX); STRIP_SLASH(repo); @@ -815,8 +815,8 @@ cvs_client_merged(char *data) client_check_directory(data, rpath); - repo = xmalloc(MAXPATHLEN); - cvs_get_repository_path(".", repo, MAXPATHLEN); + repo = xmalloc(PATH_MAX); + cvs_get_repository_path(".", repo, PATH_MAX); STRIP_SLASH(repo); @@ -872,7 +872,7 @@ void cvs_client_removed(char *data) { CVSENTRIES *entlist; - char *rpath, *filename, fpath[MAXPATHLEN]; + char *rpath, *filename, fpath[PATH_MAX]; if (data == NULL) fatal("Missing argument for Removed"); @@ -885,7 +885,7 @@ cvs_client_removed(char *data) entlist = cvs_ent_open(data); cvs_ent_remove(entlist, filename); - (void)xsnprintf(fpath, MAXPATHLEN, "%s/%s", data, filename); + (void)xsnprintf(fpath, PATH_MAX, "%s/%s", data, filename); (void)unlink(fpath); xfree(rpath); @@ -915,7 +915,7 @@ void cvs_client_set_static_directory(char *data) { FILE *fp; - char *dir, fpath[MAXPATHLEN]; + char *dir, fpath[PATH_MAX]; if (data == NULL) fatal("Missing argument for Set-static-directory"); @@ -928,7 +928,7 @@ cvs_client_set_static_directory(char *data) if (cvs_cmdop == CVS_OP_EXPORT) return; - (void)xsnprintf(fpath, MAXPATHLEN, "%s/%s", + (void)xsnprintf(fpath, PATH_MAX, "%s/%s", data, CVS_PATH_STATICENTRIES); if ((fp = fopen(fpath, "w+")) == NULL) { @@ -941,7 +941,7 @@ cvs_client_set_static_directory(char *data) void cvs_client_clear_static_directory(char *data) { - char *dir, fpath[MAXPATHLEN]; + char *dir, fpath[PATH_MAX]; if (data == NULL) fatal("Missing argument for Clear-static-directory"); @@ -954,7 +954,7 @@ cvs_client_clear_static_directory(char *data) if (cvs_cmdop == CVS_OP_EXPORT) return; - (void)xsnprintf(fpath, MAXPATHLEN, "%s/%s", + (void)xsnprintf(fpath, PATH_MAX, "%s/%s", data, CVS_PATH_STATICENTRIES); (void)cvs_unlink(fpath); @@ -964,7 +964,7 @@ void cvs_client_set_sticky(char *data) { FILE *fp; - char *dir, *tag, tagpath[MAXPATHLEN]; + char *dir, *tag, tagpath[PATH_MAX]; if (data == NULL) fatal("Missing argument for Set-sticky"); @@ -979,7 +979,7 @@ cvs_client_set_sticky(char *data) client_check_directory(data, dir); - (void)xsnprintf(tagpath, MAXPATHLEN, "%s/%s", data, CVS_PATH_TAG); + (void)xsnprintf(tagpath, PATH_MAX, "%s/%s", data, CVS_PATH_TAG); if ((fp = fopen(tagpath, "w+")) == NULL) { cvs_log(LP_ERRNO, "%s", tagpath); @@ -996,7 +996,7 @@ out: void cvs_client_clear_sticky(char *data) { - char *dir, tagpath[MAXPATHLEN]; + char *dir, tagpath[PATH_MAX]; if (data == NULL) fatal("Missing argument for Clear-sticky"); @@ -1012,7 +1012,7 @@ cvs_client_clear_sticky(char *data) client_check_directory(data, dir); - (void)xsnprintf(tagpath, MAXPATHLEN, "%s/%s", data, CVS_PATH_TAG); + (void)xsnprintf(tagpath, PATH_MAX, "%s/%s", data, CVS_PATH_TAG); (void)unlink(tagpath); xfree(dir); @@ -1031,8 +1031,8 @@ static void cvs_client_initlog(void) { u_int i; - char *env, *envdup, buf[MAXPATHLEN], fpath[MAXPATHLEN]; - char rpath[MAXPATHLEN], timebuf[CVS_TIME_BUFSZ], *s; + char *env, *envdup, buf[PATH_MAX], fpath[PATH_MAX]; + char rpath[PATH_MAX], timebuf[CVS_TIME_BUFSZ], *s; struct stat st; time_t now; struct passwd *pwd; diff --git a/usr.bin/cvs/cmd.c b/usr.bin/cvs/cmd.c index 94bf0b3950d..c4c5837fee2 100644 --- a/usr.bin/cvs/cmd.c +++ b/usr.bin/cvs/cmd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd.c,v 1.68 2008/02/03 18:18:44 tobias Exp $ */ +/* $OpenBSD: cmd.c,v 1.69 2015/01/16 06:40:07 deraadt Exp $ */ /* * Copyright (c) 2005 Joris Vink <joris@openbsd.org> * All rights reserved. @@ -23,7 +23,7 @@ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include <sys/param.h> +#include <sys/types.h> #include <sys/dirent.h> #include <string.h> diff --git a/usr.bin/cvs/commit.c b/usr.bin/cvs/commit.c index a1520984789..fe8d554f6f8 100644 --- a/usr.bin/cvs/commit.c +++ b/usr.bin/cvs/commit.c @@ -1,4 +1,4 @@ -/* $OpenBSD: commit.c,v 1.152 2011/12/27 13:59:01 nicm Exp $ */ +/* $OpenBSD: commit.c,v 1.153 2015/01/16 06:40:07 deraadt Exp $ */ /* * Copyright (c) 2006 Joris Vink <joris@openbsd.org> * Copyright (c) 2006 Xavier Santolaria <xsa@openbsd.org> @@ -68,7 +68,7 @@ cvs_commit(int argc, char **argv) struct cvs_recursion cr; struct cvs_filelist *l; struct file_info *fi; - char *arg = ".", repo[MAXPATHLEN]; + char *arg = ".", repo[PATH_MAX]; flags = CR_RECURSE_DIRS; Fflag = mflag = 0; @@ -160,7 +160,7 @@ cvs_commit(int argc, char **argv) cvs_client_send_request("ci"); cvs_client_get_responses(); } else { - cvs_get_repository_name(".", repo, MAXPATHLEN); + cvs_get_repository_name(".", repo, PATH_MAX); line_list = cvs_trigger_getlines(CVS_PATH_COMMITINFO, repo); if (line_list != NULL) { @@ -232,7 +232,7 @@ void cvs_commit_loginfo(char *repo) { BUF *buf; - char pwd[MAXPATHLEN]; + char pwd[PATH_MAX]; struct cvs_filelist *cf; if (getcwd(pwd, sizeof(pwd)) == NULL) @@ -291,7 +291,7 @@ cvs_commit_loginfo(char *repo) void cvs_commit_lock_dirs(struct cvs_file *cf) { - char repo[MAXPATHLEN]; + char repo[PATH_MAX]; cvs_get_repository_path(cf->file_wd, repo, sizeof(repo)); cvs_log(LP_TRACE, "cvs_commit_lock_dirs: %s", repo); @@ -446,7 +446,7 @@ cvs_commit_local(struct cvs_file *cf) int openflags, rcsflags; char rbuf[CVS_REV_BUFSZ], nbuf[CVS_REV_BUFSZ]; CVSENTRIES *entlist; - char attic[MAXPATHLEN], repo[MAXPATHLEN], rcsfile[MAXPATHLEN]; + char attic[PATH_MAX], repo[PATH_MAX], rcsfile[PATH_MAX]; struct file_info *fi; cvs_log(LP_TRACE, "cvs_commit_local(%s)", cf->file_path); @@ -559,8 +559,8 @@ cvs_commit_local(struct cvs_file *cf) "to be dead", cf->file_path); cvs_get_repository_path(cf->file_wd, repo, - MAXPATHLEN); - (void)xsnprintf(rcsfile, MAXPATHLEN, "%s/%s%s", + PATH_MAX); + (void)xsnprintf(rcsfile, PATH_MAX, "%s/%s%s", repo, cf->file_name, RCS_FILE_EXT); if (rename(cf->file_rpath, rcsfile) == -1) @@ -666,15 +666,15 @@ cvs_commit_local(struct cvs_file *cf) entlist = cvs_ent_open(cf->file_wd); cvs_ent_remove(entlist, cf->file_name); - cvs_get_repository_path(cf->file_wd, repo, MAXPATHLEN); + cvs_get_repository_path(cf->file_wd, repo, PATH_MAX); - (void)xsnprintf(attic, MAXPATHLEN, "%s/%s", + (void)xsnprintf(attic, PATH_MAX, "%s/%s", repo, CVS_PATH_ATTIC); if (mkdir(attic, 0755) == -1 && errno != EEXIST) fatal("cvs_commit_local: failed to create Attic"); - (void)xsnprintf(attic, MAXPATHLEN, "%s/%s/%s%s", repo, + (void)xsnprintf(attic, PATH_MAX, "%s/%s/%s%s", repo, CVS_PATH_ATTIC, cf->file_name, RCS_FILE_EXT); if (rename(cf->file_rpath, attic) == -1) @@ -772,9 +772,9 @@ commit_desc_set(struct cvs_file *cf) { BUF *bp; int fd; - char desc_path[MAXPATHLEN], *desc; + char desc_path[PATH_MAX], *desc; - (void)xsnprintf(desc_path, MAXPATHLEN, "%s/%s/%s%s", + (void)xsnprintf(desc_path, PATH_MAX, "%s/%s/%s%s", cf->file_wd, CVS_PATH_CVSDIR, cf->file_name, CVS_DESCR_FILE_EXT); if ((fd = open(desc_path, O_RDONLY)) == -1) diff --git a/usr.bin/cvs/config.c b/usr.bin/cvs/config.c index f9e29e50ba3..0d45f681ec0 100644 --- a/usr.bin/cvs/config.c +++ b/usr.bin/cvs/config.c @@ -1,4 +1,4 @@ -/* $OpenBSD: config.c,v 1.15 2008/03/02 11:58:45 joris Exp $ */ +/* $OpenBSD: config.c,v 1.16 2015/01/16 06:40:07 deraadt Exp $ */ /* * Copyright (c) 2006 Joris Vink <joris@openbsd.org> * @@ -15,7 +15,7 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#include <sys/param.h> +#include <sys/types.h> #include <sys/dirent.h> #include <sys/resource.h> @@ -83,7 +83,7 @@ cvs_read_config(char *name, int (*cb)(char *, int)) FILE *fp; size_t len; int lineno; - char *p, *buf, *lbuf, fpath[MAXPATHLEN]; + char *p, *buf, *lbuf, fpath[PATH_MAX]; (void)xsnprintf(fpath, sizeof(fpath), "%s/%s", current_cvsroot->cr_dir, name); diff --git a/usr.bin/cvs/cvs.c b/usr.bin/cvs/cvs.c index 15210e015f3..912be1af66d 100644 --- a/usr.bin/cvs/cvs.c +++ b/usr.bin/cvs/cvs.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cvs.c,v 1.154 2014/12/01 21:58:46 deraadt Exp $ */ +/* $OpenBSD: cvs.c,v 1.155 2015/01/16 06:40:07 deraadt Exp $ */ /* * Copyright (c) 2006, 2007 Joris Vink <joris@openbsd.org> * Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org> @@ -184,7 +184,7 @@ main(int argc, char **argv) int i, ret, cmd_argc; struct passwd *pw; struct stat st; - char fpath[MAXPATHLEN]; + char fpath[PATH_MAX]; tzset(); @@ -426,7 +426,7 @@ cvs_getopt(int argc, char **argv) static void cvs_read_rcfile(void) { - char rcpath[MAXPATHLEN], *buf, *lbuf, *lp, *p; + char rcpath[PATH_MAX], *buf, *lbuf, *lp, *p; int cmd_parsed, cvs_parsed, i, linenum; size_t len, pos; struct cvs_cmd *tcmdp; @@ -434,8 +434,8 @@ cvs_read_rcfile(void) linenum = 0; - i = snprintf(rcpath, MAXPATHLEN, "%s/%s", cvs_homedir, CVS_PATH_RC); - if (i < 0 || i >= MAXPATHLEN) { + i = snprintf(rcpath, PATH_MAX, "%s/%s", cvs_homedir, CVS_PATH_RC); + if (i < 0 || i >= PATH_MAX) { cvs_log(LP_ERRNO, "%s", rcpath); return; } diff --git a/usr.bin/cvs/diff3.c b/usr.bin/cvs/diff3.c index 5f0d95e31ab..a15248a1bb7 100644 --- a/usr.bin/cvs/diff3.c +++ b/usr.bin/cvs/diff3.c @@ -1,4 +1,4 @@ -/* $OpenBSD: diff3.c,v 1.56 2014/12/01 21:58:46 deraadt Exp $ */ +/* $OpenBSD: diff3.c,v 1.57 2015/01/16 06:40:07 deraadt Exp $ */ /* * Copyright (C) Caldera International Inc. 2001-2002. @@ -128,7 +128,7 @@ static int last[4]; static int eflag; static int oflag; /* indicates whether to mark overlaps (-E or -X)*/ static int debug = 0; -static char f1mark[MAXPATHLEN], f3mark[MAXPATHLEN]; /* markers for -E and -X */ +static char f1mark[PATH_MAX], f3mark[PATH_MAX]; /* markers for -E and -X */ static int duplicate(struct range *, struct range *); static int edit(struct diff *, int, int); diff --git a/usr.bin/cvs/diff_internals.c b/usr.bin/cvs/diff_internals.c index 706415acbb5..1b34d922a65 100644 --- a/usr.bin/cvs/diff_internals.c +++ b/usr.bin/cvs/diff_internals.c @@ -1,4 +1,4 @@ -/* $OpenBSD: diff_internals.c,v 1.35 2014/12/01 21:58:46 deraadt Exp $ */ +/* $OpenBSD: diff_internals.c,v 1.36 2015/01/16 06:40:07 deraadt Exp $ */ /* * Copyright (C) Caldera International Inc. 2001-2002. * All rights reserved. @@ -64,7 +64,7 @@ * @(#)diffreg.c 8.1 (Berkeley) 6/6/93 */ -#include <sys/param.h> +#include <sys/types.h> #include <sys/stat.h> #include <ctype.h> @@ -79,6 +79,9 @@ #include "cvs.h" #include "diff.h" +#define MINIMUM(a, b) (((a) < (b)) ? (a) : (b)) +#define MAXIMUM(a, b) (((a) > (b)) ? (a) : (b)) + /* * diff - compare two files. */ @@ -545,7 +548,7 @@ stone(int *a, int n, int *b, int *c, int flags) bound = UINT_MAX; else { sq = isqrt(n); - bound = MAX(256, sq); + bound = MAXIMUM(256, sq); } k = 0; @@ -1273,10 +1276,10 @@ dump_context_vec(FILE *f1, FILE *f2, int flags) return; b = d = 0; /* gcc */ - lowa = MAX(1, cvp->a - diff_context); - upb = MIN(len[0], context_vec_ptr->b + diff_context); - lowc = MAX(1, cvp->c - diff_context); - upd = MIN(len[1], context_vec_ptr->d + diff_context); + lowa = MAXIMUM(1, cvp->a - diff_context); + upb = MINIMUM(len[0], context_vec_ptr->b + diff_context); + lowc = MAXIMUM(1, cvp->c - diff_context); + upd = MINIMUM(len[1], context_vec_ptr->d + diff_context); diff_output("***************"); if ((flags & D_PROTOTYPE)) { @@ -1376,10 +1379,10 @@ dump_unified_vec(FILE *f1, FILE *f2, int flags) return; b = d = 0; /* gcc */ - lowa = MAX(1, cvp->a - diff_context); - upb = MIN(len[0], context_vec_ptr->b + diff_context); - lowc = MAX(1, cvp->c - diff_context); - upd = MIN(len[1], context_vec_ptr->d + diff_context); + lowa = MAXIMUM(1, cvp->a - diff_context); + upb = MINIMUM(len[0], context_vec_ptr->b + diff_context); + lowc = MAXIMUM(1, cvp->c - diff_context); + upd = MINIMUM(len[1], context_vec_ptr->d + diff_context); diff_output("@@ -"); uni_range(lowa, upb); diff --git a/usr.bin/cvs/edit.c b/usr.bin/cvs/edit.c index 8031b7000d0..2e292b93a68 100644 --- a/usr.bin/cvs/edit.c +++ b/usr.bin/cvs/edit.c @@ -1,4 +1,4 @@ -/* $OpenBSD: edit.c,v 1.49 2010/07/09 18:42:14 zinovik Exp $ */ +/* $OpenBSD: edit.c,v 1.50 2015/01/16 06:40:07 deraadt Exp $ */ /* * Copyright (c) 2006, 2007 Xavier Santolaria <xsa@openbsd.org> * @@ -260,8 +260,8 @@ cvs_edit_local(struct cvs_file *cf) FILE *fp; struct tm t; time_t now; - char timebuf[CVS_TIME_BUFSZ], thishost[MAXHOSTNAMELEN]; - char bfpath[MAXPATHLEN], wdir[MAXPATHLEN]; + char timebuf[CVS_TIME_BUFSZ], thishost[HOST_NAME_MAX+1]; + char bfpath[PATH_MAX], wdir[PATH_MAX]; if (cvs_noexec == 1) return; @@ -302,7 +302,7 @@ cvs_edit_local(struct cvs_file *cf) if (fchmod(cf->fd, 0644) == -1) fatal("cvs_edit_local: fchmod %s", strerror(errno)); - (void)xsnprintf(bfpath, MAXPATHLEN, "%s/%s", + (void)xsnprintf(bfpath, PATH_MAX, "%s/%s", CVS_PATH_BASEDIR, cf->file_name); if (mkdir(CVS_PATH_BASEDIR, 0755) == -1 && errno != EEXIST) @@ -327,8 +327,8 @@ cvs_unedit_local(struct cvs_file *cf) struct stat st; struct tm t; time_t now; - char bfpath[MAXPATHLEN], timebuf[64], thishost[MAXHOSTNAMELEN]; - char wdir[MAXPATHLEN], sticky[CVS_ENT_MAXLINELEN]; + char bfpath[PATH_MAX], timebuf[64], thishost[HOST_NAME_MAX+1]; + char wdir[PATH_MAX], sticky[CVS_ENT_MAXLINELEN]; RCSNUM *ba_rev; cvs_log(LP_TRACE, "cvs_unedit_local(%s)", cf->file_path); @@ -338,7 +338,7 @@ cvs_unedit_local(struct cvs_file *cf) cvs_file_classify(cf, cvs_directory_tag); - (void)xsnprintf(bfpath, MAXPATHLEN, "%s/%s", + (void)xsnprintf(bfpath, PATH_MAX, "%s/%s", CVS_PATH_BASEDIR, cf->file_name); if (stat(bfpath, &st) == -1) @@ -427,7 +427,7 @@ cvs_base_handle(struct cvs_file *cf, int flags) RCSNUM *ba_rev; int i; char *dp, *sp; - char buf[MAXPATHLEN], *fields[2], rbuf[CVS_REV_BUFSZ]; + char buf[PATH_MAX], *fields[2], rbuf[CVS_REV_BUFSZ]; cvs_log(LP_TRACE, "cvs_base_handle(%s)", cf->file_path); diff --git a/usr.bin/cvs/entries.c b/usr.bin/cvs/entries.c index a4e2ce7a3f8..36fc65da695 100644 --- a/usr.bin/cvs/entries.c +++ b/usr.bin/cvs/entries.c @@ -1,4 +1,4 @@ -/* $OpenBSD: entries.c,v 1.102 2009/03/19 09:53:16 joris Exp $ */ +/* $OpenBSD: entries.c,v 1.103 2015/01/16 06:40:07 deraadt Exp $ */ /* * Copyright (c) 2006 Joris Vink <joris@openbsd.org> * @@ -35,7 +35,7 @@ cvs_ent_open(const char *dir) { FILE *fp; CVSENTRIES *ep; - char *p, buf[MAXPATHLEN]; + char *p, buf[PATH_MAX]; struct cvs_ent *ent; struct cvs_ent_line *line; @@ -422,7 +422,7 @@ cvs_parse_tagfile(char *dir, char **tagp, char **datep, int *nbp) int i, linenum; size_t len; struct tm datetm; - char linebuf[128], tagpath[MAXPATHLEN]; + char linebuf[128], tagpath[PATH_MAX]; cvs_directory_date = -1; @@ -435,8 +435,8 @@ cvs_parse_tagfile(char *dir, char **tagp, char **datep, int *nbp) if (nbp != NULL) *nbp = 0; - i = snprintf(tagpath, MAXPATHLEN, "%s/%s", dir, CVS_PATH_TAG); - if (i < 0 || i >= MAXPATHLEN) + i = snprintf(tagpath, PATH_MAX, "%s/%s", dir, CVS_PATH_TAG); + if (i < 0 || i >= PATH_MAX) return; if ((fp = fopen(tagpath, "r")) == NULL) { @@ -499,7 +499,7 @@ cvs_write_tagfile(const char *dir, char *tag, char *date) { FILE *fp; RCSNUM *rev; - char tagpath[MAXPATHLEN]; + char tagpath[PATH_MAX]; char sticky[CVS_REV_BUFSZ]; struct tm datetm; int i; @@ -510,8 +510,8 @@ cvs_write_tagfile(const char *dir, char *tag, char *date) if (cvs_noexec == 1) return; - i = snprintf(tagpath, MAXPATHLEN, "%s/%s", dir, CVS_PATH_TAG); - if (i < 0 || i >= MAXPATHLEN) + i = snprintf(tagpath, PATH_MAX, "%s/%s", dir, CVS_PATH_TAG); + if (i < 0 || i >= PATH_MAX) return; if (tag != NULL || cvs_specified_date != -1 || diff --git a/usr.bin/cvs/file.c b/usr.bin/cvs/file.c index be038b9fc50..7b26580461e 100644 --- a/usr.bin/cvs/file.c +++ b/usr.bin/cvs/file.c @@ -1,4 +1,4 @@ -/* $OpenBSD: file.c,v 1.263 2013/12/13 15:19:41 zhuk Exp $ */ +/* $OpenBSD: file.c,v 1.264 2015/01/16 06:40:07 deraadt Exp $ */ /* * Copyright (c) 2006 Joris Vink <joris@openbsd.org> * Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org> @@ -89,7 +89,7 @@ cvs_file_init(void) { int i; FILE *ifp; - char path[MAXPATHLEN], buf[MAXNAMLEN]; + char path[PATH_MAX], buf[MAXNAMLEN]; TAILQ_INIT(&cvs_ign_pats); TAILQ_INIT(&dir_ign_pats); @@ -103,7 +103,7 @@ cvs_file_init(void) return; /* read the cvsignore file in the user's home directory, if any */ - (void)xsnprintf(path, MAXPATHLEN, "%s/.cvsignore", cvs_homedir); + (void)xsnprintf(path, PATH_MAX, "%s/.cvsignore", cvs_homedir); ifp = fopen(path, "r"); if (ifp == NULL) { @@ -264,7 +264,7 @@ cvs_file_walklist(struct cvs_flisthead *fl, struct cvs_recursion *cr) struct stat st; struct cvs_file *cf; struct cvs_filelist *l, *nxt; - char *d, *f, repo[MAXPATHLEN], fpath[MAXPATHLEN]; + char *d, *f, repo[PATH_MAX], fpath[PATH_MAX]; for (l = RB_MIN(cvs_flisthead, fl); l != NULL; l = nxt) { if (cvs_quit) @@ -311,12 +311,12 @@ cvs_file_walklist(struct cvs_flisthead *fl, struct cvs_recursion *cr) goto next; } - cvs_get_repository_path(d, repo, MAXPATHLEN); - (void)xsnprintf(fpath, MAXPATHLEN, "%s/%s", + cvs_get_repository_path(d, repo, PATH_MAX); + (void)xsnprintf(fpath, PATH_MAX, "%s/%s", repo, f); if ((fd = open(fpath, O_RDONLY)) == -1) { - strlcat(fpath, RCS_FILE_EXT, MAXPATHLEN); + strlcat(fpath, RCS_FILE_EXT, PATH_MAX); fd = open(fpath, O_RDONLY); } @@ -362,7 +362,7 @@ cvs_file_walklist(struct cvs_flisthead *fl, struct cvs_recursion *cr) if (current_cvsroot->cr_method == CVS_METHOD_LOCAL) { cvs_get_repository_path(cf->file_wd, - repo, MAXPATHLEN); + repo, PATH_MAX); cvs_repository_lock(repo, (cmdp->cmd_flags & CVS_LOCK_REPO)); } @@ -402,7 +402,7 @@ cvs_file_walkdir(struct cvs_file *cf, struct cvs_recursion *cr) struct cvs_ent_line *line; struct cvs_flisthead fl, dl; CVSENTRIES *entlist; - char *buf, *ebuf, *cp, repo[MAXPATHLEN], fpath[MAXPATHLEN]; + char *buf, *ebuf, *cp, repo[PATH_MAX], fpath[PATH_MAX]; cvs_log(LP_TRACE, "cvs_file_walkdir(%s)", cf->file_path); @@ -429,7 +429,7 @@ cvs_file_walkdir(struct cvs_file *cf, struct cvs_recursion *cr) * If we do not have an admin directory inside here, dont bother, * unless we are running export or import. */ - (void)xsnprintf(fpath, MAXPATHLEN, "%s/%s", cf->file_path, + (void)xsnprintf(fpath, PATH_MAX, "%s/%s", cf->file_path, CVS_PATH_CVSDIR); l = stat(fpath, &st); @@ -443,10 +443,10 @@ cvs_file_walkdir(struct cvs_file *cf, struct cvs_recursion *cr) /* * check for a local .cvsignore file */ - (void)xsnprintf(fpath, MAXPATHLEN, "%s/.cvsignore", cf->file_path); + (void)xsnprintf(fpath, PATH_MAX, "%s/.cvsignore", cf->file_path); if ((fp = fopen(fpath, "r")) != NULL) { - while (fgets(fpath, MAXPATHLEN, fp) != NULL) { + while (fgets(fpath, PATH_MAX, fp) != NULL) { fpath[strcspn(fpath, "\n")] = '\0'; if (fpath[0] == '\0') continue; @@ -493,7 +493,7 @@ cvs_file_walkdir(struct cvs_file *cf, struct cvs_recursion *cr) continue; } - (void)xsnprintf(fpath, MAXPATHLEN, "%s/%s", + (void)xsnprintf(fpath, PATH_MAX, "%s/%s", cf->file_path, dp->d_name); /* @@ -572,7 +572,7 @@ cvs_file_walkdir(struct cvs_file *cf, struct cvs_recursion *cr) TAILQ_FOREACH(line, &(entlist->cef_ent), entries_list) { ent = cvs_ent_parse(line->buf); - (void)xsnprintf(fpath, MAXPATHLEN, "%s/%s", cf->file_path, + (void)xsnprintf(fpath, PATH_MAX, "%s/%s", cf->file_path, ent->ce_name); if (!(cr->flags & CR_RECURSE_DIRS) && @@ -588,7 +588,7 @@ cvs_file_walkdir(struct cvs_file *cf, struct cvs_recursion *cr) walkrepo: if (current_cvsroot->cr_method == CVS_METHOD_LOCAL) { - cvs_get_repository_path(cf->file_path, repo, MAXPATHLEN); + cvs_get_repository_path(cf->file_path, repo, PATH_MAX); cvs_repository_lock(repo, (cmdp->cmd_flags & CVS_LOCK_REPO)); } @@ -646,7 +646,7 @@ cvs_file_classify(struct cvs_file *cf, const char *tag) int rflags, ismodified, rcsdead; CVSENTRIES *entlist = NULL; const char *state; - char repo[MAXPATHLEN], rcsfile[MAXPATHLEN]; + char repo[PATH_MAX], rcsfile[PATH_MAX]; cvs_log(LP_TRACE, "cvs_file_classify(%s, %s)", cf->file_path, (tag != NULL) ? tag : "none"); @@ -656,13 +656,13 @@ cvs_file_classify(struct cvs_file *cf, const char *tag) return; } - cvs_get_repository_path(cf->file_wd, repo, MAXPATHLEN); - (void)xsnprintf(rcsfile, MAXPATHLEN, "%s/%s", + cvs_get_repository_path(cf->file_wd, repo, PATH_MAX); + (void)xsnprintf(rcsfile, PATH_MAX, "%s/%s", repo, cf->file_name); if (cf->file_type == CVS_FILE) { - len = strlcat(rcsfile, RCS_FILE_EXT, MAXPATHLEN); - if (len >= MAXPATHLEN) + len = strlcat(rcsfile, RCS_FILE_EXT, PATH_MAX); + if (len >= PATH_MAX) fatal("cvs_file_classify: truncation"); } @@ -748,7 +748,7 @@ cvs_file_classify(struct cvs_file *cf, const char *tag) if (cf->file_rcs == NULL) fatal("cvs_file_classify: failed to parse RCS"); } else { - (void)xsnprintf(rcsfile, MAXPATHLEN, "%s/%s/%s%s", + (void)xsnprintf(rcsfile, PATH_MAX, "%s/%s/%s%s", repo, CVS_PATH_ATTIC, cf->file_name, RCS_FILE_EXT); cf->repo_fd = open(rcsfile, O_RDONLY); diff --git a/usr.bin/cvs/hash.c b/usr.bin/cvs/hash.c index 54a41466adf..6abad73c438 100644 --- a/usr.bin/cvs/hash.c +++ b/usr.bin/cvs/hash.c @@ -1,4 +1,4 @@ -/* $OpenBSD: hash.c,v 1.1 2008/06/21 15:39:15 joris Exp $ */ +/* $OpenBSD: hash.c,v 1.2 2015/01/16 06:40:07 deraadt Exp $ */ /* * Copyright (c) 2008 Joris Vink <joris@openbsd.org> * @@ -15,7 +15,7 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#include <sys/param.h> +#include <sys/types.h> #include <sys/queue.h> #include <stdio.h> diff --git a/usr.bin/cvs/history.c b/usr.bin/cvs/history.c index 53fb061a907..c9241aeefc5 100644 --- a/usr.bin/cvs/history.c +++ b/usr.bin/cvs/history.c @@ -1,4 +1,4 @@ -/* $OpenBSD: history.c,v 1.41 2013/12/13 15:19:41 zhuk Exp $ */ +/* $OpenBSD: history.c,v 1.42 2015/01/16 06:40:07 deraadt Exp $ */ /* * Copyright (c) 2007 Joris Vink <joris@openbsd.org> * @@ -70,7 +70,7 @@ cvs_history_add(int type, struct cvs_file *cf, const char *argument) size_t len; int fd; char *cwd, *p, *rev; - char revbuf[CVS_REV_BUFSZ], repo[MAXPATHLEN], fpath[MAXPATHLEN]; + char revbuf[CVS_REV_BUFSZ], repo[PATH_MAX], fpath[PATH_MAX]; char timebuf[CVS_TIME_BUFSZ]; struct tm datetm; diff --git a/usr.bin/cvs/import.c b/usr.bin/cvs/import.c index 04b8c2f2410..20a6b6eaed6 100644 --- a/usr.bin/cvs/import.c +++ b/usr.bin/cvs/import.c @@ -1,4 +1,4 @@ -/* $OpenBSD: import.c,v 1.103 2010/09/23 18:10:16 nicm Exp $ */ +/* $OpenBSD: import.c,v 1.104 2015/01/16 06:40:07 deraadt Exp $ */ /* * Copyright (c) 2006 Joris Vink <joris@openbsd.org> * @@ -67,7 +67,7 @@ int cvs_import(int argc, char **argv) { int i, ch; - char repo[MAXPATHLEN], *arg = "."; + char repo[PATH_MAX], *arg = "."; struct cvs_recursion cr; struct trigger_list *line_list; @@ -217,7 +217,7 @@ cvs_import_local(struct cvs_file *cf) { int isnew; struct stat st; - char repo[MAXPATHLEN]; + char repo[PATH_MAX]; cvs_log(LP_TRACE, "cvs_import_local(%s)", cf->file_path); @@ -258,7 +258,7 @@ static void import_loginfo(char *repo) { int i; - char pwd[MAXPATHLEN]; + char pwd[PATH_MAX]; if (getcwd(pwd, sizeof(pwd)) == NULL) fatal("Can't get working directory"); diff --git a/usr.bin/cvs/init.c b/usr.bin/cvs/init.c index 513db507c26..54e37079070 100644 --- a/usr.bin/cvs/init.c +++ b/usr.bin/cvs/init.c @@ -1,4 +1,4 @@ -/* $OpenBSD: init.c,v 1.38 2010/10/31 15:37:34 nicm Exp $ */ +/* $OpenBSD: init.c,v 1.39 2015/01/16 06:40:07 deraadt Exp $ */ /* * Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org> * Copyright (c) 2006 Xavier Santolaria <xsa@openbsd.org> @@ -100,7 +100,7 @@ void cvs_init_local(void) { u_int i; - char path[MAXPATHLEN]; + char path[PATH_MAX]; cvs_log(LP_TRACE, "cvs_init_local()"); @@ -108,14 +108,14 @@ cvs_init_local(void) init_mkdir(current_cvsroot->cr_dir, 0777); for (i = 0; i < INIT_NDIRS; i++) { - (void)xsnprintf(path, MAXPATHLEN, "%s/%s", + (void)xsnprintf(path, PATH_MAX, "%s/%s", current_cvsroot->cr_dir, cvsroot_dirs[i]); init_mkdir(path, 0777); } for (i = 0; i < INIT_NFILES; i++) { - (void)xsnprintf(path, MAXPATHLEN, "%s/%s", + (void)xsnprintf(path, PATH_MAX, "%s/%s", current_cvsroot->cr_dir, cvsroot_files[i].cf_path); init_mkfile(path, cvsroot_files[i].cf_content); @@ -143,7 +143,7 @@ init_mkfile(char *path, const char **content) BUF *b; size_t len; int fd, openflags, rcsflags; - char rpath[MAXPATHLEN]; + char rpath[PATH_MAX]; const char **p; RCSFILE *file; @@ -172,7 +172,7 @@ init_mkfile(char *path, const char **content) return; } - (void)xsnprintf(rpath, MAXPATHLEN, "%s%s", path, RCS_FILE_EXT); + (void)xsnprintf(rpath, PATH_MAX, "%s%s", path, RCS_FILE_EXT); if ((file = rcs_open(rpath, -1, rcsflags, 0444)) == NULL) fatal("failed to create RCS file for `%s'", path); diff --git a/usr.bin/cvs/logmsg.c b/usr.bin/cvs/logmsg.c index 12e667de44f..7e4eae7ccfb 100644 --- a/usr.bin/cvs/logmsg.c +++ b/usr.bin/cvs/logmsg.c @@ -1,4 +1,4 @@ -/* $OpenBSD: logmsg.c,v 1.54 2010/07/23 21:46:05 ray Exp $ */ +/* $OpenBSD: logmsg.c,v 1.55 2015/01/16 06:40:07 deraadt Exp $ */ /* * Copyright (c) 2007 Joris Vink <joris@openbsd.org> * @@ -99,7 +99,7 @@ cvs_logmsg_create(char *dir, struct cvs_flisthead *added, int c, fd, rd, saved_errno; struct cvs_filelist *cf; struct stat st1, st2; - char *fpath, *logmsg, repo[MAXPATHLEN]; + char *fpath, *logmsg, repo[PATH_MAX]; struct stat st; struct trigger_list *line_list; struct trigger_line *line; diff --git a/usr.bin/cvs/modules.c b/usr.bin/cvs/modules.c index 95b0c37febf..82c385340df 100644 --- a/usr.bin/cvs/modules.c +++ b/usr.bin/cvs/modules.c @@ -1,4 +1,4 @@ -/* $OpenBSD: modules.c,v 1.17 2014/01/08 13:23:55 okan Exp $ */ +/* $OpenBSD: modules.c,v 1.18 2015/01/16 06:40:07 deraadt Exp $ */ /* * Copyright (c) 2008 Joris Vink <joris@openbsd.org> * @@ -15,7 +15,7 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#include <sys/param.h> +#include <sys/types.h> #include <sys/dirent.h> #include <sys/resource.h> @@ -55,7 +55,7 @@ modules_parse_line(char *line, int lineno) int flags; struct module_info *mi; char *bline, *val, *p, *module, *sp, *dp; - char *dirname, fpath[MAXPATHLEN], *prog; + char *dirname, fpath[PATH_MAX], *prog; prog = NULL; bline = xstrdup(line); diff --git a/usr.bin/cvs/rcs.c b/usr.bin/cvs/rcs.c index c355c2243ae..220fee8f2f4 100644 --- a/usr.bin/cvs/rcs.c +++ b/usr.bin/cvs/rcs.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rcs.c,v 1.311 2014/01/08 13:23:55 okan Exp $ */ +/* $OpenBSD: rcs.c,v 1.312 2015/01/16 06:40:07 deraadt Exp $ */ /* * Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org> * All rights reserved. @@ -40,6 +40,8 @@ #include "rcs.h" #include "rcsparse.h" +#define MINIMUM(a, b) (((a) < (b)) ? (a) : (b)) + #define RCS_KWEXP_SIZE 1024 #define ANNOTATE_NEVER 0 @@ -284,7 +286,7 @@ void rcs_write(RCSFILE *rfp) { FILE *fp; - char numbuf[CVS_REV_BUFSZ], *fn, tmpdir[MAXPATHLEN]; + char numbuf[CVS_REV_BUFSZ], *fn, tmpdir[PATH_MAX]; struct rcs_access *ap; struct rcs_sym *symp; struct rcs_branch *brp; @@ -1704,7 +1706,7 @@ rcs_get_revision(const char *revstr, RCSFILE *rfp) * instead of just 2. */ if (rfp->rf_head == NULL || rcsnum_cmp(rev, rfp->rf_head, - MIN(rfp->rf_head->rn_len, rev->rn_len)) < 0) { + MINIMUM(rfp->rf_head->rn_len, rev->rn_len)) < 0) { rcsnum_free(rev); return (NULL); } diff --git a/usr.bin/cvs/rcsnum.c b/usr.bin/cvs/rcsnum.c index ac613b4ac5a..cd35a3b16da 100644 --- a/usr.bin/cvs/rcsnum.c +++ b/usr.bin/cvs/rcsnum.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rcsnum.c,v 1.55 2014/01/08 13:23:55 okan Exp $ */ +/* $OpenBSD: rcsnum.c,v 1.56 2015/01/16 06:40:07 deraadt Exp $ */ /* * Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org> * All rights reserved. @@ -29,6 +29,8 @@ #include "cvs.h" +#define MINIMUM(a, b) (((a) < (b)) ? (a) : (b)) + static void rcsnum_setsize(RCSNUM *, u_int); static char *rcsnum_itoa(u_int16_t, char *, size_t); @@ -188,7 +190,7 @@ rcsnum_cmp(RCSNUM *n1, RCSNUM *n2, u_int depth) if (!rcsnum_differ(n1, n2)) return (0); - slen = MIN(n1->rn_len, n2->rn_len); + slen = MINIMUM(n1->rn_len, n2->rn_len); if (depth != 0 && slen > depth) slen = depth; @@ -435,7 +437,7 @@ rcsnum_differ(RCSNUM *r1, RCSNUM *r2) if (r1->rn_len != r2->rn_len) return (1); - len = MIN(r1->rn_len, r2->rn_len); + len = MINIMUM(r1->rn_len, r2->rn_len); for (i = 0; i < len; i++) { if (r1->rn_id[i] != r2->rn_id[i]) return (1); diff --git a/usr.bin/cvs/release.c b/usr.bin/cvs/release.c index 8ca08835256..9544791cb07 100644 --- a/usr.bin/cvs/release.c +++ b/usr.bin/cvs/release.c @@ -1,4 +1,4 @@ -/* $OpenBSD: release.c,v 1.41 2009/03/21 11:18:45 joris Exp $ */ +/* $OpenBSD: release.c,v 1.42 2015/01/16 06:40:07 deraadt Exp $ */ /*- * Copyright (c) 2005-2007 Xavier Santolaria <xsa@openbsd.org> * @@ -96,7 +96,7 @@ cvs_release_local(struct cvs_file *cf) { struct stat st; struct cvs_recursion cr; - char *wdir, cwd[MAXPATHLEN]; + char *wdir, cwd[PATH_MAX]; char *arg = "."; int saved_noexec; diff --git a/usr.bin/cvs/remote.c b/usr.bin/cvs/remote.c index 162fe539282..4c122ad984f 100644 --- a/usr.bin/cvs/remote.c +++ b/usr.bin/cvs/remote.c @@ -1,4 +1,4 @@ -/* $OpenBSD: remote.c,v 1.29 2010/07/23 21:46:05 ray Exp $ */ +/* $OpenBSD: remote.c,v 1.30 2015/01/16 06:40:07 deraadt Exp $ */ /* * Copyright (c) 2006 Joris Vink <joris@openbsd.org> * @@ -15,6 +15,7 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#include <sys/param.h> /* MAXBSIZE */ #include <sys/stat.h> #include <errno.h> @@ -27,6 +28,8 @@ #include "cvs.h" #include "remote.h" +#define MINIMUM(a, b) (((a) < (b)) ? (a) : (b)) + struct cvs_resp * cvs_remote_get_response_info(const char *response) { @@ -136,7 +139,7 @@ cvs_remote_receive_file(int fd, size_t len) nleft = len; while (nleft > 0) { - toread = MIN(nleft, MAXBSIZE); + toread = MINIMUM(nleft, MAXBSIZE); nread = fread(data, sizeof(char), toread, in); if (nread == 0) diff --git a/usr.bin/cvs/remove.c b/usr.bin/cvs/remove.c index 72a0575840f..e2a143d460e 100644 --- a/usr.bin/cvs/remove.c +++ b/usr.bin/cvs/remove.c @@ -1,4 +1,4 @@ -/* $OpenBSD: remove.c,v 1.81 2011/12/27 13:59:01 nicm Exp $ */ +/* $OpenBSD: remove.c,v 1.82 2015/01/16 06:40:07 deraadt Exp $ */ /* * Copyright (c) 2005, 2006 Xavier Santolaria <xsa@openbsd.org> * @@ -137,7 +137,7 @@ void cvs_remove_local(struct cvs_file *cf) { CVSENTRIES *entlist; - char *entry, buf[MAXPATHLEN], tbuf[CVS_TIME_BUFSZ], rbuf[CVS_REV_BUFSZ]; + char *entry, buf[PATH_MAX], tbuf[CVS_TIME_BUFSZ], rbuf[CVS_REV_BUFSZ]; char sticky[CVS_ENT_MAXLINELEN]; cvs_log(LP_TRACE, "cvs_remove_local(%s)", cf->file_path); diff --git a/usr.bin/cvs/repository.c b/usr.bin/cvs/repository.c index c2df4be05e6..a5d0fa761ac 100644 --- a/usr.bin/cvs/repository.c +++ b/usr.bin/cvs/repository.c @@ -1,4 +1,4 @@ -/* $OpenBSD: repository.c,v 1.23 2010/07/23 08:31:19 ray Exp $ */ +/* $OpenBSD: repository.c,v 1.24 2015/01/16 06:40:07 deraadt Exp $ */ /* * Copyright (c) 2006 Joris Vink <joris@openbsd.org> * @@ -30,7 +30,7 @@ struct wklhead repo_locks; void cvs_repository_unlock(const char *repo) { - char fpath[MAXPATHLEN]; + char fpath[PATH_MAX]; cvs_log(LP_TRACE, "cvs_repository_unlock(%s)", repo); @@ -46,7 +46,7 @@ cvs_repository_lock(const char *repo, int wantlock) int i; uid_t myuid; struct stat st; - char fpath[MAXPATHLEN]; + char fpath[PATH_MAX]; struct passwd *pw; if (cvs_noexec == 1 || cvs_readonlyfs == 1) @@ -102,7 +102,7 @@ cvs_repository_getdir(const char *dir, const char *wdir, DIR *dirp; struct stat st; struct dirent *dp; - char *s, fpath[MAXPATHLEN], rpath[MAXPATHLEN]; + char *s, fpath[PATH_MAX], rpath[PATH_MAX]; if ((dirp = opendir(dir)) == NULL) fatal("cvs_repository_getdir: failed to open '%s'", dir); @@ -113,8 +113,8 @@ cvs_repository_getdir(const char *dir, const char *wdir, !strcmp(dp->d_name, CVS_LOCK)) continue; - (void)xsnprintf(fpath, MAXPATHLEN, "%s/%s", wdir, dp->d_name); - (void)xsnprintf(rpath, MAXPATHLEN, "%s/%s", dir, dp->d_name); + (void)xsnprintf(fpath, PATH_MAX, "%s/%s", wdir, dp->d_name); + (void)xsnprintf(rpath, PATH_MAX, "%s/%s", dir, dp->d_name); if (!TAILQ_EMPTY(&checkout_ign_pats)) { if ((s = strrchr(fpath, ',')) != NULL) diff --git a/usr.bin/cvs/root.c b/usr.bin/cvs/root.c index d71b2f66be2..1143ea9f280 100644 --- a/usr.bin/cvs/root.c +++ b/usr.bin/cvs/root.c @@ -1,4 +1,4 @@ -/* $OpenBSD: root.c,v 1.47 2010/10/23 18:36:35 nicm Exp $ */ +/* $OpenBSD: root.c,v 1.48 2015/01/16 06:40:07 deraadt Exp $ */ /* * Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org> * All rights reserved. @@ -163,7 +163,7 @@ cvsroot_parse(const char *str) struct cvsroot * cvsroot_get(const char *dir) { - char rootpath[MAXPATHLEN], *rootstr, line[128]; + char rootpath[PATH_MAX], *rootstr, line[128]; FILE *fp; if (cvs_rootstr != NULL) @@ -178,7 +178,7 @@ cvsroot_get(const char *dir) return (NULL); } - (void)xsnprintf(rootpath, MAXPATHLEN, "%s/%s", dir, CVS_PATH_ROOTSPEC); + (void)xsnprintf(rootpath, PATH_MAX, "%s/%s", dir, CVS_PATH_ROOTSPEC); if ((fp = fopen(rootpath, "r")) == NULL) { if (errno == ENOENT) { diff --git a/usr.bin/cvs/server.c b/usr.bin/cvs/server.c index c733ab49a9b..e01a23db438 100644 --- a/usr.bin/cvs/server.c +++ b/usr.bin/cvs/server.c @@ -1,4 +1,4 @@ -/* $OpenBSD: server.c,v 1.101 2014/12/01 21:58:46 deraadt Exp $ */ +/* $OpenBSD: server.c,v 1.102 2015/01/16 06:40:07 deraadt Exp $ */ /* * Copyright (c) 2006 Joris Vink <joris@openbsd.org> * @@ -244,9 +244,9 @@ void cvs_server_static_directory(char *data) { FILE *fp; - char fpath[MAXPATHLEN]; + char fpath[PATH_MAX]; - (void)xsnprintf(fpath, MAXPATHLEN, "%s/%s", + (void)xsnprintf(fpath, PATH_MAX, "%s/%s", server_currentdir, CVS_PATH_STATICENTRIES); if ((fp = fopen(fpath, "w+")) == NULL) { @@ -260,12 +260,12 @@ void cvs_server_sticky(char *data) { FILE *fp; - char tagpath[MAXPATHLEN]; + char tagpath[PATH_MAX]; if (data == NULL) fatal("Missing argument for Sticky"); - (void)xsnprintf(tagpath, MAXPATHLEN, "%s/%s", + (void)xsnprintf(tagpath, PATH_MAX, "%s/%s", server_currentdir, CVS_PATH_TAG); if ((fp = fopen(tagpath, "w+")) == NULL) { @@ -392,7 +392,7 @@ cvs_server_modified(char *data) size_t flen; mode_t fmode; const char *errstr; - char *mode, *len, fpath[MAXPATHLEN]; + char *mode, *len, fpath[PATH_MAX]; if (data == NULL) fatal("Missing argument for Modified"); @@ -411,7 +411,7 @@ cvs_server_modified(char *data) fatal("cvs_server_modified: %s", errstr); xfree(len); - (void)xsnprintf(fpath, MAXPATHLEN, "%s/%s", server_currentdir, data); + (void)xsnprintf(fpath, PATH_MAX, "%s/%s", server_currentdir, data); if ((fd = open(fpath, O_WRONLY | O_CREAT | O_TRUNC)) == -1) fatal("cvs_server_modified: %s: %s", fpath, strerror(errno)); @@ -432,7 +432,7 @@ cvs_server_useunchanged(char *data) void cvs_server_unchanged(char *data) { - char fpath[MAXPATHLEN]; + char fpath[PATH_MAX]; CVSENTRIES *entlist; struct cvs_ent *ent; char sticky[CVS_ENT_MAXLINELEN]; @@ -444,7 +444,7 @@ cvs_server_unchanged(char *data) /* sorry, we have to use TMP_DIR */ disable_fast_checkout = 1; - (void)xsnprintf(fpath, MAXPATHLEN, "%s/%s", server_currentdir, data); + (void)xsnprintf(fpath, PATH_MAX, "%s/%s", server_currentdir, data); entlist = cvs_ent_open(server_currentdir); ent = cvs_ent_get(entlist, data); @@ -771,13 +771,13 @@ void cvs_server_update_entry(const char *resp, struct cvs_file *cf) { char *p; - char repo[MAXPATHLEN], fpath[MAXPATHLEN]; + char repo[PATH_MAX], fpath[PATH_MAX]; if ((p = strrchr(cf->file_rpath, ',')) != NULL) *p = '\0'; - cvs_get_repository_path(cf->file_wd, repo, MAXPATHLEN); - (void)xsnprintf(fpath, MAXPATHLEN, "%s/%s", repo, cf->file_name); + cvs_get_repository_path(cf->file_wd, repo, PATH_MAX); + (void)xsnprintf(fpath, PATH_MAX, "%s/%s", repo, cf->file_name); cvs_server_send_response("%s %s/", resp, cf->file_wd); cvs_remote_output(fpath); @@ -789,11 +789,11 @@ cvs_server_update_entry(const char *resp, struct cvs_file *cf) void cvs_server_set_sticky(const char *dir, const char *tag) { - char fpath[MAXPATHLEN]; - char repo[MAXPATHLEN]; + char fpath[PATH_MAX]; + char repo[PATH_MAX]; - cvs_get_repository_path(dir, repo, MAXPATHLEN); - (void)xsnprintf(fpath, MAXPATHLEN, "%s/", repo); + cvs_get_repository_path(dir, repo, PATH_MAX); + (void)xsnprintf(fpath, PATH_MAX, "%s/", repo); cvs_server_send_response("Set-sticky %s/", dir); cvs_remote_output(fpath); @@ -803,11 +803,11 @@ cvs_server_set_sticky(const char *dir, const char *tag) void cvs_server_clear_sticky(char *dir) { - char fpath[MAXPATHLEN]; - char repo[MAXPATHLEN]; + char fpath[PATH_MAX]; + char repo[PATH_MAX]; - cvs_get_repository_path(dir, repo, MAXPATHLEN); - (void)xsnprintf(fpath, MAXPATHLEN, "%s/", repo); + cvs_get_repository_path(dir, repo, PATH_MAX); + (void)xsnprintf(fpath, PATH_MAX, "%s/", repo); cvs_server_send_response("Clear-sticky %s//", dir); cvs_remote_output(fpath); diff --git a/usr.bin/cvs/status.c b/usr.bin/cvs/status.c index 2089752f3dc..80bc5077ab3 100644 --- a/usr.bin/cvs/status.c +++ b/usr.bin/cvs/status.c @@ -1,4 +1,4 @@ -/* $OpenBSD: status.c,v 1.93 2010/04/19 13:03:10 millert Exp $ */ +/* $OpenBSD: status.c,v 1.94 2015/01/16 06:40:07 deraadt Exp $ */ /* * Copyright (c) 2006 Joris Vink <joris@openbsd.org> * Copyright (c) 2005-2008 Xavier Santolaria <xsa@openbsd.org> @@ -121,7 +121,7 @@ cvs_status_local(struct cvs_file *cf) size_t len; RCSNUM *head; const char *status; - char buf[MAXPATHLEN + CVS_REV_BUFSZ + 128]; + char buf[PATH_MAX + CVS_REV_BUFSZ + 128]; char timebuf[CVS_TIME_BUFSZ], revbuf[CVS_REV_BUFSZ]; struct rcs_sym *sym; diff --git a/usr.bin/cvs/tag.c b/usr.bin/cvs/tag.c index 41c6b643820..a7a5fe47e33 100644 --- a/usr.bin/cvs/tag.c +++ b/usr.bin/cvs/tag.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tag.c,v 1.80 2010/10/28 12:30:27 tobias Exp $ */ +/* $OpenBSD: tag.c,v 1.81 2015/01/16 06:40:07 deraadt Exp $ */ /* * Copyright (c) 2006 Xavier Santolaria <xsa@openbsd.org> * @@ -65,7 +65,7 @@ int cvs_tag(int argc, char **argv) { int ch, flags, i; - char repo[MAXPATHLEN]; + char repo[PATH_MAX]; char *arg = "."; struct cvs_recursion cr; struct trigger_list *line_list; @@ -186,7 +186,7 @@ cvs_tag(int argc, char **argv) cr.flags = flags; - cvs_get_repository_name(".", repo, MAXPATHLEN); + cvs_get_repository_name(".", repo, PATH_MAX); line_list = cvs_trigger_getlines(CVS_PATH_TAGINFO, repo); if (line_list != NULL) { TAILQ_INIT(&files_info); diff --git a/usr.bin/cvs/trigger.c b/usr.bin/cvs/trigger.c index 5fc306408af..20a5e4dd650 100644 --- a/usr.bin/cvs/trigger.c +++ b/usr.bin/cvs/trigger.c @@ -1,4 +1,4 @@ -/* $OpenBSD: trigger.c,v 1.21 2014/01/08 13:23:55 okan Exp $ */ +/* $OpenBSD: trigger.c,v 1.22 2015/01/16 06:40:07 deraadt Exp $ */ /* * Copyright (c) 2008 Tobias Stoeckmann <tobias@openbsd.org> * Copyright (c) 2008 Jonathan Armani <dbd@asystant.net> @@ -382,7 +382,7 @@ cvs_trigger_getlines(char * file, char * repo) regex_t preg; struct trigger_list *list; struct trigger_line *tline; - char fpath[MAXPATHLEN]; + char fpath[PATH_MAX]; char *currentline, *defaultline = NULL, *nline, *p, *q, *regex; if (strcmp(file, CVS_PATH_EDITINFO) == 0 || @@ -391,7 +391,7 @@ cvs_trigger_getlines(char * file, char * repo) else allow_all = 1; - (void)xsnprintf(fpath, MAXPATHLEN, "%s/%s", current_cvsroot->cr_dir, + (void)xsnprintf(fpath, PATH_MAX, "%s/%s", current_cvsroot->cr_dir, file); if ((fp = fopen(fpath, "r")) == NULL) { @@ -535,8 +535,8 @@ cvs_trigger_freeinfo(struct file_info_list * list) void cvs_trigger_loginfo_header(BUF *buf, char *repo) { - char *dir, pwd[MAXPATHLEN]; - char hostname[MAXHOSTNAMELEN]; + char *dir, pwd[PATH_MAX]; + char hostname[HOST_NAME_MAX+1]; if (gethostname(hostname, sizeof(hostname)) == -1) { fatal("cvs_trigger_loginfo_header: gethostname failed %s", diff --git a/usr.bin/cvs/update.c b/usr.bin/cvs/update.c index 2441dcafa9c..7290937bfc9 100644 --- a/usr.bin/cvs/update.c +++ b/usr.bin/cvs/update.c @@ -1,4 +1,4 @@ -/* $OpenBSD: update.c,v 1.168 2013/12/13 15:19:41 zhuk Exp $ */ +/* $OpenBSD: update.c,v 1.169 2015/01/16 06:40:07 deraadt Exp $ */ /* * Copyright (c) 2006 Joris Vink <joris@openbsd.org> * @@ -192,7 +192,7 @@ void cvs_update_enterdir(struct cvs_file *cf) { CVSENTRIES *entlist; - char *dirtag, *entry, fpath[MAXPATHLEN]; + char *dirtag, *entry, fpath[PATH_MAX]; cvs_log(LP_TRACE, "cvs_update_enterdir(%s)", cf->file_path); @@ -223,7 +223,7 @@ cvs_update_enterdir(struct cvs_file *cf) cf->file_status == FILE_UNKNOWN) { cf->file_status = FILE_SKIP; } else if (reset_tag) { - (void)xsnprintf(fpath, MAXPATHLEN, "%s/%s", + (void)xsnprintf(fpath, PATH_MAX, "%s/%s", cf->file_path, CVS_PATH_TAG); (void)unlink(fpath); } else { @@ -725,7 +725,7 @@ out: void cvs_backup_file(struct cvs_file *cf) { - char backup_name[MAXPATHLEN]; + char backup_name[PATH_MAX]; char revstr[RCSNUM_MAXSTR]; if (cf->file_status == FILE_ADDED) @@ -733,12 +733,12 @@ cvs_backup_file(struct cvs_file *cf) else rcsnum_tostr(cf->file_ent->ce_rev, revstr, sizeof(revstr)); - (void)xsnprintf(backup_name, MAXPATHLEN, "%s/.#%s.%s", + (void)xsnprintf(backup_name, PATH_MAX, "%s/.#%s.%s", cf->file_wd, cf->file_name, revstr); cvs_file_copy(cf->file_path, backup_name); - (void)xsnprintf(backup_name, MAXPATHLEN, ".#%s.%s", + (void)xsnprintf(backup_name, PATH_MAX, ".#%s.%s", cf->file_name, revstr); cvs_printf("(Locally modified %s moved to %s)\n", cf->file_name, backup_name); diff --git a/usr.bin/cvs/util.c b/usr.bin/cvs/util.c index 3d6b0948aab..747c28346fd 100644 --- a/usr.bin/cvs/util.c +++ b/usr.bin/cvs/util.c @@ -1,4 +1,4 @@ -/* $OpenBSD: util.c,v 1.156 2014/12/01 21:58:46 deraadt Exp $ */ +/* $OpenBSD: util.c,v 1.157 2015/01/16 06:40:07 deraadt Exp $ */ /* * Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org> * Copyright (c) 2005, 2006 Joris Vink <joris@openbsd.org> @@ -366,7 +366,7 @@ cvs_rmdir(const char *path) DIR *dirp; struct dirent *ent; struct stat st; - char fpath[MAXPATHLEN]; + char fpath[PATH_MAX]; if (cvs_server_active == 0) cvs_log(LP_TRACE, "cvs_rmdir(%s)", path); @@ -444,7 +444,7 @@ done: void cvs_get_repository_path(const char *dir, char *dst, size_t len) { - char buf[MAXPATHLEN]; + char buf[PATH_MAX]; cvs_get_repository_name(dir, buf, sizeof(buf)); (void)xsnprintf(dst, len, "%s/%s", current_cvsroot->cr_dir, buf); @@ -455,7 +455,7 @@ void cvs_get_repository_name(const char *dir, char *dst, size_t len) { FILE *fp; - char fpath[MAXPATHLEN]; + char fpath[PATH_MAX]; dst[0] = '\0'; @@ -501,7 +501,7 @@ cvs_mkadmin(const char *path, const char *root, const char *repo, { FILE *fp; int fd; - char buf[MAXPATHLEN]; + char buf[PATH_MAX]; struct hash_data *hdata, hd; hdata = hash_table_find(&created_cvs_directories, path, strlen(path)); @@ -565,7 +565,7 @@ cvs_mkpath(const char *path, char *tag) FILE *fp; size_t len; struct hash_data *hdata, hd; - char *entry, *sp, *dp, *dir, *p, rpath[MAXPATHLEN], repo[MAXPATHLEN]; + char *entry, *sp, *dp, *dir, *p, rpath[PATH_MAX], repo[PATH_MAX]; hdata = hash_table_find(&created_directories, path, strlen(path)); if (hdata != NULL) @@ -662,7 +662,7 @@ void cvs_mkdir(const char *path, mode_t mode) { size_t len; - char *sp, *dp, *dir, rpath[MAXPATHLEN]; + char *sp, *dp, *dir, rpath[PATH_MAX]; if (current_cvsroot->cr_method != CVS_METHOD_LOCAL || cvs_server_active == 1) diff --git a/usr.bin/cvs/worklist.h b/usr.bin/cvs/worklist.h index d2eaa533d21..5a7125fcead 100644 --- a/usr.bin/cvs/worklist.h +++ b/usr.bin/cvs/worklist.h @@ -1,4 +1,4 @@ -/* $OpenBSD: worklist.h,v 1.7 2010/07/23 08:31:19 ray Exp $ */ +/* $OpenBSD: worklist.h,v 1.8 2015/01/16 06:40:07 deraadt Exp $ */ /* * Copyright (c) 2006 Joris Vink <joris@openbsd.org> * All rights reserved. @@ -27,10 +27,11 @@ #ifndef WORKLIST_H #define WORKLIST_H -#include <sys/param.h> +#include <sys/types.h> +#include <limits.h> struct worklist { - char wkl_path[MAXPATHLEN]; + char wkl_path[PATH_MAX]; volatile SLIST_ENTRY(worklist) wkl_list; }; diff --git a/usr.bin/diff/diff.c b/usr.bin/diff/diff.c index e0c6dbe8c73..fbe46714f7d 100644 --- a/usr.bin/diff/diff.c +++ b/usr.bin/diff/diff.c @@ -1,4 +1,4 @@ -/* $OpenBSD: diff.c,v 1.57 2010/07/16 23:27:58 ray Exp $ */ +/* $OpenBSD: diff.c,v 1.58 2015/01/16 06:40:07 deraadt Exp $ */ /* * Copyright (c) 2003 Todd C. Miller <Todd.Miller@courtesan.com> @@ -20,7 +20,6 @@ * Materiel Command, USAF, under agreement number F39502-99-1-0512. */ -#include <sys/param.h> #include <sys/stat.h> #include <ctype.h> @@ -33,6 +32,7 @@ #include <stdarg.h> #include <string.h> #include <unistd.h> +#include <limits.h> #include "diff.h" #include "xmalloc.h" diff --git a/usr.bin/diff/diffdir.c b/usr.bin/diff/diffdir.c index 64b173975bd..dc6f17fd3c4 100644 --- a/usr.bin/diff/diffdir.c +++ b/usr.bin/diff/diffdir.c @@ -1,4 +1,4 @@ -/* $OpenBSD: diffdir.c,v 1.42 2014/05/20 01:25:23 guenther Exp $ */ +/* $OpenBSD: diffdir.c,v 1.43 2015/01/16 06:40:07 deraadt Exp $ */ /* * Copyright (c) 2003, 2010 Todd C. Miller <Todd.Miller@courtesan.com> @@ -20,7 +20,6 @@ * Materiel Command, USAF, under agreement number F39502-99-1-0512. */ -#include <sys/param.h> #include <sys/stat.h> #include <dirent.h> @@ -33,6 +32,7 @@ #include <stdlib.h> #include <string.h> #include <unistd.h> +#include <limits.h> #include "diff.h" #include "xmalloc.h" @@ -51,7 +51,7 @@ diffdir(char *p1, char *p2, int flags) struct dirent *dent1, **dp1, **edp1, **dirp1 = NULL; struct dirent *dent2, **dp2, **edp2, **dirp2 = NULL; size_t dirlen1, dirlen2; - char path1[MAXPATHLEN], path2[MAXPATHLEN]; + char path1[PATH_MAX], path2[PATH_MAX]; int pos; dirlen1 = strlcpy(path1, *p1 ? p1 : ".", sizeof(path1)); @@ -184,7 +184,7 @@ diffit(struct dirent *dp, char *path1, size_t plen1, char *path2, size_t plen2, int flags) { flags |= D_HEADER; - strlcpy(path1 + plen1, dp->d_name, MAXPATHLEN - plen1); + strlcpy(path1 + plen1, dp->d_name, PATH_MAX - plen1); if (stat(path1, &stb1) != 0) { if (!(Nflag || Pflag) || errno != ENOENT) { warn("%s", path1); @@ -194,7 +194,7 @@ diffit(struct dirent *dp, char *path1, size_t plen1, char *path2, size_t plen2, memset(&stb1, 0, sizeof(stb1)); } - strlcpy(path2 + plen2, dp->d_name, MAXPATHLEN - plen2); + strlcpy(path2 + plen2, dp->d_name, PATH_MAX - plen2); if (stat(path2, &stb2) != 0) { if (!Nflag || errno != ENOENT) { warn("%s", path2); diff --git a/usr.bin/diff/diffreg.c b/usr.bin/diff/diffreg.c index f949cd27c27..83a86e6aab4 100644 --- a/usr.bin/diff/diffreg.c +++ b/usr.bin/diff/diffreg.c @@ -1,4 +1,4 @@ -/* $OpenBSD: diffreg.c,v 1.83 2014/08/27 15:22:40 kspillner Exp $ */ +/* $OpenBSD: diffreg.c,v 1.84 2015/01/16 06:40:07 deraadt Exp $ */ /* * Copyright (C) Caldera International Inc. 2001-2002. @@ -64,7 +64,6 @@ * @(#)diffreg.c 8.1 (Berkeley) 6/6/93 */ -#include <sys/param.h> #include <sys/stat.h> #include <sys/wait.h> @@ -77,11 +76,15 @@ #include <stdlib.h> #include <string.h> #include <unistd.h> +#include <limits.h> #include "diff.h" #include "pathnames.h" #include "xmalloc.h" +#define MINIMUM(a, b) (((a) < (b)) ? (a) : (b)) +#define MAXIMUM(a, b) (((a) > (b)) ? (a) : (b)) + /* * diff - compare two files. */ @@ -495,7 +498,7 @@ files_differ(FILE *f1, FILE *f2, int flags) static FILE * opentemp(const char *file) { - char buf[BUFSIZ], *tempdir, tempfile[MAXPATHLEN]; + char buf[BUFSIZ], *tempdir, tempfile[PATH_MAX]; ssize_t nread; int ifd, ofd; @@ -653,7 +656,7 @@ stone(int *a, int n, int *b, int *c, int flags) bound = UINT_MAX; else { sq = isqrt(n); - bound = MAX(256, sq); + bound = MAXIMUM(256, sq); } k = 0; @@ -1360,10 +1363,10 @@ dump_context_vec(FILE *f1, FILE *f2, int flags) return; b = d = 0; /* gcc */ - lowa = MAX(1, cvp->a - diff_context); - upb = MIN(len[0], context_vec_ptr->b + diff_context); - lowc = MAX(1, cvp->c - diff_context); - upd = MIN(len[1], context_vec_ptr->d + diff_context); + lowa = MAXIMUM(1, cvp->a - diff_context); + upb = MINIMUM(len[0], context_vec_ptr->b + diff_context); + lowc = MAXIMUM(1, cvp->c - diff_context); + upd = MINIMUM(len[1], context_vec_ptr->d + diff_context); diff_output("***************"); if ((flags & D_PROTOTYPE)) { @@ -1463,10 +1466,10 @@ dump_unified_vec(FILE *f1, FILE *f2, int flags) return; b = d = 0; /* gcc */ - lowa = MAX(1, cvp->a - diff_context); - upb = MIN(len[0], context_vec_ptr->b + diff_context); - lowc = MAX(1, cvp->c - diff_context); - upd = MIN(len[1], context_vec_ptr->d + diff_context); + lowa = MAXIMUM(1, cvp->a - diff_context); + upb = MINIMUM(len[0], context_vec_ptr->b + diff_context); + lowc = MAXIMUM(1, cvp->c - diff_context); + upd = MINIMUM(len[1], context_vec_ptr->d + diff_context); diff_output("@@ -"); uni_range(lowa, upb); diff --git a/usr.bin/find/function.c b/usr.bin/find/function.c index cb9542ecff8..be4e013393f 100644 --- a/usr.bin/find/function.c +++ b/usr.bin/find/function.c @@ -1,4 +1,4 @@ -/* $OpenBSD: function.c,v 1.41 2014/05/18 08:10:00 espie Exp $ */ +/* $OpenBSD: function.c,v 1.42 2015/01/16 06:40:07 deraadt Exp $ */ /*- * Copyright (c) 1990, 1993 @@ -32,8 +32,6 @@ * SUCH DAMAGE. */ -#include <sys/param.h> -#include <sys/ucred.h> #include <sys/stat.h> #include <sys/wait.h> #include <sys/mount.h> @@ -575,8 +573,8 @@ c_exec(char *unused, char ***argvp, int isok) for (p = *argv; *p; ++p) if (p[0] == '{' && p[1] == '}') { new->e_argv[cnt] = - emalloc((u_int)MAXPATHLEN); - new->e_len[cnt] = MAXPATHLEN; + emalloc((u_int)PATH_MAX); + new->e_len[cnt] = PATH_MAX; break; } if (!*p) { @@ -607,7 +605,7 @@ f_execdir(PLAN *plan, FTSENT *entry) int cnt; pid_t pid; int status, fd; - char base[MAXPATHLEN]; + char base[PATH_MAX]; /* fts(3) does not chdir for the root level so we do it ourselves. */ if (entry->fts_level == FTS_ROOTLEVEL) { @@ -693,8 +691,8 @@ c_execdir(char *ignored, char ***argvp, int unused) new->e_orig[cnt] = *argv; for (p = *argv; *p; ++p) if (p[0] == '{' && p[1] == '}') { - new->e_argv[cnt] = emalloc((u_int)MAXPATHLEN); - new->e_len[cnt] = MAXPATHLEN; + new->e_argv[cnt] = emalloc((u_int)PATH_MAX); + new->e_len[cnt] = PATH_MAX; break; } if (!*p) { diff --git a/usr.bin/find/ls.c b/usr.bin/find/ls.c index b78ae1734a7..adbc0d7e81c 100644 --- a/usr.bin/find/ls.c +++ b/usr.bin/find/ls.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ls.c,v 1.15 2014/01/10 04:53:35 guenther Exp $ */ +/* $OpenBSD: ls.c,v 1.16 2015/01/16 06:40:07 deraadt Exp $ */ /* * Copyright (c) 1989, 1993 @@ -29,7 +29,6 @@ * SUCH DAMAGE. */ -#include <sys/param.h> #include <sys/stat.h> #include <err.h> @@ -39,6 +38,7 @@ #include <time.h> #include <tzfile.h> #include <unistd.h> +#include <limits.h> #include <utmp.h> #include <pwd.h> #include <grp.h> @@ -106,7 +106,7 @@ static void printlink(char *name) { int lnklen; - char path[MAXPATHLEN]; + char path[PATH_MAX]; if ((lnklen = readlink(name, path, sizeof(path) - 1)) == -1) { warn("%s", name); diff --git a/usr.bin/finger/finger.c b/usr.bin/finger/finger.c index 8c683ed5bac..e2e2134e49d 100644 --- a/usr.bin/finger/finger.c +++ b/usr.bin/finger/finger.c @@ -1,4 +1,4 @@ -/* $OpenBSD: finger.c,v 1.18 2009/11/12 15:33:21 nicm Exp $ */ +/* $OpenBSD: finger.c,v 1.19 2015/01/16 06:40:07 deraadt Exp $ */ /* * Copyright (c) 1989 The Regents of the University of California. @@ -56,7 +56,6 @@ * well as home directory, shell, mail info, and .plan/.project files. */ -#include <sys/param.h> #include <sys/file.h> #include <sys/stat.h> #include <stdio.h> @@ -64,6 +63,7 @@ #include <string.h> #include <time.h> #include <unistd.h> +#include <limits.h> #include <err.h> #include "finger.h" #include "extern.h" @@ -80,7 +80,7 @@ main(int argc, char *argv[]) extern int optind; extern char *__progname; int ch; - char domain[MAXHOSTNAMELEN]; + char domain[HOST_NAME_MAX+1]; struct stat sb; oflag = 1; /* default to old "office" behavior */ diff --git a/usr.bin/finger/net.c b/usr.bin/finger/net.c index 62cac5d18fc..86c41211f25 100644 --- a/usr.bin/finger/net.c +++ b/usr.bin/finger/net.c @@ -1,4 +1,4 @@ -/* $OpenBSD: net.c,v 1.12 2009/10/27 23:59:38 deraadt Exp $ */ +/* $OpenBSD: net.c,v 1.13 2015/01/16 06:40:07 deraadt Exp $ */ /* * Copyright (c) 1989 The Regents of the University of California. @@ -32,7 +32,6 @@ * SUCH DAMAGE. */ -#include <sys/param.h> #include <sys/socket.h> #include <netinet/in.h> #include <arpa/inet.h> diff --git a/usr.bin/finger/util.c b/usr.bin/finger/util.c index 3b4b3654c52..6e845c1ed71 100644 --- a/usr.bin/finger/util.c +++ b/usr.bin/finger/util.c @@ -1,4 +1,4 @@ -/* $OpenBSD: util.c,v 1.29 2014/11/19 22:07:13 millert Exp $ */ +/* $OpenBSD: util.c,v 1.30 2015/01/16 06:40:07 deraadt Exp $ */ /* * Copyright (c) 1989 The Regents of the University of California. @@ -35,7 +35,6 @@ #include <sys/types.h> #include <sys/uio.h> -#include <sys/param.h> #include <sys/stat.h> #include <err.h> #include <stdio.h> diff --git a/usr.bin/from/from.c b/usr.bin/from/from.c index 17a09c15029..07abc2ce74e 100644 --- a/usr.bin/from/from.c +++ b/usr.bin/from/from.c @@ -1,4 +1,4 @@ -/* $OpenBSD: from.c,v 1.16 2013/11/27 13:32:02 okan Exp $ */ +/* $OpenBSD: from.c,v 1.17 2015/01/16 06:40:07 deraadt Exp $ */ /* $NetBSD: from.c,v 1.6 1995/09/01 01:39:10 jtc Exp $ */ /* @@ -48,8 +48,8 @@ main(int argc, char *argv[]) struct passwd *pwd; int ch, newline; char *file, *sender, *p; -#if MAXPATHLEN > BUFSIZ - char buf[MAXPATHLEN]; +#if PATH_MAX > BUFSIZ + char buf[PATH_MAX]; #else char buf[BUFSIZ]; #endif diff --git a/usr.bin/fstat/fstat.c b/usr.bin/fstat/fstat.c index ac2c501a658..bbf26c55d7a 100644 --- a/usr.bin/fstat/fstat.c +++ b/usr.bin/fstat/fstat.c @@ -1,4 +1,4 @@ -/* $OpenBSD: fstat.c,v 1.79 2014/08/20 11:23:42 mikeb Exp $ */ +/* $OpenBSD: fstat.c,v 1.80 2015/01/16 06:40:08 deraadt Exp $ */ /* * Copyright (c) 2009 Todd C. Miller <Todd.Miller@courtesan.com> @@ -45,7 +45,7 @@ * SUCH DAMAGE. */ -#include <sys/param.h> +#include <sys/types.h> #include <sys/queue.h> #include <sys/mount.h> #include <sys/stat.h> @@ -84,6 +84,8 @@ #include "fstat.h" +#define MAXIMUM(a, b) (((a) > (b)) ? (a) : (b)) + struct fileargs fileargs = SLIST_HEAD_INITIALIZER(fileargs); int fsflg; /* show files on same filesystem as file(s) argument */ @@ -480,7 +482,7 @@ pipetrans(struct kinfo_file *kf) * same visible addr. (it's the higher address because when the other * end closes, it becomes 0) */ - maxaddr = (void *)(uintptr_t)MAX(kf->f_data, kf->pipe_peer); + maxaddr = (void *)(uintptr_t)MAXIMUM(kf->f_data, kf->pipe_peer); printf("pipe "); hide(maxaddr); diff --git a/usr.bin/fstat/fuser.c b/usr.bin/fstat/fuser.c index 4824e33c936..96212e6ece3 100644 --- a/usr.bin/fstat/fuser.c +++ b/usr.bin/fstat/fuser.c @@ -1,4 +1,4 @@ -/* $OpenBSD: fuser.c,v 1.5 2014/10/26 06:03:24 guenther Exp $ */ +/* $OpenBSD: fuser.c,v 1.6 2015/01/16 06:40:08 deraadt Exp $ */ /* * Copyright (c) 2009 Todd C. Miller <Todd.Miller@courtesan.com> @@ -41,7 +41,6 @@ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include <sys/param.h> #include <sys/queue.h> #include <sys/stat.h> #include <sys/sysctl.h> diff --git a/usr.bin/ftp/cmds.c b/usr.bin/ftp/cmds.c index d918391edc5..e0dc7f24e45 100644 --- a/usr.bin/ftp/cmds.c +++ b/usr.bin/ftp/cmds.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmds.c,v 1.72 2014/08/16 07:49:27 deraadt Exp $ */ +/* $OpenBSD: cmds.c,v 1.73 2015/01/16 06:40:08 deraadt Exp $ */ /* $NetBSD: cmds.c,v 1.27 1997/08/18 10:20:15 lukem Exp $ */ /* @@ -281,7 +281,7 @@ usage: oldintr = signal(SIGINT, mabort); (void)setjmp(jabort); if (proxy) { - char *cp, *tp2, tmpbuf[MAXPATHLEN]; + char *cp, *tp2, tmpbuf[PATH_MAX]; while ((cp = remglob(argv, 0, NULL)) != NULL) { if (*cp == '\0') { @@ -696,7 +696,7 @@ setprompt(int argc, char *argv[]) void setgate(int argc, char *argv[]) { - static char gsbuf[MAXHOSTNAMELEN]; + static char gsbuf[HOST_NAME_MAX+1]; if (argc > 3) { fprintf(ttyout, "usage: %s [on | off | host [port]]\n", @@ -800,7 +800,7 @@ setdebug(int argc, char *argv[]) void lcd(int argc, char *argv[]) { - char buf[MAXPATHLEN]; + char buf[PATH_MAX]; char *oldargv1; if (argc < 2) @@ -993,7 +993,7 @@ shell(int argc, char *argv[]) { pid_t pid; sig_t old1, old2; - char shellnam[MAXPATHLEN], *shellp, *namep; + char shellnam[PATH_MAX], *shellp, *namep; int wait_status; old1 = signal (SIGINT, SIG_IGN); @@ -1120,7 +1120,7 @@ pwd(int argc, char *argv[]) void lpwd(int argc, char *argv[]) { - char buf[MAXPATHLEN]; + char buf[PATH_MAX]; if (getcwd(buf, sizeof(buf)) != NULL) fprintf(ttyout, "Local directory %s\n", buf); @@ -1462,10 +1462,10 @@ setnmap(int argc, char *argv[]) cp = strchr(altarg, ' '); } *cp = '\0'; - (void)strncpy(mapin, altarg, MAXPATHLEN - 1); + (void)strncpy(mapin, altarg, PATH_MAX - 1); while (*++cp == ' ') continue; - (void)strncpy(mapout, cp, MAXPATHLEN - 1); + (void)strncpy(mapout, cp, PATH_MAX - 1); } void diff --git a/usr.bin/ftp/complete.c b/usr.bin/ftp/complete.c index bd249f9f370..dd5c55f483e 100644 --- a/usr.bin/ftp/complete.c +++ b/usr.bin/ftp/complete.c @@ -1,4 +1,4 @@ -/* $OpenBSD: complete.c,v 1.27 2014/04/23 11:47:04 jca Exp $ */ +/* $OpenBSD: complete.c,v 1.28 2015/01/16 06:40:08 deraadt Exp $ */ /* $NetBSD: complete.c,v 1.10 1997/08/18 10:20:18 lukem Exp $ */ /*- @@ -71,7 +71,7 @@ comparstr(const void *a, const void *b) static unsigned char complete_ambiguous(char *word, int list, StringList *words) { - char insertstr[MAXPATHLEN * 2]; + char insertstr[PATH_MAX * 2]; char *lastmatch; int i, j; size_t matchlen, wordlen; @@ -151,7 +151,7 @@ static unsigned char complete_local(char *word, int list) { StringList *words; - char dir[MAXPATHLEN]; + char dir[PATH_MAX]; char *file; DIR *dd; struct dirent *dp; @@ -204,9 +204,9 @@ static unsigned char complete_remote(char *word, int list) { static StringList *dirlist; - static char lastdir[MAXPATHLEN]; + static char lastdir[PATH_MAX]; StringList *words; - char dir[MAXPATHLEN]; + char dir[PATH_MAX]; char *file, *cp; int i; unsigned char rv; diff --git a/usr.bin/ftp/fetch.c b/usr.bin/ftp/fetch.c index 20667988442..6cb9094e2a7 100644 --- a/usr.bin/ftp/fetch.c +++ b/usr.bin/ftp/fetch.c @@ -1,4 +1,4 @@ -/* $OpenBSD: fetch.c,v 1.136 2015/01/12 15:46:55 bluhm Exp $ */ +/* $OpenBSD: fetch.c,v 1.137 2015/01/16 06:40:08 deraadt Exp $ */ /* $NetBSD: fetch.c,v 1.14 1997/08/18 10:20:20 lukem Exp $ */ /*- @@ -35,7 +35,6 @@ */ #include <sys/types.h> -#include <sys/param.h> #include <sys/socket.h> #include <sys/stat.h> @@ -47,7 +46,6 @@ #include <ctype.h> #include <err.h> #include <libgen.h> -#include <limits.h> #include <netdb.h> #include <fcntl.h> #include <signal.h> @@ -1058,7 +1056,7 @@ auto_fetch(int argc, char *argv[], char *outfile) int rval, xargc; volatile int argpos; int dirhasglob, filehasglob, oautologin; - char rempath[MAXPATHLEN]; + char rempath[PATH_MAX]; argpos = 0; diff --git a/usr.bin/ftp/ftp.c b/usr.bin/ftp/ftp.c index c85627000ff..717a9164dca 100644 --- a/usr.bin/ftp/ftp.c +++ b/usr.bin/ftp/ftp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ftp.c,v 1.88 2014/10/24 02:01:20 lteo Exp $ */ +/* $OpenBSD: ftp.c,v 1.89 2015/01/16 06:40:08 deraadt Exp $ */ /* $NetBSD: ftp.c,v 1.27 1997/08/18 10:20:23 lukem Exp $ */ /* @@ -112,7 +112,7 @@ char * hookup(char *host, char *port) { int s, tos, error; - static char hostnamebuf[MAXHOSTNAMELEN]; + static char hostnamebuf[HOST_NAME_MAX+1]; struct addrinfo hints, *res, *res0, *ares; char hbuf[NI_MAXHOST]; char *cause = "unknown"; @@ -1755,7 +1755,7 @@ pswitch(int flag) sig_t oldintr; static struct comvars { int connect; - char name[MAXHOSTNAMELEN]; + char name[HOST_NAME_MAX+1]; union sockunion mctl; union sockunion hctl; FILE *in; @@ -1770,8 +1770,8 @@ pswitch(int flag) char nti[17]; char nto[17]; int mapflg; - char mi[MAXPATHLEN]; - char mo[MAXPATHLEN]; + char mi[PATH_MAX]; + char mo[PATH_MAX]; } proxstruct, tmpstruct; struct comvars *ip, *op; @@ -1996,7 +1996,7 @@ reset(int argc, char *argv[]) char * gunique(const char *local) { - static char new[MAXPATHLEN]; + static char new[PATH_MAX]; char *cp = strrchr(local, '/'); int d, count=0; char ext = '1'; diff --git a/usr.bin/ftp/ftp_var.h b/usr.bin/ftp/ftp_var.h index 7a0a279effa..3974cdeb68d 100644 --- a/usr.bin/ftp/ftp_var.h +++ b/usr.bin/ftp/ftp_var.h @@ -1,4 +1,4 @@ -/* $OpenBSD: ftp_var.h,v 1.36 2014/10/31 13:48:21 jsing Exp $ */ +/* $OpenBSD: ftp_var.h,v 1.37 2015/01/16 06:40:08 deraadt Exp $ */ /* $NetBSD: ftp_var.h,v 1.18 1997/08/18 10:20:25 lukem Exp $ */ /* @@ -65,7 +65,8 @@ * FTP global variables. */ -#include <sys/param.h> +#include <sys/signal.h> +#include <limits.h> #include <setjmp.h> #ifndef SMALL @@ -84,7 +85,7 @@ int fclose(FILE *); #include "small.h" #define HASHBYTES 1024 -#define FTPBUFLEN MAXPATHLEN + 200 +#define FTPBUFLEN PATH_MAX + 200 #define STALLTIME 5 /* # of seconds of no xfer before "stalling" */ @@ -138,8 +139,8 @@ int passivemode; /* passive mode enabled */ int activefallback; /* fall back to active mode if passive fails */ char ntin[17]; /* input translation table */ char ntout[17]; /* output translation table */ -char mapin[MAXPATHLEN]; /* input map template */ -char mapout[MAXPATHLEN]; /* output map template */ +char mapin[PATH_MAX]; /* input map template */ +char mapout[PATH_MAX]; /* output map template */ char typename[32]; /* name of file transfer type */ int type; /* requested file transfer type */ int curtype; /* current file transfer type */ diff --git a/usr.bin/ftp/main.c b/usr.bin/ftp/main.c index 43a0517faee..bbf5249058e 100644 --- a/usr.bin/ftp/main.c +++ b/usr.bin/ftp/main.c @@ -1,4 +1,4 @@ -/* $OpenBSD: main.c,v 1.95 2014/10/31 13:48:21 jsing Exp $ */ +/* $OpenBSD: main.c,v 1.96 2015/01/16 06:40:08 deraadt Exp $ */ /* $NetBSD: main.c,v 1.24 1997/08/18 10:20:26 lukem Exp $ */ /* @@ -67,7 +67,6 @@ #include <ctype.h> #include <err.h> -#include <limits.h> #include <netdb.h> #include <pwd.h> #include <stdio.h> @@ -109,7 +108,7 @@ main(volatile int argc, char *argv[]) { int ch, top, rval; struct passwd *pw = NULL; - char *cp, homedir[MAXPATHLEN]; + char *cp, homedir[PATH_MAX]; char *outfile = NULL; const char *errstr; int dumb_terminal = 0; diff --git a/usr.bin/ftp/ruserpass.c b/usr.bin/ftp/ruserpass.c index c0b31233a4b..795b3012491 100644 --- a/usr.bin/ftp/ruserpass.c +++ b/usr.bin/ftp/ruserpass.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ruserpass.c,v 1.29 2014/05/20 01:25:23 guenther Exp $ */ +/* $OpenBSD: ruserpass.c,v 1.30 2015/01/16 06:40:08 deraadt Exp $ */ /* $NetBSD: ruserpass.c,v 1.14 1997/07/20 09:46:01 lukem Exp $ */ /* @@ -75,8 +75,8 @@ static struct toktab { int ruserpass(const char *host, char **aname, char **apass, char **aacct) { - char *hdir, buf[MAXPATHLEN], *tmp; - char myname[MAXHOSTNAMELEN], *mydomain; + char *hdir, buf[PATH_MAX], *tmp; + char myname[HOST_NAME_MAX+1], *mydomain; int t, i, c, usedefault = 0; struct stat stb; diff --git a/usr.bin/ftp/small.c b/usr.bin/ftp/small.c index e959a556081..8954fe93c81 100644 --- a/usr.bin/ftp/small.c +++ b/usr.bin/ftp/small.c @@ -1,4 +1,4 @@ -/* $OpenBSD: small.c,v 1.2 2014/08/16 07:49:27 deraadt Exp $ */ +/* $OpenBSD: small.c,v 1.3 2015/01/16 06:40:08 deraadt Exp $ */ /* $NetBSD: cmds.c,v 1.27 1997/08/18 10:20:15 lukem Exp $ */ /* @@ -242,7 +242,7 @@ usage: } globargv2 = argv[2]; if (loc && mcase) { - char *tp = argv[1], *tp2, tmpbuf[MAXPATHLEN]; + char *tp = argv[1], *tp2, tmpbuf[PATH_MAX]; while (*tp && !islower(*tp)) { tp++; @@ -329,7 +329,7 @@ mget(int argc, char *argv[]) extern int optind, optreset; sig_t oldintr; int ch, xargc = 2; - char *cp, localcwd[MAXPATHLEN], *xargv[] = { argv[0], NULL, NULL }; + char *cp, localcwd[PATH_MAX], *xargv[] = { argv[0], NULL, NULL }; static int restartit = 0; #ifndef SMALL extern char *optarg; @@ -532,7 +532,7 @@ disconnect(int argc, char *argv[]) char * dotrans(char *name) { - static char new[MAXPATHLEN]; + static char new[PATH_MAX]; char *cp1, *cp2 = new; int i, ostop, found; @@ -560,7 +560,7 @@ dotrans(char *name) char * domap(char *name) { - static char new[MAXPATHLEN]; + static char new[PATH_MAX]; char *cp1 = name, *cp2 = mapin; char *tp[9], *te[9]; int i, toks[9], toknum = 0, match = 1; diff --git a/usr.bin/ftp/util.c b/usr.bin/ftp/util.c index 65dd8d6bce5..8c576580160 100644 --- a/usr.bin/ftp/util.c +++ b/usr.bin/ftp/util.c @@ -1,4 +1,4 @@ -/* $OpenBSD: util.c,v 1.67 2014/08/16 07:49:27 deraadt Exp $ */ +/* $OpenBSD: util.c,v 1.68 2015/01/16 06:40:08 deraadt Exp $ */ /* $NetBSD: util.c,v 1.12 1997/08/18 10:20:27 lukem Exp $ */ /*- @@ -66,6 +66,7 @@ /* * FTP User Program -- Misc support routines */ +#include <sys/param.h> /* BSD */ #include <sys/ioctl.h> #include <sys/time.h> #include <arpa/ftp.h> @@ -75,7 +76,6 @@ #include <errno.h> #include <fcntl.h> #include <libgen.h> -#include <limits.h> #include <glob.h> #include <pwd.h> #include <signal.h> @@ -89,6 +89,9 @@ #include "ftp_var.h" #include "pathnames.h" +#define MINIMUM(a, b) (((a) < (b)) ? (a) : (b)) +#define MAXIMUM(a, b) (((a) > (b)) ? (a) : (b)) + static void updateprogressmeter(int); /* @@ -223,8 +226,8 @@ setpeer(int argc, char *argv[]) int ftp_login(const char *host, char *user, char *pass) { - char tmp[80], *acctname = NULL, host_name[MAXHOSTNAMELEN]; - char anonpass[MAXLOGNAME + 1 + MAXHOSTNAMELEN]; /* "user@hostname" */ + char tmp[80], *acctname = NULL, host_name[HOST_NAME_MAX+1]; + char anonpass[LOGIN_NAME_MAX + 1 + HOST_NAME_MAX+1]; /* "user@hostname" */ int n, aflag = 0, retry = 0; struct passwd *pw; @@ -375,8 +378,8 @@ another(int *pargc, char ***pargv, const char *prompt) char * remglob2(char *argv[], int doswitch, char **errbuf, FILE **ftemp, char *type) { - char temp[MAXPATHLEN], *bufp, *cp, *lmode; - static char buf[MAXPATHLEN], **args; + char temp[PATH_MAX], *bufp, *cp, *lmode; + static char buf[PATH_MAX], **args; int oldverbose, oldhash, fd; if (!mflag) { @@ -687,8 +690,8 @@ remotemodtime(const char *file, int noisy) int fileindir(const char *file, const char *dir) { - char parentdirbuf[MAXPATHLEN], *parentdir; - char realdir[MAXPATHLEN]; + char parentdirbuf[PATH_MAX], *parentdir; + char realdir[PATH_MAX]; size_t dirlen; /* determine parent directory of file */ @@ -787,8 +790,8 @@ progressmeter(int flag, const char *filename) ratio = cursize * 100 / filesize; else ratio = 100; - ratio = MAX(ratio, 0); - ratio = MIN(ratio, 100); + ratio = MAXIMUM(ratio, 0); + ratio = MINIMUM(ratio, 100); if (!verbose && flag == -1) { filename = basename(filename); if (filename != NULL) diff --git a/usr.bin/getent/getent.c b/usr.bin/getent/getent.c index acade337ab2..f12291c6144 100644 --- a/usr.bin/getent/getent.c +++ b/usr.bin/getent/getent.c @@ -1,4 +1,4 @@ -/* $OpenBSD: getent.c,v 1.8 2014/10/24 10:23:32 schwarze Exp $ */ +/* $OpenBSD: getent.c,v 1.9 2015/01/16 06:40:08 deraadt Exp $ */ /* $NetBSD: getent.c,v 1.7 2005/08/24 14:31:02 ginsbach Exp $ */ /*- @@ -144,7 +144,7 @@ printfmtstrings(char *strings[], const char *prefix, const char *sep, static int ethers(int argc, char *argv[]) { - char hostname[MAXHOSTNAMELEN], *hp; + char hostname[HOST_NAME_MAX+1], *hp; int i, rv = RV_OK; struct ether_addr ea, *eap; diff --git a/usr.bin/gprof/hertz.c b/usr.bin/gprof/hertz.c index 05d1acd2f62..1fec6c35f77 100644 --- a/usr.bin/gprof/hertz.c +++ b/usr.bin/gprof/hertz.c @@ -1,4 +1,4 @@ -/* $OpenBSD: hertz.c,v 1.6 2006/03/25 19:06:36 espie Exp $ */ +/* $OpenBSD: hertz.c,v 1.7 2015/01/16 06:40:08 deraadt Exp $ */ /* * Copyright (c) 2005 Artur Grabowski <art@openbsd.org> @@ -17,7 +17,6 @@ */ -#include <sys/param.h> #include <sys/time.h> #include <sys/sysctl.h> diff --git a/usr.bin/grep/file.c b/usr.bin/grep/file.c index c590dcd4b6c..1bef79733dc 100644 --- a/usr.bin/grep/file.c +++ b/usr.bin/grep/file.c @@ -1,4 +1,4 @@ -/* $OpenBSD: file.c,v 1.11 2010/07/02 20:48:48 nicm Exp $ */ +/* $OpenBSD: file.c,v 1.12 2015/01/16 06:40:08 deraadt Exp $ */ /*- * Copyright (c) 1999 James Howard and Dag-Erling Coïdan Smørgrav @@ -26,16 +26,15 @@ * SUCH DAMAGE. */ -#include <sys/param.h> - #include <err.h> #include <stdio.h> #include <stdlib.h> +#include <limits.h> #include <zlib.h> #include "grep.h" -static char fname[MAXPATHLEN]; +static char fname[PATH_MAX]; #ifndef NOZ static char *lnbuf; static size_t lnbuflen; diff --git a/usr.bin/grep/mmfile.c b/usr.bin/grep/mmfile.c index 4a985b1d5bc..d8ef73bfa31 100644 --- a/usr.bin/grep/mmfile.c +++ b/usr.bin/grep/mmfile.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mmfile.c,v 1.15 2014/11/08 22:13:47 brad Exp $ */ +/* $OpenBSD: mmfile.c,v 1.16 2015/01/16 06:40:08 deraadt Exp $ */ /*- * Copyright (c) 1999 James Howard and Dag-Erling Coïdan Smørgrav @@ -26,7 +26,6 @@ * SUCH DAMAGE. */ -#include <sys/param.h> #include <sys/mman.h> #include <sys/stat.h> diff --git a/usr.bin/grep/queue.c b/usr.bin/grep/queue.c index 96de3b2736a..96e50abe8b4 100644 --- a/usr.bin/grep/queue.c +++ b/usr.bin/grep/queue.c @@ -1,4 +1,4 @@ -/* $OpenBSD: queue.c,v 1.6 2011/07/08 01:20:24 tedu Exp $ */ +/* $OpenBSD: queue.c,v 1.7 2015/01/16 06:40:08 deraadt Exp $ */ /*- * Copyright (c) 1999 James Howard and Dag-Erling Coïdan Smørgrav @@ -31,8 +31,6 @@ * Dodge. */ -#include <sys/param.h> - #include <stdlib.h> #include <string.h> diff --git a/usr.bin/hexdump/display.c b/usr.bin/hexdump/display.c index ce861b35a0f..db9506765c1 100644 --- a/usr.bin/hexdump/display.c +++ b/usr.bin/hexdump/display.c @@ -1,4 +1,4 @@ -/* $OpenBSD: display.c,v 1.20 2010/10/22 14:04:24 millert Exp $ */ +/* $OpenBSD: display.c,v 1.21 2015/01/16 06:40:08 deraadt Exp $ */ /* $NetBSD: display.c,v 1.12 2001/12/07 15:14:29 bjh21 Exp $ */ /* @@ -30,7 +30,6 @@ * SUCH DAMAGE. */ -#include <sys/param.h> #include <sys/stat.h> #include <ctype.h> @@ -43,6 +42,8 @@ #include "hexdump.h" +#define MINIMUM(a, b) (((a) < (b)) ? (a) : (b)) + enum _vflag vflag = FIRST; static off_t address; /* address/offset in stream */ @@ -253,7 +254,7 @@ get(void) return(curp); } n = fread((char *)curp + nread, sizeof(u_char), - length == -1 ? need : MIN(length, need), stdin); + length == -1 ? need : MINIMUM(length, need), stdin); if (!n) { if (ferror(stdin)) warn("%s", _argv[-1]); diff --git a/usr.bin/hexdump/hexdump.c b/usr.bin/hexdump/hexdump.c index 17dd5975f9c..a84a8c315bd 100644 --- a/usr.bin/hexdump/hexdump.c +++ b/usr.bin/hexdump/hexdump.c @@ -1,4 +1,4 @@ -/* $OpenBSD: hexdump.c,v 1.16 2011/09/22 09:09:42 stsp Exp $ */ +/* $OpenBSD: hexdump.c,v 1.17 2015/01/16 06:40:08 deraadt Exp $ */ /* $NetBSD: hexdump.c,v 1.7 1997/10/19 02:34:06 lukem Exp $ */ /* @@ -30,13 +30,14 @@ * SUCH DAMAGE. */ -#include <sys/param.h> #include <err.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include "hexdump.h" +#define MINIMUM(a, b) (((a) < (b)) ? (a) : (b)) + FS *fshead; /* head of format strings */ int blocksize; /* data block size */ int exitval; /* final exit value */ @@ -64,7 +65,7 @@ main(int argc, char *argv[]) blocksize = tfs->bcnt; } if (length != -1) { - iobufsiz = MIN(length, blocksize); + iobufsiz = MINIMUM(length, blocksize); if ((iobuf = malloc(iobufsiz)) == NULL) err(1, NULL); } diff --git a/usr.bin/id/id.c b/usr.bin/id/id.c index 34538f5b2d5..45461b3457a 100644 --- a/usr.bin/id/id.c +++ b/usr.bin/id/id.c @@ -1,4 +1,4 @@ -/* $OpenBSD: id.c,v 1.21 2014/07/14 05:41:00 guenther Exp $ */ +/* $OpenBSD: id.c,v 1.22 2015/01/16 06:40:08 deraadt Exp $ */ /*- * Copyright (c) 1991, 1993 @@ -29,8 +29,6 @@ * SUCH DAMAGE. */ -#include <sys/param.h> - #include <err.h> #include <errno.h> #include <grp.h> @@ -39,6 +37,7 @@ #include <stdlib.h> #include <string.h> #include <unistd.h> +#include <limits.h> void current(void); void pretty(struct passwd *); @@ -200,7 +199,7 @@ current(void) struct passwd *pw; int cnt, ngroups; uid_t uid, euid; - gid_t groups[NGROUPS], gid, egid, lastgid; + gid_t groups[NGROUPS_MAX], gid, egid, lastgid; char *prefix; uid = getuid(); @@ -221,7 +220,7 @@ current(void) if ((gr = getgrgid(egid))) (void)printf("(%s)", gr->gr_name); } - if ((ngroups = getgroups(NGROUPS, groups))) { + if ((ngroups = getgroups(NGROUPS_MAX, groups))) { for (prefix = " groups=", lastgid = (gid_t)-1, cnt = 0; cnt < ngroups; prefix = ", ", lastgid = gid) { gid = groups[cnt++]; @@ -238,7 +237,7 @@ current(void) void user(struct passwd *pw) { - gid_t gid, groups[NGROUPS + 1]; + gid_t gid, groups[NGROUPS_MAX + 1]; int cnt, ngroups; uid_t uid; struct group *gr; @@ -249,7 +248,7 @@ user(struct passwd *pw) (void)printf(" gid=%u", pw->pw_gid); if ((gr = getgrgid(pw->pw_gid))) (void)printf("(%s)", gr->gr_name); - ngroups = NGROUPS + 1; + ngroups = NGROUPS_MAX + 1; (void) getgrouplist(pw->pw_name, pw->pw_gid, groups, &ngroups); prefix = " groups="; for (cnt = 0; cnt < ngroups;) { @@ -268,16 +267,16 @@ void group(struct passwd *pw, int nflag) { int cnt, ngroups; - gid_t gid, groups[NGROUPS + 1]; + gid_t gid, groups[NGROUPS_MAX + 1]; struct group *gr; char *prefix; if (pw) { - ngroups = NGROUPS + 1; + ngroups = NGROUPS_MAX + 1; (void) getgrouplist(pw->pw_name, pw->pw_gid, groups, &ngroups); } else { groups[0] = getgid(); - ngroups = getgroups(NGROUPS, groups + 1) + 1; + ngroups = getgroups(NGROUPS_MAX, groups + 1) + 1; } prefix = ""; for (cnt = 0; cnt < ngroups;) { diff --git a/usr.bin/indent/indent.c b/usr.bin/indent/indent.c index 1bff676952b..ad33d215568 100644 --- a/usr.bin/indent/indent.c +++ b/usr.bin/indent/indent.c @@ -1,4 +1,4 @@ -/* $OpenBSD: indent.c,v 1.25 2014/07/20 01:38:40 guenther Exp $ */ +/* $OpenBSD: indent.c,v 1.26 2015/01/16 06:40:08 deraadt Exp $ */ /* * Copyright (c) 1980, 1993 @@ -32,9 +32,9 @@ * SUCH DAMAGE. */ -#include <sys/param.h> #include <fcntl.h> #include <unistd.h> +#include <limits.h> #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -48,7 +48,7 @@ char *in_name = "Standard Input"; /* will always point to name of input * file */ char *out_name = "Standard Output"; /* will always point to name * of output file */ -char bakfile[MAXPATHLEN] = ""; +char bakfile[PATH_MAX] = ""; void bakcopy(void); @@ -1178,7 +1178,7 @@ bakcopy(void) p--; if (*p == '/') p++; - if (snprintf(bakfile, MAXPATHLEN, "%s.BAK", p) >= MAXPATHLEN) + if (snprintf(bakfile, PATH_MAX, "%s.BAK", p) >= PATH_MAX) errc(1, ENAMETOOLONG, "%s.BAK", p); /* copy in_name to backup file */ diff --git a/usr.bin/ipcs/ipcs.c b/usr.bin/ipcs/ipcs.c index 4c3dbb28f86..146aa1c10cc 100644 --- a/usr.bin/ipcs/ipcs.c +++ b/usr.bin/ipcs/ipcs.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ipcs.c,v 1.25 2012/02/05 18:27:03 guenther Exp $ */ +/* $OpenBSD: ipcs.c,v 1.26 2015/01/16 06:40:08 deraadt Exp $ */ /* $NetBSD: ipcs.c,v 1.25 2000/06/16 03:58:20 simonb Exp $ */ /*- @@ -55,7 +55,7 @@ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include <sys/param.h> +#include <sys/types.h> #include <sys/sysctl.h> #define _KERNEL /* XXX */ #include <sys/ipc.h> diff --git a/usr.bin/join/join.c b/usr.bin/join/join.c index 8fd1cd57796..b7922cd8030 100644 --- a/usr.bin/join/join.c +++ b/usr.bin/join/join.c @@ -1,4 +1,4 @@ -/* $OpenBSD: join.c,v 1.23 2014/10/11 04:31:55 doug Exp $ */ +/* $OpenBSD: join.c,v 1.24 2015/01/16 06:40:08 deraadt Exp $ */ /*- * Copyright (c) 1991, 1993, 1994 @@ -33,14 +33,14 @@ * SUCH DAMAGE. */ -#include <sys/param.h> - #include <err.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <unistd.h> +#define MAXIMUM(a, b) (((a) > (b)) ? (a) : (b)) + /* * There's a structure per input file which encapsulates the state of the * file. We repeatedly read lines from each file until we've read in all @@ -347,7 +347,7 @@ slurpit(INPUT *F) if (lp->linealloc <= len + 1) { char *p; u_long newsize = lp->linealloc + - MAX(100, len + 1 - lp->linealloc); + MAXIMUM(100, len + 1 - lp->linealloc); if ((p = realloc(lp->line, newsize)) == NULL) err(1, NULL); lp->line = p; diff --git a/usr.bin/kdump/kdump.c b/usr.bin/kdump/kdump.c index 515c1f6ee68..4b33a924b73 100644 --- a/usr.bin/kdump/kdump.c +++ b/usr.bin/kdump/kdump.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kdump.c,v 1.96 2014/12/28 11:11:01 bluhm Exp $ */ +/* $OpenBSD: kdump.c,v 1.97 2015/01/16 06:40:09 deraadt Exp $ */ /*- * Copyright (c) 1988, 1993 @@ -29,8 +29,9 @@ * SUCH DAMAGE. */ -#include <sys/param.h> +#include <sys/param.h> /* MAXCOMLEN nitems */ #include <sys/time.h> +#include <sys/signal.h> #include <sys/uio.h> #include <sys/ktrace.h> #include <sys/ioctl.h> diff --git a/usr.bin/ktrace/ktrace.c b/usr.bin/ktrace/ktrace.c index d73a0b0bebe..178180822eb 100644 --- a/usr.bin/ktrace/ktrace.c +++ b/usr.bin/ktrace/ktrace.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ktrace.c,v 1.30 2014/05/24 17:04:16 deraadt Exp $ */ +/* $OpenBSD: ktrace.c,v 1.31 2015/01/16 06:40:09 deraadt Exp $ */ /* $NetBSD: ktrace.c,v 1.4 1995/08/31 23:01:44 jtc Exp $ */ /*- @@ -30,7 +30,8 @@ * SUCH DAMAGE. */ -#include <sys/param.h> +#include <sys/param.h> /* MAXCOMLEN */ +#include <sys/signal.h> #include <sys/stat.h> #include <sys/time.h> #include <sys/uio.h> diff --git a/usr.bin/ktrace/subr.c b/usr.bin/ktrace/subr.c index 251a5db5096..96bded2611a 100644 --- a/usr.bin/ktrace/subr.c +++ b/usr.bin/ktrace/subr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: subr.c,v 1.8 2013/06/01 09:51:28 miod Exp $ */ +/* $OpenBSD: subr.c,v 1.9 2015/01/16 06:40:09 deraadt Exp $ */ /* $NetBSD: subr.c,v 1.6 1995/08/31 23:01:45 jtc Exp $ */ /*- @@ -30,7 +30,7 @@ * SUCH DAMAGE. */ -#include <sys/param.h> +#include <sys/param.h> /* MAXCOMLEN */ #include <sys/file.h> #include <sys/user.h> #include <sys/proc.h> diff --git a/usr.bin/lam/lam.c b/usr.bin/lam/lam.c index 87877952fc2..bade6206216 100644 --- a/usr.bin/lam/lam.c +++ b/usr.bin/lam/lam.c @@ -1,4 +1,4 @@ -/* $OpenBSD: lam.c,v 1.16 2013/11/20 21:22:17 deraadt Exp $ */ +/* $OpenBSD: lam.c,v 1.17 2015/01/16 06:40:09 deraadt Exp $ */ /* $NetBSD: lam.c,v 1.2 1994/11/14 20:27:42 jtc Exp $ */ /*- @@ -35,7 +35,7 @@ * Author: John Kunze, UCB */ -#include <sys/param.h> +#include <sys/param.h> /* NOFILE_MAX */ #include <ctype.h> #include <err.h> diff --git a/usr.bin/last/last.c b/usr.bin/last/last.c index 44519264103..954ffbd6cfc 100644 --- a/usr.bin/last/last.c +++ b/usr.bin/last/last.c @@ -1,4 +1,4 @@ -/* $OpenBSD: last.c,v 1.44 2014/12/09 15:40:23 tedu Exp $ */ +/* $OpenBSD: last.c,v 1.45 2015/01/16 06:40:09 deraadt Exp $ */ /* $NetBSD: last.c,v 1.6 1994/12/24 16:49:02 cgd Exp $ */ /* @@ -30,7 +30,6 @@ * SUCH DAMAGE. */ -#include <sys/param.h> #include <sys/stat.h> #include <ctype.h> @@ -45,6 +44,7 @@ #include <time.h> #include <tzfile.h> #include <unistd.h> +#include <limits.h> #include <utmp.h> #define NO 0 /* false/no */ @@ -494,7 +494,7 @@ addtty(char *ttyname) void hostconv(char *arg) { - static char *hostdot, name[MAXHOSTNAMELEN]; + static char *hostdot, name[HOST_NAME_MAX+1]; static int first = 1; char *argdot; diff --git a/usr.bin/lastcomm/lastcomm.c b/usr.bin/lastcomm/lastcomm.c index 614613c4f12..9aa1dd6ece7 100644 --- a/usr.bin/lastcomm/lastcomm.c +++ b/usr.bin/lastcomm/lastcomm.c @@ -1,4 +1,4 @@ -/* $OpenBSD: lastcomm.c,v 1.19 2013/11/27 13:32:02 okan Exp $ */ +/* $OpenBSD: lastcomm.c,v 1.20 2015/01/16 06:40:09 deraadt Exp $ */ /* $NetBSD: lastcomm.c,v 1.9 1995/10/22 01:43:42 ghudson Exp $ */ /* @@ -30,7 +30,7 @@ * SUCH DAMAGE. */ -#include <sys/param.h> +#include <sys/param.h> /* NODEV */ #include <sys/stat.h> #include <sys/acct.h> diff --git a/usr.bin/leave/leave.c b/usr.bin/leave/leave.c index 9bbf6db9a1d..4a317ce3fa3 100644 --- a/usr.bin/leave/leave.c +++ b/usr.bin/leave/leave.c @@ -1,4 +1,4 @@ -/* $OpenBSD: leave.c,v 1.14 2014/11/26 18:34:51 millert Exp $ */ +/* $OpenBSD: leave.c,v 1.15 2015/01/16 06:40:09 deraadt Exp $ */ /* $NetBSD: leave.c,v 1.4 1995/07/03 16:50:13 phil Exp $ */ /* @@ -30,7 +30,6 @@ * SUCH DAMAGE. */ -#include <sys/param.h> #include <sys/time.h> #include <ctype.h> #include <err.h> diff --git a/usr.bin/lndir/lndir.c b/usr.bin/lndir/lndir.c index a6f30449824..75bcc457745 100644 --- a/usr.bin/lndir/lndir.c +++ b/usr.bin/lndir/lndir.c @@ -1,4 +1,4 @@ -/* $OpenBSD: lndir.c,v 1.20 2014/05/20 01:25:23 guenther Exp $ */ +/* $OpenBSD: lndir.c,v 1.21 2015/01/16 06:40:09 deraadt Exp $ */ /* $XConsortium: lndir.c /main/15 1995/08/30 10:56:18 gildea $ */ /* @@ -47,7 +47,6 @@ in this Software without prior written authorization from the X Consortium. % lndir ../X */ -#include <sys/param.h> #include <sys/stat.h> #include <dirent.h> @@ -58,6 +57,7 @@ in this Software without prior written authorization from the X Consortium. #include <stdlib.h> #include <string.h> #include <unistd.h> +#include <limits.h> extern char *__progname; @@ -179,8 +179,8 @@ addexcept(char *name) int dodir(char *fn, struct stat *fs, struct stat *ts, int rel) { - char buf[MAXPATHLEN + 1], symbuf[MAXPATHLEN + 1]; - char basesym[MAXPATHLEN + 1]; + char buf[PATH_MAX + 1], symbuf[PATH_MAX + 1]; + char basesym[PATH_MAX + 1]; int n_dirs, symlen, basesymlen = -1; struct stat sb, sc; struct except *cur; diff --git a/usr.bin/locate/bigram/locate.bigram.c b/usr.bin/locate/bigram/locate.bigram.c index 48d5db2836c..8e944e1c087 100644 --- a/usr.bin/locate/bigram/locate.bigram.c +++ b/usr.bin/locate/bigram/locate.bigram.c @@ -1,5 +1,5 @@ /* - * $OpenBSD: locate.bigram.c,v 1.12 2009/10/27 23:59:39 deraadt Exp $ + * $OpenBSD: locate.bigram.c,v 1.13 2015/01/16 06:40:09 deraadt Exp $ * * Copyright (c) 1995 Wolfram Schneider <wosch@FreeBSD.org>. Berlin. * Copyright (c) 1989, 1993 @@ -32,7 +32,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: locate.bigram.c,v 1.12 2009/10/27 23:59:39 deraadt Exp $ + * $Id: locate.bigram.c,v 1.13 2015/01/16 06:40:09 deraadt Exp $ */ /* @@ -45,11 +45,11 @@ #include <stdio.h> #include <stdlib.h> -#include <sys/param.h> /* for MAXPATHLEN */ +#include <limits.h> #include "locate.h" -u_char buf1[MAXPATHLEN] = " "; -u_char buf2[MAXPATHLEN]; +u_char buf1[PATH_MAX] = " "; +u_char buf2[PATH_MAX]; u_int bigram[UCHAR_MAX + 1][UCHAR_MAX + 1]; int diff --git a/usr.bin/locate/code/locate.code.c b/usr.bin/locate/code/locate.code.c index 50c42c67cae..cf2167016d4 100644 --- a/usr.bin/locate/code/locate.code.c +++ b/usr.bin/locate/code/locate.code.c @@ -1,5 +1,5 @@ /* - * $OpenBSD: locate.code.c,v 1.17 2013/11/17 20:19:36 okan Exp $ + * $OpenBSD: locate.code.c,v 1.18 2015/01/16 06:40:09 deraadt Exp $ * * Copyright (c) 1989, 1993 * The Regents of the University of California. All rights reserved. @@ -31,7 +31,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: locate.code.c,v 1.17 2013/11/17 20:19:36 okan Exp $ + * $Id: locate.code.c,v 1.18 2015/01/16 06:40:09 deraadt Exp $ */ /* @@ -78,21 +78,20 @@ * Wolfram Schneider, Berlin September 1996 */ -#include <sys/param.h> - #include <err.h> #include <errno.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <unistd.h> +#include <limits.h> #include "locate.h" #define BGBUFSIZE (NBG * 2) /* size of bigram buffer */ -u_char buf1[MAXPATHLEN] = " "; -u_char buf2[MAXPATHLEN]; +u_char buf1[PATH_MAX] = " "; +u_char buf2[PATH_MAX]; u_char bigrams[BGBUFSIZE + 1] = { 0 }; #define LOOKUP 1 /* use a lookup array instead a function, 3x faster */ diff --git a/usr.bin/locate/locate/fastfind.c b/usr.bin/locate/locate/fastfind.c index a366f4cd572..53253029fa8 100644 --- a/usr.bin/locate/locate/fastfind.c +++ b/usr.bin/locate/locate/fastfind.c @@ -1,4 +1,4 @@ -/* $OpenBSD: fastfind.c,v 1.11 2010/10/25 19:16:45 millert Exp $ */ +/* $OpenBSD: fastfind.c,v 1.12 2015/01/16 06:40:09 deraadt Exp $ */ /* * Copyright (c) 1995 Wolfram Schneider <wosch@FreeBSD.org>. Berlin. @@ -32,7 +32,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: fastfind.c,v 1.11 2010/10/25 19:16:45 millert Exp $ + * $Id: fastfind.c,v 1.12 2015/01/16 06:40:09 deraadt Exp $ */ #ifndef _LOCATE_STATISTIC_ @@ -47,7 +47,7 @@ statistic (fp, path_fcodes) u_char *p, *s; int c; int count, umlaut; - u_char bigram1[NBG], bigram2[NBG], path[MAXPATHLEN]; + u_char bigram1[NBG], bigram2[NBG], path[PATH_MAX]; for (c = 0, p = bigram1, s = bigram2; c < NBG; c++) { p[c] = check_bigram_char(getc(fp)); @@ -140,7 +140,7 @@ fastfind int c, cc; int count, found, globflag; u_char *cutoff; - u_char bigram1[NBG], bigram2[NBG], path[MAXPATHLEN]; + u_char bigram1[NBG], bigram2[NBG], path[PATH_MAX]; #ifdef FF_ICASE /* use a lookup table for case insensitive search */ diff --git a/usr.bin/locate/locate/locate.c b/usr.bin/locate/locate/locate.c index 20e83809a84..7acad40a365 100644 --- a/usr.bin/locate/locate/locate.c +++ b/usr.bin/locate/locate/locate.c @@ -1,5 +1,5 @@ /* - * $OpenBSD: locate.c,v 1.25 2012/04/13 15:13:07 ajacoutot Exp $ + * $OpenBSD: locate.c,v 1.26 2015/01/16 06:40:09 deraadt Exp $ * * Copyright (c) 1995 Wolfram Schneider <wosch@FreeBSD.org>. Berlin. * Copyright (c) 1989, 1993 @@ -32,7 +32,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: locate.c,v 1.25 2012/04/13 15:13:07 ajacoutot Exp $ + * $Id: locate.c,v 1.26 2015/01/16 06:40:09 deraadt Exp $ */ /* @@ -63,7 +63,6 @@ * in the standard 'find'. */ -#include <sys/param.h> #include <ctype.h> #include <err.h> #include <fnmatch.h> @@ -73,6 +72,7 @@ #include <stdlib.h> #include <string.h> #include <unistd.h> +#include <limits.h> #ifdef MMAP # include <sys/types.h> @@ -334,7 +334,7 @@ usage(void) void sane_count(int count) { - if (count < 0 || count >= MAXPATHLEN) { + if (count < 0 || count >= PATH_MAX) { fprintf(stderr, "locate: corrupted database\n"); exit(1); } diff --git a/usr.bin/locate/locate/util.c b/usr.bin/locate/locate/util.c index b10b7ff24f1..2c709e01e4e 100644 --- a/usr.bin/locate/locate/util.c +++ b/usr.bin/locate/locate/util.c @@ -1,4 +1,4 @@ -/* $OpenBSD: util.c,v 1.12 2014/11/16 00:04:53 tedu Exp $ +/* $OpenBSD: util.c,v 1.13 2015/01/16 06:40:09 deraadt Exp $ * * Copyright (c) 1995 Wolfram Schneider <wosch@FreeBSD.org>. Berlin. * Copyright (c) 1989, 1993 @@ -31,15 +31,15 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: util.c,v 1.12 2014/11/16 00:04:53 tedu Exp $ + * $Id: util.c,v 1.13 2015/01/16 06:40:09 deraadt Exp $ */ #include <stdlib.h> #include <string.h> #include <err.h> -#include <sys/param.h> #include <stdio.h> +#include <limits.h> #include "locate.h" @@ -242,12 +242,12 @@ getwm(p) i = u.i; - if (i > MAXPATHLEN || i < -(MAXPATHLEN)) { + if (i > PATH_MAX || i < -(PATH_MAX)) { i = ntohl(i); - if (i > MAXPATHLEN || i < -(MAXPATHLEN)) { + if (i > PATH_MAX || i < -(PATH_MAX)) { (void)fprintf(stderr, - "integer out of +-MAXPATHLEN (%d): %d\n", - MAXPATHLEN, i); + "integer out of +-PATH_MAX (%d): %d\n", + PATH_MAX, i); exit(1); } } @@ -270,12 +270,12 @@ getwf(fp) word = getw(fp); - if (word > MAXPATHLEN || word < -(MAXPATHLEN)) { + if (word > PATH_MAX || word < -(PATH_MAX)) { word = ntohl(word); - if (word > MAXPATHLEN || word < -(MAXPATHLEN)) { + if (word > PATH_MAX || word < -(PATH_MAX)) { (void)fprintf(stderr, - "integer out of +-MAXPATHLEN (%d): %d\n", - MAXPATHLEN, word); + "integer out of +-PATH_MAX (%d): %d\n", + PATH_MAX, word); exit(1); } } diff --git a/usr.bin/lock/lock.c b/usr.bin/lock/lock.c index 12d89e9a756..12276498879 100644 --- a/usr.bin/lock/lock.c +++ b/usr.bin/lock/lock.c @@ -1,4 +1,4 @@ -/* $OpenBSD: lock.c,v 1.27 2013/08/22 04:43:40 guenther Exp $ */ +/* $OpenBSD: lock.c,v 1.28 2015/01/16 06:40:09 deraadt Exp $ */ /* $NetBSD: lock.c,v 1.8 1996/05/07 18:32:31 jtc Exp $ */ /* @@ -41,7 +41,6 @@ * an argument of the form -time where time is in minutes */ -#include <sys/param.h> #include <sys/stat.h> #include <sys/time.h> #include <signal.h> @@ -55,6 +54,7 @@ #include <string.h> #include <termios.h> #include <unistd.h> +#include <limits.h> #include <login_cap.h> #include <bsd_auth.h> @@ -75,7 +75,7 @@ extern char *__progname; int main(int argc, char *argv[]) { - char hostname[MAXHOSTNAMELEN], s[BUFSIZ], s1[BUFSIZ], date[256]; + char hostname[HOST_NAME_MAX+1], s[BUFSIZ], s1[BUFSIZ], date[256]; char *p, *style, *nstyle, *ttynam; struct itimerval ntimer, otimer; int ch, sectimeout, usemine, cnt, tries = 10, backoff = 3; diff --git a/usr.bin/login/failedlogin.c b/usr.bin/login/failedlogin.c index 970c9490996..ae6a92bfe2c 100644 --- a/usr.bin/login/failedlogin.c +++ b/usr.bin/login/failedlogin.c @@ -1,4 +1,4 @@ -/* $OpenBSD: failedlogin.c,v 1.16 2013/06/01 21:06:39 deraadt Exp $ */ +/* $OpenBSD: failedlogin.c,v 1.17 2015/01/16 06:40:09 deraadt Exp $ */ /* * Copyright (c) 1996 Todd C. Miller <Todd.Miller@courtesan.com> @@ -23,7 +23,6 @@ * the last failed login was. */ -#include <sys/param.h> #include <sys/stat.h> #include <sys/time.h> diff --git a/usr.bin/login/login.c b/usr.bin/login/login.c index b0dd066b8e3..8816252d385 100644 --- a/usr.bin/login/login.c +++ b/usr.bin/login/login.c @@ -1,4 +1,4 @@ -/* $OpenBSD: login.c,v 1.62 2014/05/20 01:25:23 guenther Exp $ */ +/* $OpenBSD: login.c,v 1.63 2015/01/16 06:40:09 deraadt Exp $ */ /* $NetBSD: login.c,v 1.13 1996/05/15 23:50:16 jtc Exp $ */ /*- @@ -70,7 +70,6 @@ * login -p (preserve existing environment; for getty) */ -#include <sys/param.h> #include <sys/socket.h> #include <sys/stat.h> #include <sys/time.h> @@ -93,6 +92,7 @@ #include <ttyent.h> #include <tzfile.h> #include <unistd.h> +#include <limits.h> #include <utmp.h> #include <util.h> #include <bsd_auth.h> @@ -138,8 +138,8 @@ main(int argc, char *argv[]) { char *domain, *p, *ttyn, *shell, *fullname, *instance; char *lipaddr, *script, *ripaddr, *style, *type, *fqdn; - char tbuf[MAXPATHLEN + 2], tname[sizeof(_PATH_TTY) + 10]; - char localhost[MAXHOSTNAMELEN], *copyright; + char tbuf[PATH_MAX + 2], tname[sizeof(_PATH_TTY) + 10]; + char localhost[HOST_NAME_MAX+1], *copyright; char mail[sizeof(_PATH_MAILDIR) + 1 + NAME_MAX]; int ask, ch, cnt, fflag, pflag, quietlog, rootlogin, lastchance; int error, homeless, needto, authok, tries, backoff; @@ -565,7 +565,7 @@ failed: shell = login_getcapstr(lc, "shell", pwd->pw_shell, pwd->pw_shell); if (*shell == '\0') shell = _PATH_BSHELL; - else if (strlen(shell) >= MAXPATHLEN) { + else if (strlen(shell) >= PATH_MAX) { syslog(LOG_ERR, "shell path too long: %s", shell); warnx("invalid shell"); quickexit(1); diff --git a/usr.bin/m4/gnum4.c b/usr.bin/m4/gnum4.c index 612c21c9617..4837cf8b14b 100644 --- a/usr.bin/m4/gnum4.c +++ b/usr.bin/m4/gnum4.c @@ -1,4 +1,4 @@ -/* $OpenBSD: gnum4.c,v 1.46 2014/07/10 14:12:31 espie Exp $ */ +/* $OpenBSD: gnum4.c,v 1.47 2015/01/16 06:40:09 deraadt Exp $ */ /* * Copyright (c) 1999 Marc Espie @@ -29,7 +29,6 @@ * functions needed to support gnu-m4 extensions, including a fake freezing */ -#include <sys/param.h> #include <sys/types.h> #include <sys/wait.h> #include <ctype.h> @@ -42,6 +41,7 @@ #include <string.h> #include <errno.h> #include <unistd.h> +#include <limits.h> #include "mdef.h" #include "stdd.h" #include "extern.h" @@ -124,7 +124,7 @@ static struct input_file * dopath(struct input_file *i, const char *filename) { - char path[MAXPATHLEN]; + char path[PATH_MAX]; struct path_entry *pe; FILE *f; diff --git a/usr.bin/mail/aux.c b/usr.bin/mail/aux.c index 3c6e961f59f..31a6d9b7643 100644 --- a/usr.bin/mail/aux.c +++ b/usr.bin/mail/aux.c @@ -1,4 +1,4 @@ -/* $OpenBSD: aux.c,v 1.26 2014/01/17 18:42:30 okan Exp $ */ +/* $OpenBSD: aux.c,v 1.27 2015/01/16 06:40:09 deraadt Exp $ */ /* $NetBSD: aux.c,v 1.5 1997/05/13 06:15:52 mikel Exp $ */ /* @@ -260,7 +260,7 @@ struct sstack { FILE *s_file; /* File we were in. */ int s_cond; /* Saved state of conditionals */ int s_loading; /* Loading .mailrc, etc. */ -} sstack[NOFILE]; +} sstack[OPEN_MAX]; /* * Pushdown current input file and switch to a new one. @@ -280,7 +280,7 @@ source(void *v) warn("%s", cp); return(1); } - if (ssp >= NOFILE - 1) { + if (ssp >= OPEN_MAX - 1) { puts("Too much \"sourcing\" going on."); (void)Fclose(fi); return(1); diff --git a/usr.bin/mail/def.h b/usr.bin/mail/def.h index 322be15ad85..17bdaf54eb5 100644 --- a/usr.bin/mail/def.h +++ b/usr.bin/mail/def.h @@ -1,4 +1,4 @@ -/* $OpenBSD: def.h,v 1.13 2003/06/25 15:13:32 millert Exp $ */ +/* $OpenBSD: def.h,v 1.14 2015/01/16 06:40:09 deraadt Exp $ */ /* $NetBSD: def.h,v 1.9 1996/12/28 07:11:00 tls Exp $ */ /* @@ -30,7 +30,7 @@ * SUCH DAMAGE. * * @(#)def.h 8.4 (Berkeley) 4/20/95 - * $OpenBSD: def.h,v 1.13 2003/06/25 15:13:32 millert Exp $ + * $OpenBSD: def.h,v 1.14 2015/01/16 06:40:09 deraadt Exp $ */ /* @@ -42,7 +42,6 @@ #ifndef MAIL_DEF_H #define MAIL_DEF_H -#include <sys/param.h> #include <sys/stat.h> #include <sys/time.h> @@ -54,6 +53,7 @@ #include <string.h> #include <termios.h> #include <unistd.h> +#include <limits.h> #include <vis.h> #include "pathnames.h" @@ -61,7 +61,7 @@ #define ESCAPE '~' /* Default escape for sending */ #define NMLSIZE 1024 /* max names in a message list */ -#define PATHSIZE MAXPATHLEN /* Size of pathnames throughout */ +#define PATHSIZE PATH_MAX /* Size of pathnames throughout */ #define HSHSIZE 59 /* Hash size for aliases and vars */ #define LINESIZE BUFSIZ /* max readable line width */ #define STRINGSIZE ((unsigned) 128)/* Dynamic allocation units */ diff --git a/usr.bin/mail/main.c b/usr.bin/mail/main.c index d7faa687972..2dfde98ef28 100644 --- a/usr.bin/mail/main.c +++ b/usr.bin/mail/main.c @@ -1,4 +1,4 @@ -/* $OpenBSD: main.c,v 1.26 2014/12/16 18:37:17 millert Exp $ */ +/* $OpenBSD: main.c,v 1.27 2015/01/16 06:40:09 deraadt Exp $ */ /* $NetBSD: main.c,v 1.7 1997/05/13 06:15:57 mikel Exp $ */ /* @@ -84,7 +84,7 @@ main(int argc, char **argv) /* * Next argument is person to pretend to be. */ - if (strlen(optarg) >= MAXLOGNAME) + if (strlen(optarg) >= LOGIN_NAME_MAX) errx(1, "username `%s' too long", optarg); unsetenv("MAIL"); myname = optarg; diff --git a/usr.bin/mail/popen.c b/usr.bin/mail/popen.c index 5a1cd561ef1..2ce59fe2e8d 100644 --- a/usr.bin/mail/popen.c +++ b/usr.bin/mail/popen.c @@ -1,4 +1,4 @@ -/* $OpenBSD: popen.c,v 1.36 2013/04/29 00:28:23 okan Exp $ */ +/* $OpenBSD: popen.c,v 1.37 2015/01/16 06:40:09 deraadt Exp $ */ /* $NetBSD: popen.c,v 1.6 1997/05/13 06:48:42 mikel Exp $ */ /* @@ -434,7 +434,7 @@ handle_spool_locks(int action) lockfp = NULL; } else if (action == 1) { char *cmd; - char buf[sizeof(_PATH_LOCKSPOOL) + MAXLOGNAME + 1]; + char buf[sizeof(_PATH_LOCKSPOOL) + LOGIN_NAME_MAX + 1]; /* XXX - lockspool requires root for user arg, we do not */ if (uflag) { diff --git a/usr.bin/man/man.c b/usr.bin/man/man.c index 812df45309f..ed380019bbb 100644 --- a/usr.bin/man/man.c +++ b/usr.bin/man/man.c @@ -1,4 +1,4 @@ -/* $OpenBSD: man.c,v 1.48 2013/07/01 18:47:39 schwarze Exp $ */ +/* $OpenBSD: man.c,v 1.49 2015/01/16 06:40:09 deraadt Exp $ */ /* $NetBSD: man.c,v 1.7 1995/09/28 06:05:34 tls Exp $ */ /* @@ -47,7 +47,6 @@ */ #include <sys/types.h> -#include <sys/param.h> #include <sys/queue.h> #include <sys/stat.h> diff --git a/usr.bin/netstat/if.c b/usr.bin/netstat/if.c index 90e392da783..675f33f3982 100644 --- a/usr.bin/netstat/if.c +++ b/usr.bin/netstat/if.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if.c,v 1.69 2014/11/21 17:49:00 mikeb Exp $ */ +/* $OpenBSD: if.c,v 1.70 2015/01/16 06:40:09 deraadt Exp $ */ /* $NetBSD: if.c,v 1.16.4.2 1996/06/07 21:46:46 thorpej Exp $ */ /* @@ -30,7 +30,7 @@ * SUCH DAMAGE. */ -#include <sys/param.h> +#include <sys/param.h> /* roundup() */ #include <sys/types.h> #include <sys/ioctl.h> #include <sys/protosw.h> diff --git a/usr.bin/netstat/inet.c b/usr.bin/netstat/inet.c index cfebd8fe33d..af3d0a76582 100644 --- a/usr.bin/netstat/inet.c +++ b/usr.bin/netstat/inet.c @@ -1,4 +1,4 @@ -/* $OpenBSD: inet.c,v 1.137 2014/11/03 17:20:46 bluhm Exp $ */ +/* $OpenBSD: inet.c,v 1.138 2015/01/16 06:40:09 deraadt Exp $ */ /* $NetBSD: inet.c,v 1.14 1995/10/03 21:42:37 thorpej Exp $ */ /* @@ -30,7 +30,6 @@ * SUCH DAMAGE. */ -#include <sys/param.h> #include <sys/queue.h> #include <sys/socket.h> #include <sys/socketvar.h> @@ -802,7 +801,7 @@ inetname(struct in_addr *inp) char *cp; static char line[50]; struct hostent *hp; - static char domain[MAXHOSTNAMELEN]; + static char domain[HOST_NAME_MAX+1]; static int first = 1; if (first && !nflag) { diff --git a/usr.bin/netstat/inet6.c b/usr.bin/netstat/inet6.c index a321ae369cc..124e28cd57a 100644 --- a/usr.bin/netstat/inet6.c +++ b/usr.bin/netstat/inet6.c @@ -1,4 +1,4 @@ -/* $OpenBSD: inet6.c,v 1.46 2014/08/14 12:55:50 mpi Exp $ */ +/* $OpenBSD: inet6.c,v 1.47 2015/01/16 06:40:10 deraadt Exp $ */ /* BSDI inet.c,v 2.3 1995/10/24 02:19:29 prb Exp */ /* * Copyright (c) 1983, 1988, 1993 @@ -29,7 +29,7 @@ * SUCH DAMAGE. */ -#include <sys/param.h> +#include <sys/types.h> #include <sys/socket.h> #include <sys/socketvar.h> #include <sys/ioctl.h> @@ -60,6 +60,7 @@ #include <stdio.h> #include <string.h> #include <unistd.h> +#include <limits.h> #include "netstat.h" struct socket sockb; @@ -1113,7 +1114,7 @@ inet6name(struct in6_addr *in6p) char *cp; static char line[NI_MAXHOST]; struct hostent *hp; - static char domain[MAXHOSTNAMELEN]; + static char domain[HOST_NAME_MAX+1]; static int first = 1; char hbuf[NI_MAXHOST]; struct sockaddr_in6 sin6; diff --git a/usr.bin/netstat/main.c b/usr.bin/netstat/main.c index f3074c99ef9..5b0eb1f0bec 100644 --- a/usr.bin/netstat/main.c +++ b/usr.bin/netstat/main.c @@ -1,4 +1,4 @@ -/* $OpenBSD: main.c,v 1.102 2014/10/23 16:45:57 schwarze Exp $ */ +/* $OpenBSD: main.c,v 1.103 2015/01/16 06:40:10 deraadt Exp $ */ /* $NetBSD: main.c,v 1.9 1996/05/07 02:55:02 thorpej Exp $ */ /* @@ -30,7 +30,7 @@ * SUCH DAMAGE. */ -#include <sys/param.h> +#include <sys/types.h> #include <sys/protosw.h> #include <sys/socket.h> #include <sys/sysctl.h> diff --git a/usr.bin/netstat/mbuf.c b/usr.bin/netstat/mbuf.c index 38e784fb80b..5d19182215a 100644 --- a/usr.bin/netstat/mbuf.c +++ b/usr.bin/netstat/mbuf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mbuf.c,v 1.33 2014/11/06 12:50:55 dlg Exp $ */ +/* $OpenBSD: mbuf.c,v 1.34 2015/01/16 06:40:10 deraadt Exp $ */ /* $NetBSD: mbuf.c,v 1.9 1996/05/07 02:55:03 thorpej Exp $ */ /* @@ -30,7 +30,7 @@ * SUCH DAMAGE. */ -#include <sys/param.h> +#include <sys/param.h> /* MSIZE */ #include <sys/protosw.h> #include <sys/socket.h> #include <sys/mbuf.h> diff --git a/usr.bin/netstat/mroute.c b/usr.bin/netstat/mroute.c index 97f9275f988..48d5bee3bae 100644 --- a/usr.bin/netstat/mroute.c +++ b/usr.bin/netstat/mroute.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mroute.c,v 1.22 2014/08/14 12:34:04 mpi Exp $ */ +/* $OpenBSD: mroute.c,v 1.23 2015/01/16 06:40:10 deraadt Exp $ */ /* $NetBSD: mroute.c,v 1.10 1996/05/11 13:51:27 mycroft Exp $ */ /* @@ -42,7 +42,7 @@ * MROUTING 1.0 */ -#include <sys/param.h> +#include <sys/types.h> #include <sys/socket.h> #include <sys/socketvar.h> #include <sys/protosw.h> diff --git a/usr.bin/netstat/mroute6.c b/usr.bin/netstat/mroute6.c index 438d04b17c7..79f824b8026 100644 --- a/usr.bin/netstat/mroute6.c +++ b/usr.bin/netstat/mroute6.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mroute6.c,v 1.14 2014/11/21 17:49:00 mikeb Exp $ */ +/* $OpenBSD: mroute6.c,v 1.15 2015/01/16 06:40:10 deraadt Exp $ */ /* * Copyright (C) 1998 WIDE Project. @@ -64,7 +64,7 @@ * @(#)mroute.c 8.2 (Berkeley) 4/28/95 */ -#include <sys/param.h> +#include <sys/types.h> #include <sys/queue.h> #include <sys/socket.h> #include <sys/protosw.h> diff --git a/usr.bin/netstat/net80211.c b/usr.bin/netstat/net80211.c index 6cf8a4413f6..07129060b08 100644 --- a/usr.bin/netstat/net80211.c +++ b/usr.bin/netstat/net80211.c @@ -1,4 +1,4 @@ -/* $OpenBSD: net80211.c,v 1.12 2014/11/21 17:49:00 mikeb Exp $ */ +/* $OpenBSD: net80211.c,v 1.13 2015/01/16 06:40:10 deraadt Exp $ */ /* * Copyright (c) 2005 Reyk Floeter <reyk@openbsd.org> @@ -16,7 +16,7 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#include <sys/param.h> +#include <sys/types.h> #include <sys/time.h> #include <sys/socket.h> #include <sys/file.h> diff --git a/usr.bin/netstat/route.c b/usr.bin/netstat/route.c index 004d2794410..dabfdcc0a9d 100644 --- a/usr.bin/netstat/route.c +++ b/usr.bin/netstat/route.c @@ -1,4 +1,4 @@ -/* $OpenBSD: route.c,v 1.94 2014/12/26 05:47:23 tedu Exp $ */ +/* $OpenBSD: route.c,v 1.95 2015/01/16 06:40:10 deraadt Exp $ */ /* $NetBSD: route.c,v 1.15 1996/05/07 02:55:06 thorpej Exp $ */ /* @@ -30,7 +30,7 @@ * SUCH DAMAGE. */ -#include <sys/param.h> +#include <sys/types.h> #include <sys/protosw.h> #include <sys/socket.h> diff --git a/usr.bin/netstat/show.c b/usr.bin/netstat/show.c index e27e30198e1..8099bfcb182 100644 --- a/usr.bin/netstat/show.c +++ b/usr.bin/netstat/show.c @@ -1,4 +1,4 @@ -/* $OpenBSD: show.c,v 1.43 2014/10/23 16:45:57 schwarze Exp $ */ +/* $OpenBSD: show.c,v 1.44 2015/01/16 06:40:10 deraadt Exp $ */ /* $NetBSD: show.c,v 1.1 1996/11/15 18:01:41 gwr Exp $ */ /* @@ -30,7 +30,6 @@ * SUCH DAMAGE. */ -#include <sys/param.h> #include <sys/socket.h> #include <sys/sysctl.h> @@ -53,6 +52,7 @@ #include <stdlib.h> #include <string.h> #include <unistd.h> +#include <limits.h> #include "netstat.h" @@ -563,8 +563,8 @@ p_sockaddr(struct sockaddr *sa, struct sockaddr *mask, int flags, int width) } } -static char line[MAXHOSTNAMELEN]; -static char domain[MAXHOSTNAMELEN]; +static char line[HOST_NAME_MAX+1]; +static char domain[HOST_NAME_MAX+1]; void p_sockaddr_mpls(struct sockaddr *in, struct sockaddr *out, int flags, int width) diff --git a/usr.bin/netstat/unix.c b/usr.bin/netstat/unix.c index e92a88bf5f3..c422a30b6b6 100644 --- a/usr.bin/netstat/unix.c +++ b/usr.bin/netstat/unix.c @@ -1,4 +1,4 @@ -/* $OpenBSD: unix.c,v 1.23 2014/07/10 14:08:13 deraadt Exp $ */ +/* $OpenBSD: unix.c,v 1.24 2015/01/16 06:40:10 deraadt Exp $ */ /* $NetBSD: unix.c,v 1.13 1995/10/03 21:42:48 thorpej Exp $ */ /*- @@ -33,7 +33,7 @@ /* * Display protocol blocks in the unix domain. */ -#include <sys/param.h> +#include <sys/param.h> /* MSIZE */ #include <sys/protosw.h> #include <sys/socket.h> #include <sys/socketvar.h> diff --git a/usr.bin/newsyslog/newsyslog.c b/usr.bin/newsyslog/newsyslog.c index 2527c5a87d8..95bcdcfd785 100644 --- a/usr.bin/newsyslog/newsyslog.c +++ b/usr.bin/newsyslog/newsyslog.c @@ -1,4 +1,4 @@ -/* $OpenBSD: newsyslog.c,v 1.92 2013/11/26 13:19:07 deraadt Exp $ */ +/* $OpenBSD: newsyslog.c,v 1.93 2015/01/16 06:40:10 deraadt Exp $ */ /* * Copyright (c) 1999, 2002, 2003 Todd C. Miller <Todd.Miller@courtesan.com> @@ -90,7 +90,7 @@ #define SENDMAIL "/usr/lib/sendmail" #endif -#include <sys/param.h> +#include <sys/param.h> /* DEV_BSIZE */ #include <sys/stat.h> #include <sys/time.h> #include <sys/wait.h> @@ -153,7 +153,7 @@ int monitormode = 0; /* Don't do monitoring by default */ int force = 0; /* Force the logs to be rotated */ char *conf = CONF; /* Configuration file to use */ time_t timenow; -char hostname[MAXHOSTNAMELEN]; /* Hostname */ +char hostname[HOST_NAME_MAX+1]; /* Hostname */ char *daytime; /* timenow in human readable form */ char *arcdir; /* Dir to put archives in (if it exists) */ @@ -648,7 +648,7 @@ parse_file(int *nentries) break; if (*q == '/') { *(parse = son(parse)) = '\0'; - if (strlen(q) >= MAXPATHLEN) + if (strlen(q) >= PATH_MAX) errx(1, "%s:%d: pathname too long: %s", conf, lineno, q); working->pidfile = strdup(q); @@ -714,17 +714,17 @@ parse_file(int *nentries) } else working->backdir = NULL; - /* Make sure we can't oflow MAXPATHLEN */ + /* Make sure we can't oflow PATH_MAX */ if (working->backdir != NULL) { if (snprintf(line, sizeof(line), "%s/%s.%d%s", working->backdir, working->logbase, - working->numlogs, COMPRESS_POSTFIX) >= MAXPATHLEN) + working->numlogs, COMPRESS_POSTFIX) >= PATH_MAX) errx(1, "%s:%d: pathname too long: %s", conf, lineno, q); } else { if (snprintf(line, sizeof(line), "%s.%d%s", working->log, working->numlogs, COMPRESS_POSTFIX) - >= MAXPATHLEN) + >= PATH_MAX) errx(1, "%s:%d: pathname too long: %s", conf, lineno, working->log); } @@ -749,7 +749,7 @@ missing_field(char *p, char *errline, int lineno) void rotate(struct conf_entry *ent, const char *oldlog) { - char file1[MAXPATHLEN], file2[MAXPATHLEN], *suffix; + char file1[PATH_MAX], file2[PATH_MAX], *suffix; int numdays = ent->numlogs - 1; int done = 0; @@ -798,7 +798,7 @@ rotate(struct conf_entry *ent, const char *oldlog) void dotrim(struct conf_entry *ent) { - char file1[MAXPATHLEN], file2[MAXPATHLEN], oldlog[MAXPATHLEN]; + char file1[PATH_MAX], file2[PATH_MAX], oldlog[PATH_MAX]; int fd; /* Is there a separate backup dir? */ @@ -871,7 +871,7 @@ log_trim(char *log) void compress_log(struct conf_entry *ent) { - char *base, tmp[MAXPATHLEN]; + char *base, tmp[PATH_MAX]; pid_t pid; if (ent->backdir != NULL) @@ -913,7 +913,7 @@ sizefile(struct stat *sb) int age_old_log(struct conf_entry *ent) { - char file[MAXPATHLEN]; + char file[PATH_MAX]; struct stat sb; if (ent->backdir != NULL) @@ -967,7 +967,7 @@ isnumberstr(char *string) int domonitor(struct conf_entry *ent) { - char fname[MAXPATHLEN], *flog, *p, *rb = NULL; + char fname[PATH_MAX], *flog, *p, *rb = NULL; struct stat sb, tsb; off_t osize; FILE *fp; diff --git a/usr.bin/nfsstat/nfsstat.c b/usr.bin/nfsstat/nfsstat.c index e0c44250f2f..878a0eed164 100644 --- a/usr.bin/nfsstat/nfsstat.c +++ b/usr.bin/nfsstat/nfsstat.c @@ -1,4 +1,4 @@ -/* $OpenBSD: nfsstat.c,v 1.33 2009/10/27 23:59:40 deraadt Exp $ */ +/* $OpenBSD: nfsstat.c,v 1.34 2015/01/16 06:40:10 deraadt Exp $ */ /* $NetBSD: nfsstat.c,v 1.7 1996/03/03 17:21:30 thorpej Exp $ */ /* @@ -33,7 +33,7 @@ * SUCH DAMAGE. */ -#include <sys/param.h> +#include <sys/types.h> #include <sys/mount.h> #include <sys/sysctl.h> #include <nfs/rpcv2.h> diff --git a/usr.bin/nm/elf.c b/usr.bin/nm/elf.c index 7e323d31de8..74b3bd35979 100644 --- a/usr.bin/nm/elf.c +++ b/usr.bin/nm/elf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: elf.c,v 1.23 2013/11/26 13:19:07 deraadt Exp $ */ +/* $OpenBSD: elf.c,v 1.24 2015/01/16 06:40:10 deraadt Exp $ */ /* * Copyright (c) 2003 Michael Shalayeff @@ -26,7 +26,6 @@ * THE POSSIBILITY OF SUCH DAMAGE. */ -#include <sys/param.h> #include <sys/mman.h> #include <unistd.h> #include <a.out.h> @@ -36,6 +35,7 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> +#include <limits.h> #include <ctype.h> #include "elfuncs.h" #include "util.h" diff --git a/usr.bin/nm/nm.c b/usr.bin/nm/nm.c index a9622b67cad..3937f4926c1 100644 --- a/usr.bin/nm/nm.c +++ b/usr.bin/nm/nm.c @@ -1,4 +1,4 @@ -/* $OpenBSD: nm.c,v 1.41 2014/04/28 18:49:28 miod Exp $ */ +/* $OpenBSD: nm.c,v 1.42 2015/01/16 06:40:10 deraadt Exp $ */ /* $NetBSD: nm.c,v 1.7 1996/01/14 23:04:03 pk Exp $ */ /* @@ -33,7 +33,7 @@ * SUCH DAMAGE. */ -#include <sys/param.h> +#include <sys/types.h> #include <sys/mman.h> #include <a.out.h> #include <elf_abi.h> diff --git a/usr.bin/nohup/nohup.c b/usr.bin/nohup/nohup.c index bb4f9d389ee..dd9a158d169 100644 --- a/usr.bin/nohup/nohup.c +++ b/usr.bin/nohup/nohup.c @@ -1,4 +1,4 @@ -/* $OpenBSD: nohup.c,v 1.14 2009/10/27 23:59:41 deraadt Exp $ */ +/* $OpenBSD: nohup.c,v 1.15 2015/01/16 06:40:10 deraadt Exp $ */ /* $NetBSD: nohup.c,v 1.6 1995/08/31 23:35:25 jtc Exp $ */ /* @@ -30,7 +30,6 @@ * SUCH DAMAGE. */ -#include <sys/param.h> #include <sys/file.h> #include <sys/stat.h> #include <fcntl.h> @@ -40,6 +39,7 @@ #include <stdlib.h> #include <string.h> #include <errno.h> +#include <limits.h> #include <err.h> static void dofile(void); @@ -100,7 +100,7 @@ dofile(void) { int fd; const char *p; - char path[MAXPATHLEN]; + char path[PATH_MAX]; p = FILENAME; if ((fd = open(p, O_RDWR|O_CREAT|O_APPEND, S_IRUSR|S_IWUSR)) >= 0) diff --git a/usr.bin/passwd/yp_passwd.c b/usr.bin/passwd/yp_passwd.c index 2765eef00e2..de9a6603edf 100644 --- a/usr.bin/passwd/yp_passwd.c +++ b/usr.bin/passwd/yp_passwd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: yp_passwd.c,v 1.34 2014/11/21 05:13:44 tedu Exp $ */ +/* $OpenBSD: yp_passwd.c,v 1.35 2015/01/16 06:40:10 deraadt Exp $ */ /* * Copyright (c) 1988 The Regents of the University of California. @@ -39,6 +39,7 @@ #include <time.h> #include <pwd.h> #include <err.h> +#include <signal.h> #include <errno.h> #include <ctype.h> #include <login_cap.h> diff --git a/usr.bin/patch/util.c b/usr.bin/patch/util.c index 4db53a42b5b..ee6e5d12a9f 100644 --- a/usr.bin/patch/util.c +++ b/usr.bin/patch/util.c @@ -1,4 +1,4 @@ -/* $OpenBSD: util.c,v 1.38 2014/12/13 10:31:07 tobias Exp $ */ +/* $OpenBSD: util.c,v 1.39 2015/01/16 06:40:10 deraadt Exp $ */ /* * patch - a program to apply diffs to original files @@ -26,7 +26,6 @@ * behaviour */ -#include <sys/param.h> #include <sys/stat.h> #include <ctype.h> @@ -95,7 +94,7 @@ int backup_file(const char *orig) { struct stat filestat; - char bakname[MAXPATHLEN], *s, *simplename; + char bakname[PATH_MAX], *s, *simplename; dev_t orig_device; ino_t orig_inode; @@ -396,7 +395,7 @@ fetchname(const char *at, bool *exists, int strip_leading) char * checked_in(char *file) { - char *filebase, *filedir, tmpbuf[MAXPATHLEN]; + char *filebase, *filedir, tmpbuf[PATH_MAX]; struct stat filestat; filebase = basename(file); diff --git a/usr.bin/pctr/pctr.c b/usr.bin/pctr/pctr.c index 017dc5dd92a..85af51e7368 100644 --- a/usr.bin/pctr/pctr.c +++ b/usr.bin/pctr/pctr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pctr.c,v 1.20 2008/07/08 21:39:52 sobrado Exp $ */ +/* $OpenBSD: pctr.c,v 1.21 2015/01/16 06:40:10 deraadt Exp $ */ /* * Copyright (c) 2007 Mike Belopuhov, Aleksey Lomovtsev @@ -25,7 +25,6 @@ * OpenBSD project by leaving this copyright notice intact. */ -#include <sys/param.h> #include <sys/types.h> #include <sys/stat.h> #include <sys/sysctl.h> diff --git a/usr.bin/pkill/pkill.c b/usr.bin/pkill/pkill.c index df349bb0980..b03b7075d4c 100644 --- a/usr.bin/pkill/pkill.c +++ b/usr.bin/pkill/pkill.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pkill.c,v 1.35 2014/05/07 01:27:42 tedu Exp $ */ +/* $OpenBSD: pkill.c,v 1.36 2015/01/16 06:40:10 deraadt Exp $ */ /* $NetBSD: pkill.c,v 1.5 2002/10/27 11:49:34 kleink Exp $ */ /*- @@ -30,8 +30,8 @@ * POSSIBILITY OF SUCH DAMAGE. */ +#include <sys/param.h> /* MAXCOMLEN */ #include <sys/types.h> -#include <sys/param.h> #include <sys/sysctl.h> #include <sys/proc.h> #include <sys/queue.h> @@ -540,7 +540,7 @@ makelist(struct listhead *head, enum listtype type, char *src) struct passwd *pw; struct group *gr; struct stat st; - char *sp, *p, buf[MAXPATHLEN]; + char *sp, *p, buf[PATH_MAX]; int empty; empty = 1; diff --git a/usr.bin/quota/quota.c b/usr.bin/quota/quota.c index b2038ff9752..e122b9975dd 100644 --- a/usr.bin/quota/quota.c +++ b/usr.bin/quota/quota.c @@ -1,4 +1,4 @@ -/* $OpenBSD: quota.c,v 1.32 2013/11/26 13:19:07 deraadt Exp $ */ +/* $OpenBSD: quota.c,v 1.33 2015/01/16 06:40:10 deraadt Exp $ */ /* * Copyright (c) 1980, 1990, 1993 @@ -35,7 +35,7 @@ /* * Disk quota reporting program. */ -#include <sys/param.h> +#include <sys/param.h> /* DEV_BSIZE */ #include <sys/types.h> #include <sys/file.h> #include <sys/stat.h> @@ -67,7 +67,7 @@ struct quotause { struct quotause *next; long flags; struct dqblk dqblk; - char fsname[MAXPATHLEN + 1]; + char fsname[PATH_MAX + 1]; }; #define FOUND 0x01 diff --git a/usr.bin/rcs/ci.c b/usr.bin/rcs/ci.c index 1ddaf3392d6..1ec9aeceed1 100644 --- a/usr.bin/rcs/ci.c +++ b/usr.bin/rcs/ci.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ci.c,v 1.218 2014/10/02 06:23:15 otto Exp $ */ +/* $OpenBSD: ci.c,v 1.219 2015/01/16 06:40:11 deraadt Exp $ */ /* * Copyright (c) 2005, 2006 Niall O'Higgins <niallo@openbsd.org> * All rights reserved. @@ -70,7 +70,7 @@ struct checkin_params { RCSFILE *file; RCSNUM *frev, *newrev; const char *description, *symbol; - char fpath[MAXPATHLEN], *rcs_msg, *username, *filename; + char fpath[PATH_MAX], *rcs_msg, *username, *filename; char *author, *state; BUF *deltatext; }; diff --git a/usr.bin/rcs/co.c b/usr.bin/rcs/co.c index 1d3cdc5acf4..ce050de96a5 100644 --- a/usr.bin/rcs/co.c +++ b/usr.bin/rcs/co.c @@ -1,4 +1,4 @@ -/* $OpenBSD: co.c,v 1.119 2014/10/10 08:15:25 otto Exp $ */ +/* $OpenBSD: co.c,v 1.120 2015/01/16 06:40:11 deraadt Exp $ */ /* * Copyright (c) 2005 Joris Vink <joris@openbsd.org> * All rights reserved. @@ -50,7 +50,7 @@ checkout_main(int argc, char **argv) RCSNUM *rev; RCSFILE *file; const char *author, *date, *state; - char fpath[MAXPATHLEN]; + char fpath[PATH_MAX]; char *rev_str, *username; time_t rcs_mtime = -1; diff --git a/usr.bin/rcs/diff.c b/usr.bin/rcs/diff.c index b19dcd1224c..1d0a4577166 100644 --- a/usr.bin/rcs/diff.c +++ b/usr.bin/rcs/diff.c @@ -1,4 +1,4 @@ -/* $OpenBSD: diff.c,v 1.36 2014/12/01 21:58:46 deraadt Exp $ */ +/* $OpenBSD: diff.c,v 1.37 2015/01/16 06:40:11 deraadt Exp $ */ /* * Copyright (C) Caldera International Inc. 2001-2002. * All rights reserved. @@ -64,21 +64,25 @@ * @(#)diffreg.c 8.1 (Berkeley) 6/6/93 */ -#include <sys/param.h> #include <sys/stat.h> #include <ctype.h> #include <err.h> #include <stdarg.h> +#include <stdint.h> #include <stddef.h> #include <stdio.h> #include <string.h> #include <unistd.h> +#include <limits.h> #include "buf.h" #include "diff.h" #include "xmalloc.h" +#define MINIMUM(a, b) (((a) < (b)) ? (a) : (b)) +#define MAXIMUM(a, b) (((a) > (b)) ? (a) : (b)) + /* * diff - compare two files. */ @@ -527,7 +531,7 @@ stone(int *a, int n, int *b, int *c, int flags) bound = UINT_MAX; else { sq = isqrt(n); - bound = MAX(256, sq); + bound = MAXIMUM(256, sq); } k = 0; @@ -1200,10 +1204,10 @@ dump_context_vec(FILE *f1, FILE *f2, int flags) return; b = d = 0; /* gcc */ - lowa = MAX(1, cvp->a - diff_context); - upb = MIN(len[0], context_vec_ptr->b + diff_context); - lowc = MAX(1, cvp->c - diff_context); - upd = MIN(len[1], context_vec_ptr->d + diff_context); + lowa = MAXIMUM(1, cvp->a - diff_context); + upb = MINIMUM(len[0], context_vec_ptr->b + diff_context); + lowc = MAXIMUM(1, cvp->c - diff_context); + upd = MINIMUM(len[1], context_vec_ptr->d + diff_context); diff_output("***************"); if ((flags & D_PROTOTYPE)) { @@ -1303,10 +1307,10 @@ dump_unified_vec(FILE *f1, FILE *f2, int flags) return; d = 0; /* gcc */ - lowa = MAX(1, cvp->a - diff_context); - upb = MIN(len[0], context_vec_ptr->b + diff_context); - lowc = MAX(1, cvp->c - diff_context); - upd = MIN(len[1], context_vec_ptr->d + diff_context); + lowa = MAXIMUM(1, cvp->a - diff_context); + upb = MINIMUM(len[0], context_vec_ptr->b + diff_context); + lowc = MAXIMUM(1, cvp->c - diff_context); + upd = MINIMUM(len[1], context_vec_ptr->d + diff_context); diff_output("@@ -"); uni_range(lowa, upb); diff --git a/usr.bin/rcs/diff3.c b/usr.bin/rcs/diff3.c index 9ceae97d302..27b57ea4d91 100644 --- a/usr.bin/rcs/diff3.c +++ b/usr.bin/rcs/diff3.c @@ -1,4 +1,4 @@ -/* $OpenBSD: diff3.c,v 1.34 2014/12/01 21:58:46 deraadt Exp $ */ +/* $OpenBSD: diff3.c,v 1.35 2015/01/16 06:40:11 deraadt Exp $ */ /* * Copyright (C) Caldera International Inc. 2001-2002. @@ -126,7 +126,7 @@ static int last[4]; static int eflag = 3; /* default -E for compatibility with former RCS */ static int oflag = 1; /* default -E for compatibility with former RCS */ static int debug = 0; -static char f1mark[MAXPATHLEN], f3mark[MAXPATHLEN]; /* markers for -E and -X */ +static char f1mark[PATH_MAX], f3mark[PATH_MAX]; /* markers for -E and -X */ static int duplicate(struct range *, struct range *); static int edit(struct diff *, int, int); diff --git a/usr.bin/rcs/rcs.c b/usr.bin/rcs/rcs.c index cd86d6991a9..4db755e0cdc 100644 --- a/usr.bin/rcs/rcs.c +++ b/usr.bin/rcs/rcs.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rcs.c,v 1.81 2014/10/10 08:15:25 otto Exp $ */ +/* $OpenBSD: rcs.c,v 1.82 2015/01/16 06:40:11 deraadt Exp $ */ /* * Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org> * All rights reserved. @@ -24,6 +24,7 @@ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#include <sys/param.h> /* MAXBSIZE */ #include <sys/stat.h> #include <ctype.h> @@ -44,6 +45,8 @@ #include "rcsutil.h" #include "xmalloc.h" +#define MINIMUM(a, b) (((a) < (b)) ? (a) : (b)) + /* invalid characters in RCS states */ static const char rcs_state_invch[] = RCS_STATE_INVALCHAR; @@ -981,7 +984,7 @@ rcs_getrev(RCSFILE *rfp, RCSNUM *frev) /* XXX rcsnum_cmp() is totally broken for * this purpose. */ - numlen = MIN(brev->rn_len, + numlen = MINIMUM(brev->rn_len, rb->rb_num->rn_len - 1); for (i = 0; i < numlen; i++) { if (rb->rb_num->rn_id[i] != @@ -1477,7 +1480,7 @@ rcs_expand_keywords(char *rcsfile_in, struct rcs_delta *rdp, BUF *bp, int mode) { BUF *newbuf; u_char *c, *kw, *fin; - char buf[256], *tmpf, resolved[MAXPATHLEN], *rcsfile; + char buf[256], *tmpf, resolved[PATH_MAX], *rcsfile; u_char *line, *line2; u_int i, j; int kwtype; diff --git a/usr.bin/rcs/rcsclean.c b/usr.bin/rcs/rcsclean.c index 1241e756d21..4bff4894fd4 100644 --- a/usr.bin/rcs/rcsclean.c +++ b/usr.bin/rcs/rcsclean.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rcsclean.c,v 1.53 2014/10/02 06:23:15 otto Exp $ */ +/* $OpenBSD: rcsclean.c,v 1.54 2015/01/16 06:40:11 deraadt Exp $ */ /* * Copyright (c) 2005 Joris Vink <joris@openbsd.org> * All rights reserved. @@ -133,7 +133,7 @@ rcsclean_file(char *fname, const char *rev_str) { int fd, match; RCSFILE *file; - char fpath[MAXPATHLEN], numb[RCS_REV_BUFSZ]; + char fpath[PATH_MAX], numb[RCS_REV_BUFSZ]; RCSNUM *rev; BUF *b1, *b2; time_t rcs_mtime = -1; diff --git a/usr.bin/rcs/rcsdiff.c b/usr.bin/rcs/rcsdiff.c index f508dba3ecf..bd3a3edbdf6 100644 --- a/usr.bin/rcs/rcsdiff.c +++ b/usr.bin/rcs/rcsdiff.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rcsdiff.c,v 1.81 2014/12/01 21:58:46 deraadt Exp $ */ +/* $OpenBSD: rcsdiff.c,v 1.82 2015/01/16 06:40:11 deraadt Exp $ */ /* * Copyright (c) 2005 Joris Vink <joris@openbsd.org> * All rights reserved. @@ -51,7 +51,7 @@ rcsdiff_main(int argc, char **argv) int fd, i, ch, dflags, status; RCSNUM *rev1, *rev2; RCSFILE *file; - char fpath[MAXPATHLEN], *rev_str1, *rev_str2; + char fpath[PATH_MAX], *rev_str1, *rev_str2; const char *errstr; rev1 = rev2 = NULL; diff --git a/usr.bin/rcs/rcsmerge.c b/usr.bin/rcs/rcsmerge.c index d5806e367f0..96ff687d17a 100644 --- a/usr.bin/rcs/rcsmerge.c +++ b/usr.bin/rcs/rcsmerge.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rcsmerge.c,v 1.54 2014/10/10 08:15:25 otto Exp $ */ +/* $OpenBSD: rcsmerge.c,v 1.55 2015/01/16 06:40:11 deraadt Exp $ */ /* * Copyright (c) 2005, 2006 Xavier Santolaria <xsa@openbsd.org> * All rights reserved. @@ -37,7 +37,7 @@ int rcsmerge_main(int argc, char **argv) { int fd, ch, flags, kflag, status; - char fpath[MAXPATHLEN], r1[RCS_REV_BUFSZ], r2[RCS_REV_BUFSZ]; + char fpath[PATH_MAX], r1[RCS_REV_BUFSZ], r2[RCS_REV_BUFSZ]; char *rev_str1, *rev_str2; RCSFILE *file; RCSNUM *rev1, *rev2; diff --git a/usr.bin/rcs/rcsnum.c b/usr.bin/rcs/rcsnum.c index 907683453cb..71cc05d848a 100644 --- a/usr.bin/rcs/rcsnum.c +++ b/usr.bin/rcs/rcsnum.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rcsnum.c,v 1.15 2014/12/01 21:58:46 deraadt Exp $ */ +/* $OpenBSD: rcsnum.c,v 1.16 2015/01/16 06:40:11 deraadt Exp $ */ /* * Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org> * All rights reserved. @@ -24,15 +24,16 @@ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include <sys/param.h> - #include <ctype.h> #include <err.h> #include <string.h> +#include <limits.h> #include "rcs.h" #include "xmalloc.h" +#define MINIMUM(a, b) (((a) < (b)) ? (a) : (b)) + static void rcsnum_setsize(RCSNUM *, u_int); static char *rcsnum_itoa(u_int16_t, char *, size_t); @@ -199,7 +200,7 @@ rcsnum_cmp(const RCSNUM *n1, const RCSNUM *n2, u_int depth) u_int i; size_t slen; - slen = MIN(n1->rn_len, n2->rn_len); + slen = MINIMUM(n1->rn_len, n2->rn_len); if (depth != 0 && slen > depth) slen = depth; diff --git a/usr.bin/rcs/rcsprog.c b/usr.bin/rcs/rcsprog.c index c4b4729f8b3..0029cff4972 100644 --- a/usr.bin/rcs/rcsprog.c +++ b/usr.bin/rcs/rcsprog.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rcsprog.c,v 1.154 2014/12/01 21:58:46 deraadt Exp $ */ +/* $OpenBSD: rcsprog.c,v 1.155 2015/01/16 06:40:11 deraadt Exp $ */ /* * Copyright (c) 2005 Jean-Francois Brousseau <jfb@openbsd.org> * All rights reserved. @@ -181,7 +181,7 @@ rcs_main(int argc, char **argv) int fd; int i, j, ch, flags, kflag, lkmode; const char *nflag, *oldfilename, *orange; - char fpath[MAXPATHLEN]; + char fpath[PATH_MAX]; char *logstr, *logmsg, *descfile; char *alist, *comment, *elist, *lrev, *urev; mode_t fmode; @@ -371,7 +371,7 @@ rcs_main(int argc, char **argv) if (rcsflags & CO_ACLAPPEND) { RCSFILE *oldfile; int ofd; - char ofpath[MAXPATHLEN]; + char ofpath[PATH_MAX]; ofd = rcs_choosefile(oldfilename, ofpath, sizeof(ofpath)); if (ofd < 0) { diff --git a/usr.bin/rcs/rcsutil.c b/usr.bin/rcs/rcsutil.c index f27cf467e3e..258e5ed76af 100644 --- a/usr.bin/rcs/rcsutil.c +++ b/usr.bin/rcs/rcsutil.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rcsutil.c,v 1.42 2014/12/01 21:58:46 deraadt Exp $ */ +/* $OpenBSD: rcsutil.c,v 1.43 2015/01/16 06:40:11 deraadt Exp $ */ /* * Copyright (c) 2005, 2006 Joris Vink <joris@openbsd.org> * Copyright (c) 2006 Xavier Santolaria <xsa@openbsd.org> @@ -154,8 +154,8 @@ rcs_choosefile(const char *filename, char *out, size_t len) { int fd; struct stat sb; - char *p, *ext, name[MAXPATHLEN], *next, *ptr, rcsdir[MAXPATHLEN], - *suffixes, rcspath[MAXPATHLEN]; + char *p, *ext, name[PATH_MAX], *next, *ptr, rcsdir[PATH_MAX], + *suffixes, rcspath[PATH_MAX]; /* * If `filename' contains a directory, `rcspath' contains that @@ -215,7 +215,7 @@ rcs_choosefile(const char *filename, char *out, size_t len) */ suffixes = xstrdup(rcs_suffixes); for (next = suffixes; (ext = strsep(&next, "/")) != NULL;) { - char fpath[MAXPATHLEN]; + char fpath[PATH_MAX]; if ((p = strrchr(rcspath, ',')) != NULL) { if (!strcmp(p, ext)) { diff --git a/usr.bin/rcs/rlog.c b/usr.bin/rcs/rlog.c index 9f4b8594767..bb9d1c2302f 100644 --- a/usr.bin/rcs/rlog.c +++ b/usr.bin/rcs/rlog.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rlog.c,v 1.70 2014/11/28 15:09:50 otto Exp $ */ +/* $OpenBSD: rlog.c,v 1.71 2015/01/16 06:40:11 deraadt Exp $ */ /* * Copyright (c) 2005, 2009 Joris Vink <joris@openbsd.org> * Copyright (c) 2005, 2006 Xavier Santolaria <xsa@openbsd.org> @@ -75,7 +75,7 @@ rlog_main(int argc, char **argv) RCSFILE *file; int Rflag; int i, ch, fd, status; - char fpath[MAXPATHLEN]; + char fpath[PATH_MAX]; rcsnum_flags |= RCSNUM_NO_MAGIC; hflag = Rflag = rflag = status = 0; diff --git a/usr.bin/rcs/worklist.h b/usr.bin/rcs/worklist.h index 40a9b125019..cf833e8580b 100644 --- a/usr.bin/rcs/worklist.h +++ b/usr.bin/rcs/worklist.h @@ -1,4 +1,4 @@ -/* $OpenBSD: worklist.h,v 1.3 2010/07/23 08:31:19 ray Exp $ */ +/* $OpenBSD: worklist.h,v 1.4 2015/01/16 06:40:11 deraadt Exp $ */ /* * Copyright (c) 2006 Joris Vink <joris@openbsd.org> * All rights reserved. @@ -27,10 +27,11 @@ #ifndef WORKLIST_H #define WORKLIST_H -#include <sys/param.h> +#include <sys/types.h> +#include <limits.h> struct worklist { - char wkl_path[MAXPATHLEN]; + char wkl_path[PATH_MAX]; volatile SLIST_ENTRY(worklist) wkl_list; }; diff --git a/usr.bin/rdist/client.c b/usr.bin/rdist/client.c index 69225dec2ca..47dbad804c9 100644 --- a/usr.bin/rdist/client.c +++ b/usr.bin/rdist/client.c @@ -1,4 +1,4 @@ -/* $OpenBSD: client.c,v 1.31 2014/07/12 03:48:04 guenther Exp $ */ +/* $OpenBSD: client.c,v 1.32 2015/01/16 06:40:11 deraadt Exp $ */ /* * Copyright (c) 1983 Regents of the University of California. @@ -347,9 +347,9 @@ linkinfo(struct stat *statp) static int sendhardlink(opt_t opts, struct linkbuf *lp, char *rname, int destdir) { - static char buff[MAXPATHLEN]; + static char buff[PATH_MAX]; char *lname; /* name of file to link to */ - char ername[MAXPATHLEN*4], elname[MAXPATHLEN*4]; + char ername[PATH_MAX*4], elname[PATH_MAX*4]; debugmsg(DM_MISC, "sendhardlink: rname='%s' pathname='%s' src='%s' target='%s'\n", @@ -382,7 +382,7 @@ sendfile(char *rname, opt_t opts, struct stat *stb, char *user, { int goterr, f; off_t i; - char ername[MAXPATHLEN*4]; + char ername[PATH_MAX*4]; if (stb->st_nlink > 1) { struct linkbuf *lp; @@ -492,7 +492,7 @@ rmchk(opt_t opts) struct stat stb; int didupdate = 0; int n; - char targ[MAXPATHLEN*4]; + char targ[PATH_MAX*4]; debugmsg(DM_CALL, "rmchk()\n"); @@ -584,7 +584,7 @@ senddir(char *rname, opt_t opts, struct stat *stb, char *user, char *optarget, *cp; int len; int didupdate = 0; - char ername[MAXPATHLEN*4]; + char ername[PATH_MAX*4]; /* * Send recvdir command in recvit() format. @@ -620,7 +620,7 @@ senddir(char *rname, opt_t opts, struct stat *stb, char *user, if (!strcmp(dp->d_name, ".") || !strcmp(dp->d_name, "..")) continue; - if (len + 1 + (int) strlen(dp->d_name) >= MAXPATHLEN - 1) { + if (len + 1 + (int) strlen(dp->d_name) >= PATH_MAX - 1) { error("%s/%s: Name too long", target, dp->d_name); continue; @@ -656,9 +656,9 @@ sendlink(char *rname, opt_t opts, struct stat *stb, char *user, { int f, n; static char tbuf[BUFSIZ]; - char lbuf[MAXPATHLEN]; + char lbuf[PATH_MAX]; u_char *s; - char ername[MAXPATHLEN*4]; + char ername[PATH_MAX*4]; debugmsg(DM_CALL, "sendlink(%s, %lx, stb, %d)\n", rname, opts, destdir); @@ -777,7 +777,7 @@ update(char *rname, opt_t opts, struct stat *statp) char *owner = NULL, *group = NULL; int done, n; u_char *cp; - char ername[MAXPATHLEN*4]; + char ername[PATH_MAX*4]; debugmsg(DM_CALL, "update(%s, 0x%lx, %p)\n", rname, opts, statp); @@ -1041,7 +1041,7 @@ statupdate(int u, char *starget, opt_t opts, char *rname, int destdir, struct stat *st, char *user, char *group) { int rv = 0; - char ername[MAXPATHLEN*4]; + char ername[PATH_MAX*4]; int lmode = st->st_mode & 07777; if (u == US_CHMOG) { @@ -1214,10 +1214,10 @@ cleanup(int dummy) int install(char *src, char *dest, int ddir, int destdir, opt_t opts) { - static char destcopy[MAXPATHLEN]; + static char destcopy[PATH_MAX]; char *rname; int didupdate = 0; - char ername[MAXPATHLEN*4]; + char ername[PATH_MAX*4]; debugmsg(DM_CALL, "install(src=%s,dest=%s,ddir=%d,destdir=%d,opts=%ld) start\n", diff --git a/usr.bin/rdist/common.c b/usr.bin/rdist/common.c index 0780c51c6a5..34312c0e636 100644 --- a/usr.bin/rdist/common.c +++ b/usr.bin/rdist/common.c @@ -1,4 +1,4 @@ -/* $OpenBSD: common.c,v 1.33 2014/07/12 03:32:00 guenther Exp $ */ +/* $OpenBSD: common.c,v 1.34 2015/01/16 06:40:11 deraadt Exp $ */ /* * Copyright (c) 1983 Regents of the University of California. @@ -44,7 +44,7 @@ /* * Variables common to both client and server */ -char host[MAXHOSTNAMELEN]; /* Name of this host */ +char host[HOST_NAME_MAX+1]; /* Name of this host */ uid_t userid = (uid_t)-1; /* User's UID */ gid_t groupid = (gid_t)-1; /* User's GID */ char *homedir = NULL; /* User's $HOME */ diff --git a/usr.bin/rdist/defs.h b/usr.bin/rdist/defs.h index 0fd21548cae..54099b986ac 100644 --- a/usr.bin/rdist/defs.h +++ b/usr.bin/rdist/defs.h @@ -1,4 +1,4 @@ -/* $OpenBSD: defs.h,v 1.31 2014/07/12 03:48:04 guenther Exp $ */ +/* $OpenBSD: defs.h,v 1.32 2015/01/16 06:40:11 deraadt Exp $ */ #ifndef __DEFS_H__ #define __DEFS_H__ @@ -37,7 +37,6 @@ */ #include <sys/types.h> -#include <sys/param.h> #include <sys/file.h> #include <sys/time.h> #include <sys/stat.h> @@ -55,6 +54,7 @@ #include <string.h> #include <syslog.h> #include <unistd.h> +#include <limits.h> #ifndef __GNUC__ # ifndef __attribute__ diff --git a/usr.bin/rdist/message.c b/usr.bin/rdist/message.c index 1e28bac9731..5ce2f0e5259 100644 --- a/usr.bin/rdist/message.c +++ b/usr.bin/rdist/message.c @@ -1,4 +1,4 @@ -/* $OpenBSD: message.c,v 1.21 2014/07/05 06:18:58 guenther Exp $ */ +/* $OpenBSD: message.c,v 1.22 2015/01/16 06:40:11 deraadt Exp $ */ /* * Copyright (c) 1983 Regents of the University of California. @@ -473,7 +473,7 @@ msgsendnotify(MSGFACILITY *msgfac, int mtype, int flags, char *msgbuf) void checkhostname(void) { - static char mbuf[MAXHOSTNAMELEN]; + static char mbuf[HOST_NAME_MAX+1]; char *cp; if (!currenthost) { diff --git a/usr.bin/rdistd/filesys-os.c b/usr.bin/rdistd/filesys-os.c index 8558094a60a..1707afdfe23 100644 --- a/usr.bin/rdistd/filesys-os.c +++ b/usr.bin/rdistd/filesys-os.c @@ -1,4 +1,4 @@ -/* $OpenBSD: filesys-os.c,v 1.11 2014/07/05 10:21:24 guenther Exp $ */ +/* $OpenBSD: filesys-os.c,v 1.12 2015/01/16 06:40:11 deraadt Exp $ */ /* * Copyright (c) 1983 Regents of the University of California. @@ -29,7 +29,7 @@ * SUCH DAMAGE. */ -#include <sys/param.h> +#include <sys/types.h> #include <sys/mount.h> #include "defs.h" @@ -71,7 +71,7 @@ mntent_t * getmountent(void) { static mntent_t mntstruct; - static char remote_dev[MAXHOSTNAMELEN+MAXPATHLEN+1]; + static char remote_dev[HOST_NAME_MAX+1 + PATH_MAX + 1]; if (!entries_left) return (NULL); diff --git a/usr.bin/rdistd/filesys.c b/usr.bin/rdistd/filesys.c index 8d413a416d3..fc25fb75b7e 100644 --- a/usr.bin/rdistd/filesys.c +++ b/usr.bin/rdistd/filesys.c @@ -1,4 +1,4 @@ -/* $OpenBSD: filesys.c,v 1.16 2015/01/10 07:56:16 guenther Exp $ */ +/* $OpenBSD: filesys.c,v 1.17 2015/01/16 06:40:11 deraadt Exp $ */ /* * Copyright (c) 1983 Regents of the University of California. @@ -29,7 +29,7 @@ * SUCH DAMAGE. */ -#include <sys/param.h> +#include <sys/types.h> #include <sys/mount.h> #include "defs.h" @@ -49,8 +49,8 @@ jmp_buf env; char * find_file(char *pathname, struct stat *statbuf, int *isvalid) { - static char last_pathname[MAXPATHLEN]; - static char file[MAXPATHLEN + 3]; + static char last_pathname[PATH_MAX]; + static char file[PATH_MAX + 3]; static struct stat filestat; char *p; diff --git a/usr.bin/rdistd/server.c b/usr.bin/rdistd/server.c index 47d47eb5128..d5973fadf49 100644 --- a/usr.bin/rdistd/server.c +++ b/usr.bin/rdistd/server.c @@ -1,4 +1,4 @@ -/* $OpenBSD: server.c,v 1.33 2014/07/12 03:10:03 guenther Exp $ */ +/* $OpenBSD: server.c,v 1.34 2015/01/16 06:40:11 deraadt Exp $ */ /* * Copyright (c) 1983 Regents of the University of California. @@ -39,7 +39,7 @@ char tempname[sizeof _RDIST_TMP + 1]; /* Tmp file name */ char buf[BUFSIZ]; /* general purpose buffer */ -char target[MAXPATHLEN]; /* target/source directory name */ +char target[PATH_MAX]; /* target/source directory name */ char *ptarget; /* pointer to end of target name */ int catname = 0; /* cat name to target name */ char *sptarget[32]; /* stack of saved ptarget's for directories */ @@ -324,7 +324,7 @@ removefile(struct stat *statb, int silent) (dp->d_name[1] == '.' && dp->d_name[2] == '\0'))) continue; - if (len + 1 + (int)strlen(dp->d_name) >= MAXPATHLEN - 1) { + if (len + 1 + (int)strlen(dp->d_name) >= PATH_MAX - 1) { if (!silent) message(MT_REMOTE|MT_WARNING, "%s/%s: Name too long", @@ -387,7 +387,7 @@ doclean(char *cp) char *optarget, *ep; int len; opt_t opts; - char targ[MAXPATHLEN*4]; + char targ[PATH_MAX*4]; opts = strtol(cp, &ep, 8); if (*ep != CNULL) { @@ -407,7 +407,7 @@ doclean(char *cp) (dp->d_name[1] == '.' && dp->d_name[2] == '\0'))) continue; - if (len + 1 + (int)strlen(dp->d_name) >= MAXPATHLEN - 1) { + if (len + 1 + (int)strlen(dp->d_name) >= PATH_MAX - 1) { message(MT_REMOTE|MT_WARNING, "%s/%s: Name too long", target, dp->d_name); continue; @@ -553,7 +553,7 @@ query(char *xname) { static struct stat stb; int s = -1, stbvalid = 0; - char name[MAXPATHLEN]; + char name[PATH_MAX]; if (DECODE(name, xname) == -1) { error("query: Cannot decode filename"); @@ -677,9 +677,9 @@ chkparent(char *name, opt_t opts) static char * savetarget(char *file, opt_t opts) { - static char savefile[MAXPATHLEN]; + static char savefile[PATH_MAX]; - if (strlen(file) + sizeof(SAVE_SUFFIX) + 1 > MAXPATHLEN) { + if (strlen(file) + sizeof(SAVE_SUFFIX) + 1 > PATH_MAX) { error("%s: Cannot save: Save name too long", file); return(NULL); } @@ -1110,7 +1110,7 @@ recvdir(opt_t opts, int mode, char *owner, char *group) static void recvlink(char *new, opt_t opts, int mode, off_t size) { - char tbuf[MAXPATHLEN], dbuf[BUFSIZ]; + char tbuf[PATH_MAX], dbuf[BUFSIZ]; struct stat stb; char *optarget; int uptodate; @@ -1355,8 +1355,8 @@ recvit(char *cmd, int type) off_t size; time_t mtime, atime; char *owner, *group, *file; - char new[MAXPATHLEN]; - char fileb[MAXPATHLEN]; + char new[PATH_MAX]; + char fileb[PATH_MAX]; int64_t freespace = -1, freefiles = -1; char *cp = cmd; @@ -1541,7 +1541,7 @@ dochmog(char *cmd) opt_t opts; char *owner, *group, *file; char *cp = cmd; - char fileb[MAXPATHLEN]; + char fileb[PATH_MAX]; /* * Get rdist option flags diff --git a/usr.bin/rpcgen/rpc_main.c b/usr.bin/rpcgen/rpc_main.c index 92c9e5f938a..70027bac95d 100644 --- a/usr.bin/rpcgen/rpc_main.c +++ b/usr.bin/rpcgen/rpc_main.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rpc_main.c,v 1.28 2014/11/18 20:54:28 krw Exp $ */ +/* $OpenBSD: rpc_main.c,v 1.29 2015/01/16 06:40:11 deraadt Exp $ */ /* $NetBSD: rpc_main.c,v 1.9 1996/02/19 11:12:43 pk Exp $ */ /* @@ -39,12 +39,12 @@ #define RPCGEN_VERSION "199506"/* This program's version (year & month) */ #include <sys/types.h> -#include <sys/param.h> #include <sys/file.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <unistd.h> +#include <limits.h> #include <ctype.h> #include <sys/stat.h> #include "rpc_parse.h" @@ -77,7 +77,7 @@ static char *cmdname; static char *svcclosetime = "120"; static char *CPP = "/usr/bin/cpp"; static char CPPFLAGS[] = "-C"; -static char pathbuf[MAXPATHLEN]; +static char pathbuf[PATH_MAX]; static char *allv[] = { "rpcgen", "-s", "udp", "-s", "tcp", }; diff --git a/usr.bin/rup/rup.c b/usr.bin/rup/rup.c index 3200cfb01a0..6e61fc06a28 100644 --- a/usr.bin/rup/rup.c +++ b/usr.bin/rup/rup.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rup.c,v 1.28 2014/11/26 18:34:51 millert Exp $ */ +/* $OpenBSD: rup.c,v 1.29 2015/01/16 06:40:11 deraadt Exp $ */ /*- * Copyright (c) 1993, John Brezak @@ -32,7 +32,6 @@ #include <stdlib.h> #include <string.h> #include <time.h> -#include <sys/param.h> #include <sys/socket.h> #include <netdb.h> #include <rpc/rpc.h> diff --git a/usr.bin/rusers/rusers.c b/usr.bin/rusers/rusers.c index 7d991526d4f..96077d82c5a 100644 --- a/usr.bin/rusers/rusers.c +++ b/usr.bin/rusers/rusers.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rusers.c,v 1.33 2014/11/26 18:34:51 millert Exp $ */ +/* $OpenBSD: rusers.c,v 1.34 2015/01/16 06:40:11 deraadt Exp $ */ /* * Copyright (c) 2001, 2003 Todd C. Miller <Todd.Miller@courtesan.com> @@ -46,9 +46,9 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include <sys/param.h> #include <sys/ioctl.h> #include <sys/socket.h> +#include <sys/signal.h> #include <rpc/rpc.h> #include <rpc/pmap_prot.h> #include <rpc/pmap_rmt.h> @@ -65,6 +65,10 @@ #include <string.h> #include <termios.h> #include <unistd.h> +#include <limits.h> + +#define MINIMUM(a, b) (((a) < (b)) ? (a) : (b)) +#define MAXIMUM(a, b) (((a) > (b)) ? (a) : (b)) /* Preferred formatting */ #define HOST_WIDTH 17 @@ -535,7 +539,7 @@ allhosts(void) outlen[1] = xdr_getpos(&xdr); xdr_destroy(&xdr); - maxfd = MAX(sock[0], sock[1]) + 1; + maxfd = MAXIMUM(sock[0], sock[1]) + 1; fds = (fd_set *)calloc(howmany(maxfd, NFDBITS), sizeof(fd_mask)); if (fds == NULL) err(1, NULL); @@ -653,16 +657,16 @@ print_entry(struct host_info *entry, int longfmt) date[sizeof(date) - 1] = '\0'; fmt_idle(ut->ut_idle, idle_time, sizeof(idle_time)); len = termwidth - - (MAX(strlen(ut->ut_user), NAME_WIDTH) + 1 + + (MAXIMUM(strlen(ut->ut_user), NAME_WIDTH) + 1 + HOST_WIDTH + 1 + LINE_WIDTH + 1 + strlen(date) + - 1 + MAX(8, strlen(idle_time)) + 1 + 2); + 1 + MAXIMUM(8, strlen(idle_time)) + 1 + 2); if (len > 0 && ut->ut_host[0] != '\0') snprintf(remote, sizeof(remote), "(%.*s)", - MIN(len, RUSERS_MAXHOSTLEN), ut->ut_host); + MINIMUM(len, RUSERS_MAXHOSTLEN), ut->ut_host); else remote[0] = '\0'; - len = HOST_WIDTH - MIN(HOST_WIDTH, strlen(entry->host)) + - LINE_WIDTH - MIN(LINE_WIDTH, strlen(ut->ut_line)); + len = HOST_WIDTH - MINIMUM(HOST_WIDTH, strlen(entry->host)) + + LINE_WIDTH - MINIMUM(LINE_WIDTH, strlen(ut->ut_line)); printf("%-*s %.*s:%.*s%-*s %-12s %8s %s\n", NAME_WIDTH, ut->ut_user, HOST_WIDTH, entry->host, LINE_WIDTH, ut->ut_line, len, "", date, diff --git a/usr.bin/rwall/rwall.c b/usr.bin/rwall/rwall.c index 7c0abdabf04..29725f8d2dc 100644 --- a/usr.bin/rwall/rwall.c +++ b/usr.bin/rwall/rwall.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rwall.c,v 1.12 2009/10/27 23:59:43 deraadt Exp $ */ +/* $OpenBSD: rwall.c,v 1.13 2015/01/16 06:40:11 deraadt Exp $ */ /* * Copyright (c) 1993 Christopher G. Demetriou @@ -39,11 +39,11 @@ #include <stdlib.h> #include <string.h> #include <time.h> -#include <sys/param.h> #include <sys/types.h> #include <sys/stat.h> #include <pwd.h> #include <unistd.h> +#include <limits.h> #include <paths.h> #include <err.h> @@ -109,7 +109,7 @@ makemsg(char *fname) time_t now; FILE *fp; int fd; - char *whom, hostname[MAXHOSTNAMELEN], lbuf[100], tmpname[MAXPATHLEN]; + char *whom, hostname[HOST_NAME_MAX+1], lbuf[100], tmpname[PATH_MAX]; snprintf(tmpname, sizeof(tmpname), "%s/wall.XXXXXXXXXX", _PATH_TMP); if ((fd = mkstemp(tmpname)) == -1 || !(fp = fdopen(fd, "r+"))) diff --git a/usr.bin/sdiff/sdiff.c b/usr.bin/sdiff/sdiff.c index 3866d7bc8d6..93d0d4e904a 100644 --- a/usr.bin/sdiff/sdiff.c +++ b/usr.bin/sdiff/sdiff.c @@ -1,11 +1,10 @@ -/* $OpenBSD: sdiff.c,v 1.30 2013/11/26 21:08:12 deraadt Exp $ */ +/* $OpenBSD: sdiff.c,v 1.31 2015/01/16 06:40:11 deraadt Exp $ */ /* * Written by Raymond Lai <ray@cyth.net>. * Public domain. */ -#include <sys/param.h> #include <sys/queue.h> #include <sys/stat.h> #include <sys/types.h> diff --git a/usr.bin/sendbug/sendbug.c b/usr.bin/sendbug/sendbug.c index 616202fdb68..8075f44ed31 100644 --- a/usr.bin/sendbug/sendbug.c +++ b/usr.bin/sendbug/sendbug.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sendbug.c,v 1.68 2014/03/18 22:36:37 miod Exp $ */ +/* $OpenBSD: sendbug.c,v 1.69 2015/01/16 06:40:11 deraadt Exp $ */ /* * Written by Ray Lai <ray@cyth.net>. @@ -6,7 +6,6 @@ */ #include <sys/types.h> -#include <sys/param.h> #include <sys/stat.h> #include <sys/sysctl.h> #include <sys/wait.h> diff --git a/usr.bin/skeyaudit/skeyaudit.c b/usr.bin/skeyaudit/skeyaudit.c index b50d9a8ef2b..381c271b6dc 100644 --- a/usr.bin/skeyaudit/skeyaudit.c +++ b/usr.bin/skeyaudit/skeyaudit.c @@ -1,4 +1,4 @@ -/* $OpenBSD: skeyaudit.c,v 1.24 2008/11/12 16:13:46 sobrado Exp $ */ +/* $OpenBSD: skeyaudit.c,v 1.25 2015/01/16 06:40:11 deraadt Exp $ */ /* * Copyright (c) 1997, 2000, 2003 Todd C. Miller <Todd.Miller@courtesan.com> @@ -20,7 +20,6 @@ * Materiel Command, USAF, under agreement number F39502-99-1-0512. */ -#include <sys/param.h> #include <sys/wait.h> #include <err.h> @@ -138,7 +137,7 @@ main(int argc, char **argv) void notify(struct passwd *pw, int seq, int interactive) { - static char hostname[MAXHOSTNAMELEN]; + static char hostname[HOST_NAME_MAX+1]; pid_t pid; FILE *out; diff --git a/usr.bin/skeyinit/skeyinit.c b/usr.bin/skeyinit/skeyinit.c index d94d72e0e97..96698358826 100644 --- a/usr.bin/skeyinit/skeyinit.c +++ b/usr.bin/skeyinit/skeyinit.c @@ -1,4 +1,4 @@ -/* $OpenBSD: skeyinit.c,v 1.55 2014/05/20 01:25:23 guenther Exp $ */ +/* $OpenBSD: skeyinit.c,v 1.56 2015/01/16 06:40:11 deraadt Exp $ */ /* OpenBSD S/Key (skeyinit.c) * @@ -12,7 +12,6 @@ * S/Key initialization and seed update */ -#include <sys/param.h> #include <sys/file.h> #include <sys/resource.h> #include <sys/stat.h> @@ -29,6 +28,7 @@ #include <syslog.h> #include <time.h> #include <unistd.h> +#include <limits.h> #include <utmp.h> #include <skey.h> @@ -48,7 +48,7 @@ int main(int argc, char **argv) { int rval, i, l, n, defaultsetup, rmkey, hexmode, enable, convert; - char hostname[MAXHOSTNAMELEN]; + char hostname[HOST_NAME_MAX+1]; char seed[SKEY_MAX_SEED_LEN + 1]; char buf[256], key[SKEY_BINKEY_SIZE], filename[PATH_MAX], *ht; char lastc, me[UT_NAMESIZE + 1], *p, *auth_type; diff --git a/usr.bin/sndiod/sndiod.c b/usr.bin/sndiod/sndiod.c index 6f9ec02e079..b108ef2e7f8 100644 --- a/usr.bin/sndiod/sndiod.c +++ b/usr.bin/sndiod/sndiod.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sndiod.c,v 1.6 2014/03/05 20:24:16 ratchov Exp $ */ +/* $OpenBSD: sndiod.c,v 1.7 2015/01/16 06:40:12 deraadt Exp $ */ /* * Copyright (c) 2008-2012 Alexandre Ratchov <alex@caoua.org> * @@ -14,7 +14,6 @@ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#include <sys/param.h> #include <sys/queue.h> #include <sys/stat.h> #include <sys/types.h> diff --git a/usr.bin/sort/msort.c b/usr.bin/sort/msort.c index e70de031f73..45fe75df0e4 100644 --- a/usr.bin/sort/msort.c +++ b/usr.bin/sort/msort.c @@ -1,4 +1,4 @@ -/* $OpenBSD: msort.c,v 1.24 2013/11/13 15:07:27 deraadt Exp $ */ +/* $OpenBSD: msort.c,v 1.25 2015/01/16 06:40:12 deraadt Exp $ */ /*- * Copyright (c) 1993 @@ -32,6 +32,8 @@ * SUCH DAMAGE. */ +#include <sys/param.h> /* ALIGN */ + #include "sort.h" #include "fsort.h" diff --git a/usr.bin/sort/sort.h b/usr.bin/sort/sort.h index 59baea59d50..e06618b10f4 100644 --- a/usr.bin/sort/sort.h +++ b/usr.bin/sort/sort.h @@ -1,4 +1,4 @@ -/* $OpenBSD: sort.h,v 1.7 2007/08/21 20:29:25 millert Exp $ */ +/* $OpenBSD: sort.h,v 1.8 2015/01/16 06:40:12 deraadt Exp $ */ /*- * Copyright (c) 1993 @@ -34,8 +34,6 @@ * @(#)sort.h 8.1 (Berkeley) 6/6/93 */ -#include <sys/param.h> - #include <db.h> #include <err.h> #include <errno.h> diff --git a/usr.bin/sort/tmp.c b/usr.bin/sort/tmp.c index b772580b1a8..fd1f63be301 100644 --- a/usr.bin/sort/tmp.c +++ b/usr.bin/sort/tmp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tmp.c,v 1.9 2009/10/27 23:59:43 deraadt Exp $ */ +/* $OpenBSD: tmp.c,v 1.10 2015/01/16 06:40:12 deraadt Exp $ */ /*- * Copyright (c) 1993 @@ -32,8 +32,6 @@ * SUCH DAMAGE. */ -#include <sys/param.h> - #include <err.h> #include <errno.h> #include <limits.h> diff --git a/usr.bin/spell/spellprog.c b/usr.bin/spell/spellprog.c index 8ed8337a108..ce086979641 100644 --- a/usr.bin/spell/spellprog.c +++ b/usr.bin/spell/spellprog.c @@ -1,4 +1,4 @@ -/* $OpenBSD: spellprog.c,v 1.8 2014/05/20 01:25:23 guenther Exp $ */ +/* $OpenBSD: spellprog.c,v 1.9 2015/01/16 06:40:12 deraadt Exp $ */ /* * Copyright (c) 1991, 1993 @@ -64,7 +64,6 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include <sys/param.h> #include <sys/mman.h> #include <sys/stat.h> diff --git a/usr.bin/split/split.c b/usr.bin/split/split.c index 6231e8ffa1a..27a75d5c449 100644 --- a/usr.bin/split/split.c +++ b/usr.bin/split/split.c @@ -1,4 +1,4 @@ -/* $OpenBSD: split.c,v 1.17 2009/10/27 23:59:43 deraadt Exp $ */ +/* $OpenBSD: split.c,v 1.18 2015/01/16 06:40:12 deraadt Exp $ */ /* $NetBSD: split.c,v 1.5 1995/08/31 22:22:05 jtc Exp $ */ /* @@ -30,7 +30,7 @@ * SUCH DAMAGE. */ -#include <sys/param.h> +#include <sys/param.h> /* MAXBSIZE */ #include <sys/types.h> #include <ctype.h> @@ -51,7 +51,7 @@ long numlines; /* Line count to split on. */ int file_open; /* If a file open. */ int ifd = -1, ofd = -1; /* Input/output file descriptors. */ char bfr[MAXBSIZE]; /* I/O buffer. */ -char fname[MAXPATHLEN]; /* File name prefix. */ +char fname[PATH_MAX]; /* File name prefix. */ regex_t rgx; int pflag; int sufflen = 2; /* File name suffix length. */ diff --git a/usr.bin/ssh/atomicio.c b/usr.bin/ssh/atomicio.c index f1269678f54..4a391958aa5 100644 --- a/usr.bin/ssh/atomicio.c +++ b/usr.bin/ssh/atomicio.c @@ -1,4 +1,4 @@ -/* $OpenBSD: atomicio.c,v 1.26 2010/09/22 22:58:51 djm Exp $ */ +/* $OpenBSD: atomicio.c,v 1.27 2015/01/16 06:40:12 deraadt Exp $ */ /* * Copyright (c) 2006 Damien Miller. All rights reserved. * Copyright (c) 2005 Anil Madhavapeddy. All rights reserved. @@ -26,13 +26,13 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include <sys/param.h> #include <sys/uio.h> #include <errno.h> #include <poll.h> #include <string.h> #include <unistd.h> +#include <limits.h> #include "atomicio.h" diff --git a/usr.bin/ssh/misc.c b/usr.bin/ssh/misc.c index 328473903f5..6110a6f8bd9 100644 --- a/usr.bin/ssh/misc.c +++ b/usr.bin/ssh/misc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: misc.c,v 1.95 2014/10/24 02:01:20 lteo Exp $ */ +/* $OpenBSD: misc.c,v 1.96 2015/01/16 06:40:12 deraadt Exp $ */ /* * Copyright (c) 2000 Markus Friedl. All rights reserved. * Copyright (c) 2005,2006 Damien Miller. All rights reserved. @@ -28,7 +28,6 @@ #include <sys/ioctl.h> #include <sys/socket.h> #include <sys/un.h> -#include <sys/param.h> #include <net/if.h> #include <netinet/in.h> @@ -41,6 +40,7 @@ #include <netdb.h> #include <paths.h> #include <pwd.h> +#include <limits.h> #include <stdarg.h> #include <stdio.h> #include <stdlib.h> @@ -534,7 +534,7 @@ tilde_expand_filename(const char *filename, uid_t uid) if (path != NULL) filename = path + 1; - if (xasprintf(&ret, "%s%s%s", pw->pw_dir, sep, filename) >= MAXPATHLEN) + if (xasprintf(&ret, "%s%s%s", pw->pw_dir, sep, filename) >= PATH_MAX) fatal("tilde_expand_filename: Path too long"); return (ret); diff --git a/usr.bin/ssh/readconf.c b/usr.bin/ssh/readconf.c index 34ff37e6787..eabfa3c739e 100644 --- a/usr.bin/ssh/readconf.c +++ b/usr.bin/ssh/readconf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: readconf.c,v 1.227 2015/01/15 09:40:00 djm Exp $ */ +/* $OpenBSD: readconf.c,v 1.228 2015/01/16 06:40:12 deraadt Exp $ */ /* * Author: Tatu Ylonen <ylo@cs.hut.fi> * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland @@ -31,6 +31,7 @@ #include <stdio.h> #include <string.h> #include <unistd.h> +#include <limits.h> #include <util.h> #include <vis.h> diff --git a/usr.bin/ssh/scp.c b/usr.bin/ssh/scp.c index 52b0a20c5e9..52d02ebc8d8 100644 --- a/usr.bin/ssh/scp.c +++ b/usr.bin/ssh/scp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: scp.c,v 1.180 2014/06/24 02:21:01 djm Exp $ */ +/* $OpenBSD: scp.c,v 1.181 2015/01/16 06:40:12 deraadt Exp $ */ /* * scp - secure remote copy. This is basically patched BSD rcp which * uses ssh to do the data transfer (instead of using rcmd). @@ -71,7 +71,7 @@ * */ -#include <sys/param.h> +#include <sys/param.h> /* roundup MAX */ #include <sys/types.h> #include <sys/poll.h> #include <sys/wait.h> @@ -91,6 +91,7 @@ #include <string.h> #include <time.h> #include <unistd.h> +#include <limits.h> #include <vis.h> #include "xmalloc.h" @@ -728,7 +729,7 @@ source(int argc, char **argv) off_t i, statbytes; size_t amt, nr; int fd = -1, haderr, indx; - char *last, *name, buf[2048], encname[MAXPATHLEN]; + char *last, *name, buf[2048], encname[PATH_MAX]; int len; for (indx = 0; indx < argc; ++indx) { @@ -837,7 +838,7 @@ rsource(char *name, struct stat *statp) { DIR *dirp; struct dirent *dp; - char *last, *vect[1], path[MAXPATHLEN]; + char *last, *vect[1], path[PATH_MAX]; if (!(dirp = opendir(name))) { run_err("%s: %s", name, strerror(errno)); diff --git a/usr.bin/ssh/servconf.c b/usr.bin/ssh/servconf.c index f36cc9c352e..d6304fb2a80 100644 --- a/usr.bin/ssh/servconf.c +++ b/usr.bin/ssh/servconf.c @@ -1,5 +1,5 @@ -/* $OpenBSD: servconf.c,v 1.258 2015/01/13 07:39:19 djm Exp $ */ +/* $OpenBSD: servconf.c,v 1.259 2015/01/16 06:40:12 deraadt Exp $ */ /* * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland * All rights reserved @@ -26,6 +26,7 @@ #include <string.h> #include <signal.h> #include <unistd.h> +#include <limits.h> #include <stdarg.h> #include <errno.h> #include <util.h> @@ -529,7 +530,7 @@ parse_token(const char *cp, const char *filename, char * derelativise_path(const char *path) { - char *expanded, *ret, cwd[MAXPATHLEN]; + char *expanded, *ret, cwd[PATH_MAX]; if (strcasecmp(path, "none") == 0) return xstrdup("none"); diff --git a/usr.bin/ssh/session.c b/usr.bin/ssh/session.c index 4025bfc03e2..aa7ae456b65 100644 --- a/usr.bin/ssh/session.c +++ b/usr.bin/ssh/session.c @@ -1,4 +1,4 @@ -/* $OpenBSD: session.c,v 1.276 2015/01/14 20:05:27 djm Exp $ */ +/* $OpenBSD: session.c,v 1.277 2015/01/16 06:40:12 deraadt Exp $ */ /* * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland * All rights reserved @@ -38,7 +38,6 @@ #include <sys/un.h> #include <sys/stat.h> #include <sys/socket.h> -#include <sys/param.h> #include <sys/queue.h> #include <errno.h> @@ -53,6 +52,7 @@ #include <stdlib.h> #include <string.h> #include <unistd.h> +#include <limits.h> #include "xmalloc.h" #include "ssh.h" @@ -1151,7 +1151,7 @@ static void safely_chroot(const char *path, uid_t uid) { const char *cp; - char component[MAXPATHLEN]; + char component[PATH_MAX]; struct stat st; if (*path != '/') diff --git a/usr.bin/ssh/ssh-add.c b/usr.bin/ssh/ssh-add.c index 33b238dd582..9f1101a2c1c 100644 --- a/usr.bin/ssh/ssh-add.c +++ b/usr.bin/ssh/ssh-add.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ssh-add.c,v 1.116 2015/01/14 20:05:27 djm Exp $ */ +/* $OpenBSD: ssh-add.c,v 1.117 2015/01/16 06:40:12 deraadt Exp $ */ /* * Author: Tatu Ylonen <ylo@cs.hut.fi> * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland @@ -37,7 +37,6 @@ #include <sys/types.h> #include <sys/stat.h> -#include <sys/param.h> #include <openssl/evp.h> @@ -48,6 +47,7 @@ #include <stdlib.h> #include <string.h> #include <unistd.h> +#include <limits.h> #include "xmalloc.h" #include "ssh.h" @@ -560,7 +560,7 @@ main(int argc, char **argv) goto done; } if (argc == 0) { - char buf[MAXPATHLEN]; + char buf[PATH_MAX]; struct passwd *pw; struct stat st; int count = 0; diff --git a/usr.bin/ssh/ssh-agent.c b/usr.bin/ssh/ssh-agent.c index 30756c31148..e149098ad5d 100644 --- a/usr.bin/ssh/ssh-agent.c +++ b/usr.bin/ssh/ssh-agent.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ssh-agent.c,v 1.195 2015/01/14 19:33:41 djm Exp $ */ +/* $OpenBSD: ssh-agent.c,v 1.196 2015/01/16 06:40:12 deraadt Exp $ */ /* * Author: Tatu Ylonen <ylo@cs.hut.fi> * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland @@ -34,6 +34,7 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#include <sys/param.h> /* MIN MAX */ #include <sys/types.h> #include <sys/time.h> #include <sys/queue.h> @@ -41,7 +42,6 @@ #include <sys/socket.h> #include <sys/stat.h> #include <sys/un.h> -#include <sys/param.h> #ifdef WITH_OPENSSL #include <openssl/evp.h> @@ -54,6 +54,7 @@ #include <stdlib.h> #include <stdio.h> #include <string.h> +#include <limits.h> #include <time.h> #include <unistd.h> @@ -120,8 +121,8 @@ time_t parent_alive_interval = 0; pid_t cleanup_pid = 0; /* pathname and directory for AUTH_SOCKET */ -char socket_name[MAXPATHLEN]; -char socket_dir[MAXPATHLEN]; +char socket_name[PATH_MAX]; +char socket_dir[PATH_MAX]; /* locking */ int locked = 0; diff --git a/usr.bin/ssh/ssh-keygen.c b/usr.bin/ssh/ssh-keygen.c index f90a600f876..d1337927b4b 100644 --- a/usr.bin/ssh/ssh-keygen.c +++ b/usr.bin/ssh/ssh-keygen.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ssh-keygen.c,v 1.252 2015/01/15 09:40:00 djm Exp $ */ +/* $OpenBSD: ssh-keygen.c,v 1.253 2015/01/16 06:40:12 deraadt Exp $ */ /* * Author: Tatu Ylonen <ylo@cs.hut.fi> * Copyright (c) 1994 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland @@ -15,7 +15,6 @@ #include <sys/types.h> #include <sys/socket.h> #include <sys/stat.h> -#include <sys/param.h> #include <openssl/evp.h> #include <openssl/pem.h> @@ -28,6 +27,7 @@ #include <stdlib.h> #include <string.h> #include <unistd.h> +#include <limits.h> #include "xmalloc.h" #include "sshkey.h" @@ -1047,7 +1047,7 @@ do_known_hosts(struct passwd *pw, const char *name) FILE *in, *out = stdout; struct sshkey *pub; char *cp, *cp2, *kp, *kp2; - char line[16*1024], tmp[MAXPATHLEN], old[MAXPATHLEN]; + char line[16*1024], tmp[PATH_MAX], old[PATH_MAX]; int c, skip = 0, inplace = 0, num = 0, invalid = 0, has_unhashed = 0; int r, ca, revoked; int found_key = 0; @@ -2275,9 +2275,9 @@ usage(void) int main(int argc, char **argv) { - char dotsshdir[MAXPATHLEN], comment[1024], *passphrase1, *passphrase2; + char dotsshdir[PATH_MAX], comment[1024], *passphrase1, *passphrase2; char *checkpoint = NULL; - char out_file[MAXPATHLEN], *rr_hostname = NULL, *ep; + char out_file[PATH_MAX], *rr_hostname = NULL, *ep; struct sshkey *private, *public; struct passwd *pw; struct stat st; @@ -2490,7 +2490,7 @@ main(int argc, char **argv) fatal("Output filename too long"); break; case 'K': - if (strlen(optarg) >= MAXPATHLEN) + if (strlen(optarg) >= PATH_MAX) fatal("Checkpoint filename too long"); checkpoint = xstrdup(optarg); break; diff --git a/usr.bin/ssh/sshkey.c b/usr.bin/ssh/sshkey.c index 8359bd5aaf3..0745fde7125 100644 --- a/usr.bin/ssh/sshkey.c +++ b/usr.bin/ssh/sshkey.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sshkey.c,v 1.12 2015/01/14 10:46:28 djm Exp $ */ +/* $OpenBSD: sshkey.c,v 1.13 2015/01/16 06:40:12 deraadt Exp $ */ /* * Copyright (c) 2000, 2001 Markus Friedl. All rights reserved. * Copyright (c) 2008 Alexander von Gernler. All rights reserved. @@ -25,7 +25,7 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include <sys/param.h> +#include <sys/param.h> /* MIN MAX */ #include <sys/types.h> #include <netinet/in.h> @@ -41,6 +41,7 @@ #include <stdio.h> #include <string.h> #include <util.h> +#include <limits.h> #include <resolv.h> #include "ssh2.h" diff --git a/usr.bin/ssh/sshlogin.c b/usr.bin/ssh/sshlogin.c index 0f646cf42e6..e39b1147599 100644 --- a/usr.bin/ssh/sshlogin.c +++ b/usr.bin/ssh/sshlogin.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sshlogin.c,v 1.29 2014/07/15 15:54:14 millert Exp $ */ +/* $OpenBSD: sshlogin.c,v 1.30 2015/01/16 06:40:12 deraadt Exp $ */ /* * Author: Tatu Ylonen <ylo@cs.hut.fi> * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland @@ -40,7 +40,7 @@ */ #include <sys/types.h> -#include <sys/param.h> +#include <sys/param.h> /* MAXHOSTNAMELEN */ #include <sys/socket.h> #include <errno.h> diff --git a/usr.bin/ssh/uidswap.c b/usr.bin/ssh/uidswap.c index dc8b191b49a..e9dee64578a 100644 --- a/usr.bin/ssh/uidswap.c +++ b/usr.bin/ssh/uidswap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uidswap.c,v 1.36 2013/11/08 11:15:19 dtucker Exp $ */ +/* $OpenBSD: uidswap.c,v 1.37 2015/01/16 06:40:12 deraadt Exp $ */ /* * Author: Tatu Ylonen <ylo@cs.hut.fi> * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland @@ -12,11 +12,11 @@ * called by a name other than "ssh" or "Secure Shell". */ -#include <sys/param.h> #include <errno.h> #include <pwd.h> #include <string.h> #include <unistd.h> +#include <limits.h> #include <stdarg.h> #include <stdlib.h> diff --git a/usr.bin/ssh/xmalloc.c b/usr.bin/ssh/xmalloc.c index c6bd95973a6..a85acb7a566 100644 --- a/usr.bin/ssh/xmalloc.c +++ b/usr.bin/ssh/xmalloc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: xmalloc.c,v 1.29 2014/01/04 17:50:55 tedu Exp $ */ +/* $OpenBSD: xmalloc.c,v 1.30 2015/01/16 06:40:12 deraadt Exp $ */ /* * Author: Tatu Ylonen <ylo@cs.hut.fi> * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland @@ -13,11 +13,11 @@ * called by a name other than "ssh" or "Secure Shell". */ -#include <sys/param.h> #include <stdarg.h> #include <stdio.h> #include <stdlib.h> #include <string.h> +#include <limits.h> #include "xmalloc.h" #include "log.h" diff --git a/usr.bin/su/su.c b/usr.bin/su/su.c index b7f821990c2..b6869bccd62 100644 --- a/usr.bin/su/su.c +++ b/usr.bin/su/su.c @@ -1,4 +1,4 @@ -/* $OpenBSD: su.c,v 1.65 2011/01/11 10:07:56 robert Exp $ */ +/* $OpenBSD: su.c,v 1.66 2015/01/16 06:40:13 deraadt Exp $ */ /* * Copyright (c) 1988 The Regents of the University of California. @@ -29,7 +29,6 @@ * SUCH DAMAGE. */ -#include <sys/param.h> #include <sys/time.h> #include <sys/resource.h> @@ -44,6 +43,7 @@ #include <string.h> #include <syslog.h> #include <unistd.h> +#include <limits.h> #include <utmp.h> #include <stdarg.h> #include <bsd_auth.h> @@ -65,7 +65,7 @@ main(int argc, char **argv) char *user, *shell = NULL, *avshell, *username, **np; char *class = NULL, *style = NULL, *p; enum { UNSET, YES, NO } iscsh = UNSET; - char avshellbuf[MAXPATHLEN]; + char avshellbuf[PATH_MAX]; extern char **environ; auth_session_t *as; struct passwd *pwd; @@ -395,7 +395,7 @@ chshell(const char *sh) char * ontty(void) { - static char buf[MAXPATHLEN + 4]; + static char buf[PATH_MAX + 4]; char *p; buf[0] = 0; diff --git a/usr.bin/talk/get_names.c b/usr.bin/talk/get_names.c index caf98634894..c4cd1d2858f 100644 --- a/usr.bin/talk/get_names.c +++ b/usr.bin/talk/get_names.c @@ -1,4 +1,4 @@ -/* $OpenBSD: get_names.c,v 1.19 2010/08/12 23:31:29 tedu Exp $ */ +/* $OpenBSD: get_names.c,v 1.20 2015/01/16 06:40:13 deraadt Exp $ */ /* $NetBSD: get_names.c,v 1.4 1994/12/09 02:14:16 jtc Exp $ */ /* @@ -31,10 +31,10 @@ */ #include "talk.h" -#include <sys/param.h> #include <pwd.h> #include <stdlib.h> #include <unistd.h> +#include <limits.h> extern CTL_MSG msg; @@ -44,7 +44,7 @@ extern CTL_MSG msg; void get_names(int argc, char *argv[]) { - char hostname[MAXHOSTNAMELEN]; + char hostname[HOST_NAME_MAX+1]; char *his_name, *my_name; char *my_machine_name, *his_machine_name; char *his_tty; diff --git a/usr.bin/telnet/commands.c b/usr.bin/telnet/commands.c index 2799f161f47..64c6e8cde8e 100644 --- a/usr.bin/telnet/commands.c +++ b/usr.bin/telnet/commands.c @@ -1,4 +1,4 @@ -/* $OpenBSD: commands.c,v 1.70 2014/09/09 03:41:08 guenther Exp $ */ +/* $OpenBSD: commands.c,v 1.71 2015/01/16 06:40:13 deraadt Exp $ */ /* $NetBSD: commands.c,v 1.14 1996/03/24 22:03:48 jtk Exp $ */ /* @@ -47,6 +47,7 @@ #include <stdlib.h> #include <string.h> #include <unistd.h> +#include <limits.h> #ifdef SKEY #include <sys/wait.h> @@ -1544,7 +1545,7 @@ env_init(void) if ((ep = env_find("DISPLAY")) && ((*ep->value == ':') || (strncmp(ep->value, "unix:", 5) == 0))) { - char hbuf[MAXHOSTNAMELEN]; + char hbuf[HOST_NAME_MAX+1]; char *cp2 = strchr(ep->value, ':'); gethostname(hbuf, sizeof hbuf); @@ -1774,7 +1775,7 @@ cmdrc(char *m1, char *m2) int gotmachine = 0; int l1 = strlen(m1); int l2 = strlen(m2); - char m1save[MAXHOSTNAMELEN]; + char m1save[HOST_NAME_MAX+1]; if (skiprc) return; diff --git a/usr.bin/tftp/main.c b/usr.bin/tftp/main.c index debf8dfcca8..68a6d4b6f1a 100644 --- a/usr.bin/tftp/main.c +++ b/usr.bin/tftp/main.c @@ -1,4 +1,4 @@ -/* $OpenBSD: main.c,v 1.34 2013/11/26 21:08:12 deraadt Exp $ */ +/* $OpenBSD: main.c,v 1.35 2015/01/16 06:40:13 deraadt Exp $ */ /* $NetBSD: main.c,v 1.6 1995/05/21 16:54:10 mycroft Exp $ */ /* @@ -36,7 +36,6 @@ * This version includes many modifications by Jim Guyton <guyton@rand-unix> */ -#include <sys/param.h> #include <sys/socket.h> #include <sys/file.h> @@ -54,6 +53,7 @@ #include <stdlib.h> #include <string.h> #include <unistd.h> +#include <limits.h> #include "extern.h" @@ -100,7 +100,7 @@ char *prompt = "tftp"; void intr(int); int rexmtval = TIMEOUT; int maxtimeout = 5 * TIMEOUT; -char hostname[MAXHOSTNAMELEN]; +char hostname[HOST_NAME_MAX+1]; FILE *file = NULL; volatile sig_atomic_t intrflag = 0; char *ackbuf; diff --git a/usr.bin/tic/progs.priv.h b/usr.bin/tic/progs.priv.h index 0795db553e3..1499fabddf2 100644 --- a/usr.bin/tic/progs.priv.h +++ b/usr.bin/tic/progs.priv.h @@ -1,4 +1,4 @@ -/* $OpenBSD: progs.priv.h,v 1.9 2010/01/12 23:22:14 nicm Exp $ */ +/* $OpenBSD: progs.priv.h,v 1.10 2015/01/16 06:40:13 deraadt Exp $ */ /**************************************************************************** * Copyright (c) 1998-2007,2008 Free Software Foundation, Inc. * @@ -32,7 +32,7 @@ * Author: Thomas E. Dickey 1997-on * ****************************************************************************/ /* - * $Id: progs.priv.h,v 1.9 2010/01/12 23:22:14 nicm Exp $ + * $Id: progs.priv.h,v 1.10 2015/01/16 06:40:13 deraadt Exp $ * * progs.priv.h * @@ -63,7 +63,7 @@ #if HAVE_LIMITS_H # include <limits.h> #elif HAVE_SYS_PARAM_H -# include <sys/param.h> +# include <sys/param.h> /* only if no limits.h */ #endif #if HAVE_DIRENT_H diff --git a/usr.bin/time/time.c b/usr.bin/time/time.c index b6b77cfe84b..e18653d537d 100644 --- a/usr.bin/time/time.c +++ b/usr.bin/time/time.c @@ -1,4 +1,4 @@ -/* $OpenBSD: time.c,v 1.19 2013/04/16 23:43:00 deraadt Exp $ */ +/* $OpenBSD: time.c,v 1.20 2015/01/16 06:40:13 deraadt Exp $ */ /* $NetBSD: time.c,v 1.7 1995/06/27 00:34:00 jtc Exp $ */ /* @@ -30,7 +30,6 @@ * SUCH DAMAGE. */ -#include <sys/param.h> #include <sys/time.h> #include <sys/resource.h> #include <sys/wait.h> diff --git a/usr.bin/tmux/procname.c b/usr.bin/tmux/procname.c index aeaf0fa49a3..3b6081c09c0 100644 --- a/usr.bin/tmux/procname.c +++ b/usr.bin/tmux/procname.c @@ -1,4 +1,4 @@ -/* $OpenBSD: procname.c,v 1.13 2014/07/04 05:58:31 guenther Exp $ */ +/* $OpenBSD: procname.c,v 1.14 2015/01/16 06:40:13 deraadt Exp $ */ /* * Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net> @@ -16,7 +16,8 @@ * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#include <sys/param.h> +#include <sys/param.h> /* MAXCOMLEN */ +#include <sys/types.h> #include <sys/proc.h> #include <sys/sysctl.h> #include <sys/stat.h> diff --git a/usr.bin/top/machine.c b/usr.bin/top/machine.c index 44d0e1ebe3a..fc87693b614 100644 --- a/usr.bin/top/machine.c +++ b/usr.bin/top/machine.c @@ -1,4 +1,4 @@ -/* $OpenBSD: machine.c,v 1.80 2014/09/17 01:56:54 dlg Exp $ */ +/* $OpenBSD: machine.c,v 1.81 2015/01/16 06:40:13 deraadt Exp $ */ /*- * Copyright (c) 1994 Thorsten Lockert <tholo@sigmasoft.com> @@ -33,8 +33,9 @@ * Patch for new swapctl(2) by Tobias Weingartner <weingart@openbsd.org> */ +#include <sys/param.h> /* DEV_BSIZE MAXCOMLEN PZERO */ #include <sys/types.h> -#include <sys/param.h> +#include <sys/signal.h> #include <sys/mount.h> #include <sys/proc.h> #include <sys/sched.h> diff --git a/usr.bin/top/utils.c b/usr.bin/top/utils.c index 3eaef986555..7e33cdead4a 100644 --- a/usr.bin/top/utils.c +++ b/usr.bin/top/utils.c @@ -1,4 +1,4 @@ -/* $OpenBSD: utils.c,v 1.24 2013/04/02 06:04:50 guenther Exp $ */ +/* $OpenBSD: utils.c,v 1.25 2015/01/16 06:40:13 deraadt Exp $ */ /* * Top users/processes display for Unix @@ -32,13 +32,14 @@ * This file contains various handy utilities used by top. */ -#include <sys/param.h> +#include <sys/types.h> #include <sys/sysctl.h> #include <err.h> #include <stdio.h> #include <string.h> #include <stdlib.h> #include <stdint.h> +#include <limits.h> #include "top.h" #include "machine.h" diff --git a/usr.bin/tput/tput.c b/usr.bin/tput/tput.c index 84bafe6e787..fbe7f672fab 100644 --- a/usr.bin/tput/tput.c +++ b/usr.bin/tput/tput.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tput.c,v 1.20 2014/10/08 04:10:47 doug Exp $ */ +/* $OpenBSD: tput.c,v 1.21 2015/01/16 06:40:13 deraadt Exp $ */ /* * Copyright (c) 1999 Todd C. Miller <Todd.Miller@courtesan.com> @@ -44,8 +44,6 @@ * SUCH DAMAGE. */ -#include <sys/param.h> - #include <ctype.h> #include <err.h> #include <curses.h> @@ -54,8 +52,11 @@ #include <stdlib.h> #include <termios.h> #include <unistd.h> +#include <limits.h> #include <string.h> +#define MAXIMUM(a, b) (((a) > (b)) ? (a) : (b)) + #include <sys/wait.h> static void init(void); @@ -229,7 +230,7 @@ process(char *cap, char *str, char **argv) } } } - arg_need = MAX(arg_need, popcount); + arg_need = MAXIMUM(arg_need, popcount); if (arg_need > 9) errx(2, "too many arguments (%d) for capability `%s'", arg_need, cap); diff --git a/usr.bin/uname/uname.c b/usr.bin/uname/uname.c index 674ff10c135..d9b1821946c 100644 --- a/usr.bin/uname/uname.c +++ b/usr.bin/uname/uname.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uname.c,v 1.12 2011/10/21 14:48:02 ajacoutot Exp $ */ +/* $OpenBSD: uname.c,v 1.13 2015/01/16 06:40:13 deraadt Exp $ */ /* * Copyright (c) 1994 Winning Strategies, Inc. @@ -31,7 +31,7 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include <sys/param.h> +#include <sys/param.h> /* MACHINE_ARCH */ #include <stdio.h> #include <stdlib.h> #include <locale.h> diff --git a/usr.bin/uudecode/uudecode.c b/usr.bin/uudecode/uudecode.c index 2b03e6ef615..65801e1093b 100644 --- a/usr.bin/uudecode/uudecode.c +++ b/usr.bin/uudecode/uudecode.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uudecode.c,v 1.19 2014/05/20 01:25:23 guenther Exp $ */ +/* $OpenBSD: uudecode.c,v 1.20 2015/01/16 06:40:13 deraadt Exp $ */ /* $FreeBSD: uudecode.c,v 1.49 2003/05/03 19:44:46 obrien Exp $ */ /*- @@ -35,7 +35,6 @@ * Used with uuencode. */ -#include <sys/param.h> #include <sys/socket.h> #include <sys/stat.h> @@ -51,6 +50,7 @@ #include <stdlib.h> #include <string.h> #include <unistd.h> +#include <limits.h> static const char *infile, *outfile; static FILE *infp, *outfp; @@ -182,7 +182,7 @@ decode2(void) void *handle; struct passwd *pw; struct stat st; - char buf[MAXPATHLEN]; + char buf[PATH_MAX]; base64 = 0; /* search for header line */ @@ -334,7 +334,7 @@ uu_decode(void) { int i, ch; char *p; - char buf[MAXPATHLEN]; + char buf[PATH_MAX]; /* for each input line */ for (;;) { @@ -412,8 +412,8 @@ static int base64_decode(void) { int n; - char inbuf[MAXPATHLEN]; - unsigned char outbuf[MAXPATHLEN * 4]; + char inbuf[PATH_MAX]; + unsigned char outbuf[PATH_MAX * 4]; for (;;) { switch (get_line(inbuf, sizeof(inbuf))) { diff --git a/usr.bin/uuencode/uuencode.c b/usr.bin/uuencode/uuencode.c index ccce77bf7a5..6e203fb456c 100644 --- a/usr.bin/uuencode/uuencode.c +++ b/usr.bin/uuencode/uuencode.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uuencode.c,v 1.10 2009/10/27 23:59:46 deraadt Exp $ */ +/* $OpenBSD: uuencode.c,v 1.11 2015/01/16 06:40:13 deraadt Exp $ */ /* $FreeBSD: uuencode.c,v 1.18 2004/01/22 07:23:35 grehan Exp $ */ /*- @@ -34,7 +34,6 @@ * Encode a file so it can be mailed to a remote system. */ -#include <sys/param.h> #include <sys/socket.h> #include <sys/stat.h> diff --git a/usr.bin/vacation/vacation.c b/usr.bin/vacation/vacation.c index 4f3e185effe..44611c1b8f9 100644 --- a/usr.bin/vacation/vacation.c +++ b/usr.bin/vacation/vacation.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vacation.c,v 1.34 2013/11/26 19:25:39 deraadt Exp $ */ +/* $OpenBSD: vacation.c,v 1.35 2015/01/16 06:40:13 deraadt Exp $ */ /* $NetBSD: vacation.c,v 1.7 1995/04/29 05:58:27 cgd Exp $ */ /* @@ -36,7 +36,6 @@ ** Berkeley, California */ -#include <sys/param.h> #include <sys/stat.h> #include <fcntl.h> #include <pwd.h> diff --git a/usr.bin/vi/common/exf.c b/usr.bin/vi/common/exf.c index c7aefb308ae..044e3cf01e0 100644 --- a/usr.bin/vi/common/exf.c +++ b/usr.bin/vi/common/exf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: exf.c,v 1.32 2014/11/14 20:23:56 tedu Exp $ */ +/* $OpenBSD: exf.c,v 1.33 2015/01/16 06:40:14 deraadt Exp $ */ /*- * Copyright (c) 1992, 1993, 1994 @@ -11,7 +11,6 @@ #include "config.h" -#include <sys/param.h> #include <sys/queue.h> #include <sys/stat.h> @@ -123,7 +122,7 @@ file_init(SCR *sp, FREF *frp, char *rcv_name, int flags) struct stat sb; size_t psize; int fd, exists, open_err, readonly; - char *oname, tname[MAXPATHLEN]; + char *oname, tname[PATH_MAX]; open_err = readonly = 0; @@ -450,7 +449,7 @@ file_spath(SCR *sp, FREF *frp, struct stat *sbp, int *existsp) CHAR_T savech; size_t len; int found; - char *name, *p, *t, path[MAXPATHLEN]; + char *name, *p, *t, path[PATH_MAX]; /* * If the name is NULL or an explicit reference (i.e., the first @@ -738,7 +737,7 @@ file_write(SCR *sp, MARK *fm, MARK *tm, char *name, int flags) size_t len; u_long nlno, nch; int fd, nf, noname, oflags, rval; - char *p, *s, *t, buf[MAXPATHLEN + 64]; + char *p, *s, *t, buf[PATH_MAX + 64]; const char *msgstr; ep = sp->ep; diff --git a/usr.bin/vi/common/key.c b/usr.bin/vi/common/key.c index dd3101c9bd1..63421dd75d1 100644 --- a/usr.bin/vi/common/key.c +++ b/usr.bin/vi/common/key.c @@ -1,4 +1,4 @@ -/* $OpenBSD: key.c,v 1.13 2014/11/12 04:28:41 bentley Exp $ */ +/* $OpenBSD: key.c,v 1.14 2015/01/16 06:40:14 deraadt Exp $ */ /*- * Copyright (c) 1991, 1993, 1994 @@ -11,7 +11,6 @@ #include "config.h" -#include <sys/param.h> #include <sys/queue.h> #include <sys/time.h> @@ -28,6 +27,8 @@ #include "common.h" #include "../vi/vi.h" +#define MAXIMUM(a, b) (((a) > (b)) ? (a) : (b)) + static int v_event_append(SCR *, EVENT *); static int v_event_grow(SCR *, int); static int v_key_cmp(const void *, const void *); @@ -344,7 +345,7 @@ v_event_push(SCR *sp, EVENT *p_evp, CHAR_T *p_s, size_t nitems, u_int flags) */ #define TERM_PUSH_SHIFT 30 total = gp->i_cnt + gp->i_next + nitems + TERM_PUSH_SHIFT; - if (total >= gp->i_nelem && v_event_grow(sp, MAX(total, 64))) + if (total >= gp->i_nelem && v_event_grow(sp, MAXIMUM(total, 64))) return (1); if (gp->i_cnt) MEMMOVE(gp->i_event + TERM_PUSH_SHIFT + nitems, @@ -383,7 +384,7 @@ v_event_append(SCR *sp, EVENT *argp) gp = sp->gp; if (gp->i_event == NULL || nevents > gp->i_nelem - (gp->i_next + gp->i_cnt)) - v_event_grow(sp, MAX(nevents, 64)); + v_event_grow(sp, MAXIMUM(nevents, 64)); evp = gp->i_event + gp->i_next + gp->i_cnt; gp->i_cnt += nevents; diff --git a/usr.bin/vi/common/msg.c b/usr.bin/vi/common/msg.c index 8ea5b983307..147311b173e 100644 --- a/usr.bin/vi/common/msg.c +++ b/usr.bin/vi/common/msg.c @@ -1,4 +1,4 @@ -/* $OpenBSD: msg.c,v 1.21 2014/11/12 16:29:04 millert Exp $ */ +/* $OpenBSD: msg.c,v 1.22 2015/01/16 06:40:14 deraadt Exp $ */ /*- * Copyright (c) 1991, 1993, 1994 @@ -11,7 +11,6 @@ #include "config.h" -#include <sys/param.h> #include <sys/queue.h> #include <sys/stat.h> #include <sys/time.h> @@ -519,7 +518,7 @@ msg_open(SCR *sp, char *file) DB *db; DBT data, key; recno_t msgno; - char *p, *t, buf[MAXPATHLEN]; + char *p, *t, buf[PATH_MAX]; if ((p = strrchr(file, '/')) != NULL && p[1] == '\0' && (((t = getenv("LC_MESSAGES")) != NULL && t[0] != '\0') || diff --git a/usr.bin/vi/common/recover.c b/usr.bin/vi/common/recover.c index b66dfd225ba..6c95cd1479b 100644 --- a/usr.bin/vi/common/recover.c +++ b/usr.bin/vi/common/recover.c @@ -1,4 +1,4 @@ -/* $OpenBSD: recover.c,v 1.19 2014/11/14 20:27:03 tedu Exp $ */ +/* $OpenBSD: recover.c,v 1.20 2015/01/16 06:40:14 deraadt Exp $ */ /*- * Copyright (c) 1993, 1994 @@ -11,7 +11,6 @@ #include "config.h" -#include <sys/param.h> #include <sys/queue.h> #include <sys/stat.h> @@ -123,7 +122,7 @@ rcv_tmp(SCR *sp, EXF *ep, char *name) { struct stat sb; int fd; - char *dp, *p, path[MAXPATHLEN]; + char *dp, *p, path[PATH_MAX]; /* * !!! @@ -327,9 +326,9 @@ rcv_mailfile(SCR *sp, int issync, char *cp_path) time_t now; uid_t uid; int fd; - char *dp, *p, *t, buf[4096], mpath[MAXPATHLEN]; + char *dp, *p, *t, buf[4096], mpath[PATH_MAX]; char *t1, *t2, *t3; - char host[MAXHOSTNAMELEN]; + char host[HOST_NAME_MAX+1]; gp = sp->gp; if ((pw = getpwuid(uid = getuid())) == NULL) { @@ -475,7 +474,7 @@ rcv_list(SCR *sp) DIR *dirp; FILE *fp; int found; - char *p, *t, file[MAXPATHLEN], path[MAXPATHLEN]; + char *p, *t, file[PATH_MAX], path[PATH_MAX]; /* Open the recovery directory for reading. */ if (opts_empty(sp, O_RECDIR, 0)) @@ -579,7 +578,7 @@ rcv_read(SCR *sp, FREF *frp) time_t rec_mtime; int fd, found, locked, requested, sv_fd; char *name, *p, *t, *rp, *recp, *pathp; - char file[MAXPATHLEN], path[MAXPATHLEN], recpath[MAXPATHLEN]; + char file[PATH_MAX], path[PATH_MAX], recpath[PATH_MAX]; if (opts_empty(sp, O_RECDIR, 0)) return (1); @@ -828,7 +827,7 @@ static void rcv_email(SCR *sp, char *fname) { struct stat sb; - char buf[MAXPATHLEN * 2 + 20]; + char buf[PATH_MAX * 2 + 20]; if (_PATH_SENDMAIL[0] != '/' || stat(_PATH_SENDMAIL, &sb)) msgq_str(sp, M_SYSERR, diff --git a/usr.bin/vi/common/seq.c b/usr.bin/vi/common/seq.c index 183b11fe517..9eb933fdc85 100644 --- a/usr.bin/vi/common/seq.c +++ b/usr.bin/vi/common/seq.c @@ -1,4 +1,4 @@ -/* $OpenBSD: seq.c,v 1.9 2014/11/12 04:28:41 bentley Exp $ */ +/* $OpenBSD: seq.c,v 1.10 2015/01/16 06:40:14 deraadt Exp $ */ /*- * Copyright (c) 1992, 1993, 1994 @@ -11,7 +11,6 @@ #include "config.h" -#include <sys/param.h> #include <sys/queue.h> #include <bitstring.h> @@ -24,6 +23,8 @@ #include "common.h" +#define MINIMUM(a, b) (((a) < (b)) ? (a) : (b)) + /* * seq_set -- * Internal version to enter a sequence. @@ -195,7 +196,7 @@ seq_find(SCR *sp, SEQ **lastqp, EVENT *e_input, CHAR_T *c_input, size_t ilen, if (qp->input[0] < c_input[0] || qp->stype != stype || F_ISSET(qp, SEQ_FUNCMAP)) continue; - diff = memcmp(qp->input, c_input, MIN(qp->ilen, ilen)); + diff = memcmp(qp->input, c_input, MINIMUM(qp->ilen, ilen)); } else { if (qp->input[0] > e_input->e_c) break; @@ -203,7 +204,7 @@ seq_find(SCR *sp, SEQ **lastqp, EVENT *e_input, CHAR_T *c_input, size_t ilen, qp->stype != stype || F_ISSET(qp, SEQ_FUNCMAP)) continue; diff = - e_memcmp(qp->input, e_input, MIN(qp->ilen, ilen)); + e_memcmp(qp->input, e_input, MINIMUM(qp->ilen, ilen)); } if (diff > 0) break; diff --git a/usr.bin/vi/common/util.c b/usr.bin/vi/common/util.c index d69bbbc0bae..c02210a2645 100644 --- a/usr.bin/vi/common/util.c +++ b/usr.bin/vi/common/util.c @@ -1,4 +1,4 @@ -/* $OpenBSD: util.c,v 1.9 2014/11/12 04:28:41 bentley Exp $ */ +/* $OpenBSD: util.c,v 1.10 2015/01/16 06:40:14 deraadt Exp $ */ /*- * Copyright (c) 1991, 1993, 1994 @@ -11,7 +11,6 @@ #include "config.h" -#include <sys/param.h> #include <sys/queue.h> #include <bitstring.h> @@ -24,6 +23,8 @@ #include "common.h" +#define MAXIMUM(a, b) (((a) > (b)) ? (a) : (b)) + /* * binc -- * Increase the size of a buffer. @@ -39,7 +40,7 @@ binc(SCR *sp, void *bp, size_t *bsizep, size_t min) if (min && *bsizep >= min) return (bp); - csize = *bsizep + MAX(min, 256); + csize = *bsizep + MAXIMUM(min, 256); REALLOC(sp, bp, void *, csize); if (bp == NULL) { diff --git a/usr.bin/vi/ex/ex_cd.c b/usr.bin/vi/ex/ex_cd.c index 305fb82b4f8..b7532630bbb 100644 --- a/usr.bin/vi/ex/ex_cd.c +++ b/usr.bin/vi/ex/ex_cd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ex_cd.c,v 1.10 2014/11/12 04:28:41 bentley Exp $ */ +/* $OpenBSD: ex_cd.c,v 1.11 2015/01/16 06:40:14 deraadt Exp $ */ /*- * Copyright (c) 1992, 1993, 1994 @@ -11,7 +11,6 @@ #include "config.h" -#include <sys/param.h> #include <sys/queue.h> #include <bitstring.h> @@ -38,7 +37,7 @@ ex_cd(SCR *sp, EXCMD *cmdp) ARGS *ap; CHAR_T savech; char *dir, *p, *t; /* XXX: END OF THE STACK, DON'T TRUST GETCWD. */ - char buf[MAXPATHLEN * 2]; + char buf[PATH_MAX * 2]; /* * !!! diff --git a/usr.bin/vi/ex/ex_cscope.c b/usr.bin/vi/ex/ex_cscope.c index 757b741ca69..0bca4cbb2cd 100644 --- a/usr.bin/vi/ex/ex_cscope.c +++ b/usr.bin/vi/ex/ex_cscope.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ex_cscope.c,v 1.23 2014/11/14 20:27:03 tedu Exp $ */ +/* $OpenBSD: ex_cscope.c,v 1.24 2015/01/16 06:40:14 deraadt Exp $ */ /*- * Copyright (c) 1994, 1996 @@ -11,7 +11,6 @@ #include "config.h" -#include <sys/param.h> #include <sys/queue.h> #include <sys/stat.h> #include <sys/time.h> @@ -190,7 +189,7 @@ cscope_add(SCR *sp, EXCMD *cmdp, char *dname) CSC *csc; size_t len; int cur_argc; - char *dbname, path[MAXPATHLEN]; + char *dbname, path[PATH_MAX]; exp = EXP(sp); @@ -283,7 +282,7 @@ get_paths(SCR *sp, CSC *csc) struct stat sb; int fd, nentries; size_t len; - char *p, **pathp, buf[MAXPATHLEN * 2]; + char *p, **pathp, buf[PATH_MAX * 2]; /* * EXTENSION #2: @@ -354,7 +353,7 @@ static int run_cscope(SCR *sp, CSC *csc, char *dbname) { int to_cs[2], from_cs[2]; - char cmd[MAXPATHLEN * 2]; + char cmd[PATH_MAX * 2]; /* * Cscope reads from to_cs[0] and writes to from_cs[1]; vi reads from @@ -752,7 +751,7 @@ csc_file(SCR *sp, CSC *csc, char *name, char **dirp, size_t *dlenp, int *isolderp) { struct stat sb; - char **pp, buf[MAXPATHLEN]; + char **pp, buf[PATH_MAX]; /* * Check for the file in all of the listed paths. If we don't diff --git a/usr.bin/vi/ex/ex_filter.c b/usr.bin/vi/ex/ex_filter.c index bfdf8cfeea8..0beac24b385 100644 --- a/usr.bin/vi/ex/ex_filter.c +++ b/usr.bin/vi/ex/ex_filter.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ex_filter.c,v 1.12 2014/11/12 04:28:41 bentley Exp $ */ +/* $OpenBSD: ex_filter.c,v 1.13 2015/01/16 06:40:14 deraadt Exp $ */ /*- * Copyright (c) 1991, 1993, 1994 @@ -11,7 +11,6 @@ #include "config.h" -#include <sys/param.h> #include <sys/stat.h> #include <sys/types.h> #include <sys/queue.h> @@ -46,7 +45,7 @@ ex_filter(SCR *sp, EXCMD *cmdp, MARK *fm, MARK *tm, MARK *rp, char *cmd, pid_t parent_writer_pid, utility_pid; recno_t nread; int input[2], output[2], fd, rval; - char *name, tname[MAXPATHLEN]; + char *name, tname[PATH_MAX]; rval = 0; diff --git a/usr.bin/vi/ex/ex_init.c b/usr.bin/vi/ex/ex_init.c index f850b118cc7..86effa05ac7 100644 --- a/usr.bin/vi/ex/ex_init.c +++ b/usr.bin/vi/ex/ex_init.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ex_init.c,v 1.13 2014/11/12 16:29:04 millert Exp $ */ +/* $OpenBSD: ex_init.c,v 1.14 2015/01/16 06:40:14 deraadt Exp $ */ /*- * Copyright (c) 1992, 1993, 1994 @@ -11,7 +11,6 @@ #include "config.h" -#include <sys/param.h> #include <sys/queue.h> #include <sys/stat.h> @@ -135,7 +134,7 @@ int ex_exrc(SCR *sp) { struct stat hsb, lsb; - char *p, path[MAXPATHLEN]; + char *p, path[PATH_MAX]; int fd; /* @@ -344,7 +343,7 @@ exrc_isok(SCR *sp, struct stat *sbp, int *fdp, char *path, int rootown, enum { ROOTOWN, OWN, WRITER } etype; uid_t euid; int nf1, nf2; - char *a, *b, buf[MAXPATHLEN]; + char *a, *b, buf[PATH_MAX]; if ((*fdp = open(path, O_RDONLY, 0)) < 0) { if (errno == ENOENT) diff --git a/usr.bin/vi/ex/ex_shell.c b/usr.bin/vi/ex/ex_shell.c index 43188804798..6a4888b820e 100644 --- a/usr.bin/vi/ex/ex_shell.c +++ b/usr.bin/vi/ex/ex_shell.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ex_shell.c,v 1.13 2014/11/12 04:28:41 bentley Exp $ */ +/* $OpenBSD: ex_shell.c,v 1.14 2015/01/16 06:40:14 deraadt Exp $ */ /*- * Copyright (c) 1992, 1993, 1994 @@ -11,7 +11,6 @@ #include "config.h" -#include <sys/param.h> #include <sys/queue.h> #include <sys/wait.h> @@ -26,6 +25,8 @@ #include "../common/common.h" +#define MINIMUM(a, b) (((a) < (b)) ? (a) : (b)) + /* * ex_shell -- :sh[ell] * Invoke the program named in the SHELL environment variable @@ -37,7 +38,7 @@ int ex_shell(SCR *sp, EXCMD *cmdp) { int rval; - char buf[MAXPATHLEN]; + char buf[PATH_MAX]; /* We'll need a shell. */ if (opts_empty(sp, O_SHELL, 0)) @@ -166,7 +167,7 @@ proc_wait(SCR *sp, pid_t pid, const char *cmd, int silent, int okpipe) p = msg_print(sp, cmd, &nf); len = strlen(p); msgq(sp, M_ERR, "%.*s%s: received signal: %s%s", - MIN(len, 20), p, len > 20 ? " ..." : "", + MINIMUM(len, 20), p, len > 20 ? " ..." : "", strsignal(WTERMSIG(pstat)), WCOREDUMP(pstat) ? "; core dumped" : ""); if (nf) @@ -188,7 +189,7 @@ proc_wait(SCR *sp, pid_t pid, const char *cmd, int silent, int okpipe) p = msg_print(sp, cmd, &nf); len = strlen(p); msgq(sp, M_ERR, "%.*s%s: exited with status %d", - MIN(len, 20), p, len > 20 ? " ..." : "", + MINIMUM(len, 20), p, len > 20 ? " ..." : "", WEXITSTATUS(pstat)); if (nf) FREE_SPACE(sp, p, 0); diff --git a/usr.bin/vi/ex/ex_subst.c b/usr.bin/vi/ex/ex_subst.c index eff4ed755a2..cdbf5fd7141 100644 --- a/usr.bin/vi/ex/ex_subst.c +++ b/usr.bin/vi/ex/ex_subst.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ex_subst.c,v 1.21 2014/11/12 04:28:41 bentley Exp $ */ +/* $OpenBSD: ex_subst.c,v 1.22 2015/01/16 06:40:14 deraadt Exp $ */ /*- * Copyright (c) 1992, 1993, 1994 @@ -11,7 +11,6 @@ #include "config.h" -#include <sys/param.h> #include <sys/queue.h> #include <sys/time.h> @@ -27,6 +26,8 @@ #include "../common/common.h" #include "../vi/vi.h" +#define MAXIMUM(a, b) (((a) > (b)) ? (a) : (b)) + #define SUB_FIRST 0x01 /* The 'r' flag isn't reasonable. */ #define SUB_MUSTSETR 0x02 /* The 'r' flag is required. */ @@ -312,7 +313,7 @@ ex_subtilde(SCR *sp, EXCMD *cmdp) #define BUILD(sp, l, len) { \ if (lbclen + (len) > lblen) { \ - lblen += MAX(lbclen + (len), 256); \ + lblen += MAXIMUM(lbclen + (len), 256); \ REALLOC((sp), lb, char *, lblen); \ if (lb == NULL) { \ lbclen = 0; \ @@ -325,7 +326,7 @@ ex_subtilde(SCR *sp, EXCMD *cmdp) #define NEEDSP(sp, len, pnt) { \ if (lbclen + (len) > lblen) { \ - lblen += MAX(lbclen + (len), 256); \ + lblen += MAXIMUM(lbclen + (len), 256); \ REALLOC((sp), lb, char *, lblen); \ if (lb == NULL) { \ lbclen = 0; \ diff --git a/usr.bin/vi/ex/ex_tag.c b/usr.bin/vi/ex/ex_tag.c index ae3f8ab69a5..9dda01b4900 100644 --- a/usr.bin/vi/ex/ex_tag.c +++ b/usr.bin/vi/ex/ex_tag.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ex_tag.c,v 1.20 2014/11/12 16:29:04 millert Exp $ */ +/* $OpenBSD: ex_tag.c,v 1.21 2015/01/16 06:40:14 deraadt Exp $ */ /*- * Copyright (c) 1992, 1993, 1994 @@ -14,7 +14,6 @@ #include "config.h" -#include <sys/param.h> #include <sys/mman.h> #include <sys/queue.h> #include <sys/stat.h> @@ -1124,7 +1123,7 @@ static void ctag_file(SCR *sp, TAGF *tfp, char *name, char **dirp, size_t *dlenp) { struct stat sb; - char *p, buf[MAXPATHLEN]; + char *p, buf[PATH_MAX]; /* * !!! diff --git a/usr.bin/vi/vi/v_scroll.c b/usr.bin/vi/vi/v_scroll.c index 5ecdb944834..6bd2a876571 100644 --- a/usr.bin/vi/vi/v_scroll.c +++ b/usr.bin/vi/vi/v_scroll.c @@ -1,4 +1,4 @@ -/* $OpenBSD: v_scroll.c,v 1.9 2014/11/12 04:28:41 bentley Exp $ */ +/* $OpenBSD: v_scroll.c,v 1.10 2015/01/16 06:40:14 deraadt Exp $ */ /*- * Copyright (c) 1992, 1993, 1994 @@ -11,7 +11,6 @@ #include "config.h" -#include <sys/param.h> #include <sys/queue.h> #include <sys/time.h> @@ -23,6 +22,8 @@ #include "../common/common.h" #include "vi.h" +#define MINIMUM(a, b) (((a) < (b)) ? (a) : (b)) + static void goto_adjust(VICMD *); /* @@ -345,7 +346,7 @@ v_pagedown(SCR *sp, VICMD *vp) * least one line. */ offset = (F_ISSET(vp, VC_C1SET) ? vp->count : 1) * (IS_SPLIT(sp) ? - MIN(sp->t_maxrows, O_VAL(sp, O_WINDOW)) : O_VAL(sp, O_WINDOW)); + MINIMUM(sp->t_maxrows, O_VAL(sp, O_WINDOW)) : O_VAL(sp, O_WINDOW)); offset = offset <= 2 ? 1 : offset - 2; if (vs_sm_scroll(sp, &vp->m_stop, offset, CNTRL_F)) return (1); @@ -396,7 +397,7 @@ v_pageup(SCR *sp, VICMD *vp) * least one line. */ offset = (F_ISSET(vp, VC_C1SET) ? vp->count : 1) * (IS_SPLIT(sp) ? - MIN(sp->t_maxrows, O_VAL(sp, O_WINDOW)) : O_VAL(sp, O_WINDOW)); + MINIMUM(sp->t_maxrows, O_VAL(sp, O_WINDOW)) : O_VAL(sp, O_WINDOW)); offset = offset <= 2 ? 1 : offset - 2; if (vs_sm_scroll(sp, &vp->m_stop, offset, CNTRL_B)) return (1); diff --git a/usr.bin/vi/vi/v_txt.c b/usr.bin/vi/vi/v_txt.c index c74b20a8c80..6296c128d2e 100644 --- a/usr.bin/vi/vi/v_txt.c +++ b/usr.bin/vi/vi/v_txt.c @@ -1,4 +1,4 @@ -/* $OpenBSD: v_txt.c,v 1.27 2014/11/12 04:28:41 bentley Exp $ */ +/* $OpenBSD: v_txt.c,v 1.28 2015/01/16 06:40:14 deraadt Exp $ */ /*- * Copyright (c) 1993, 1994 @@ -11,7 +11,6 @@ #include "config.h" -#include <sys/param.h> #include <sys/queue.h> #include <sys/stat.h> #include <sys/time.h> @@ -28,6 +27,8 @@ #include "../common/common.h" #include "vi.h" +#define MINIMUM(a, b) (((a) < (b)) ? (a) : (b)) + static int txt_abbrev(SCR *, TEXT *, CHAR_T *, int, int *, int *); static void txt_ai_resolve(SCR *, TEXT *, int *); static TEXT *txt_backup(SCR *, TEXTH *, TEXT *, u_int32_t *); @@ -2862,7 +2863,7 @@ txt_Rresolve(SCR *sp, TEXTH *tiqh, TEXT *tp, const size_t orig_len) * okay, the user just extended the file. */ if (input_len < orig_len) { - retain = MIN(tp->owrite, orig_len - input_len); + retain = MINIMUM(tp->owrite, orig_len - input_len); if (db_get(sp, TAILQ_FIRST(tiqh)->lno, DBG_FATAL | DBG_NOCACHE, &p, NULL)) return; diff --git a/usr.bin/vmstat/dkstats.c b/usr.bin/vmstat/dkstats.c index 6d97256b3b6..880caf627c0 100644 --- a/usr.bin/vmstat/dkstats.c +++ b/usr.bin/vmstat/dkstats.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dkstats.c,v 1.36 2014/09/15 19:08:22 miod Exp $ */ +/* $OpenBSD: dkstats.c,v 1.37 2015/01/16 06:40:14 deraadt Exp $ */ /* $NetBSD: dkstats.c,v 1.1 1996/05/10 23:19:27 thorpej Exp $ */ /* @@ -33,7 +33,6 @@ * SUCH DAMAGE. */ -#include <sys/param.h> #include <sys/time.h> #include <sys/disk.h> #include <sys/sched.h> diff --git a/usr.bin/vmstat/vmstat.c b/usr.bin/vmstat/vmstat.c index fd65ac9dc09..c034ba267b8 100644 --- a/usr.bin/vmstat/vmstat.c +++ b/usr.bin/vmstat/vmstat.c @@ -1,5 +1,5 @@ /* $NetBSD: vmstat.c,v 1.29.4.1 1996/06/05 00:21:05 cgd Exp $ */ -/* $OpenBSD: vmstat.c,v 1.135 2014/12/19 20:18:15 tedu Exp $ */ +/* $OpenBSD: vmstat.c,v 1.136 2015/01/16 06:40:14 deraadt Exp $ */ /* * Copyright (c) 1980, 1986, 1991, 1993 @@ -30,7 +30,7 @@ * SUCH DAMAGE. */ -#include <sys/param.h> +#include <sys/param.h> /* MAXCOMLEN */ #include <sys/time.h> #include <sys/proc.h> #include <sys/namei.h> diff --git a/usr.bin/w/proc_compare.c b/usr.bin/w/proc_compare.c index a2b280f9551..77be7a9e389 100644 --- a/usr.bin/w/proc_compare.c +++ b/usr.bin/w/proc_compare.c @@ -1,4 +1,4 @@ -/* $OpenBSD: proc_compare.c,v 1.14 2014/07/04 05:58:31 guenther Exp $ */ +/* $OpenBSD: proc_compare.c,v 1.15 2015/01/16 06:40:14 deraadt Exp $ */ /*- * Copyright (c) 1990, 1993 @@ -29,7 +29,7 @@ * SUCH DAMAGE. */ -#include <sys/param.h> +#include <sys/param.h> /* MAXCOMLEN */ #include <sys/proc.h> #include <sys/sysctl.h> #include <sys/time.h> diff --git a/usr.bin/w/w.c b/usr.bin/w/w.c index 2847004aa45..08f6b951528 100644 --- a/usr.bin/w/w.c +++ b/usr.bin/w/w.c @@ -1,4 +1,4 @@ -/* $OpenBSD: w.c,v 1.56 2014/07/08 23:24:28 deraadt Exp $ */ +/* $OpenBSD: w.c,v 1.57 2015/01/16 06:40:14 deraadt Exp $ */ /*- * Copyright (c) 1980, 1991, 1993, 1994 @@ -35,10 +35,11 @@ * This program is similar to the systat command on Tenex/Tops 10/20 * */ -#include <sys/param.h> +#include <sys/param.h> /* MAXCOMLEN */ #include <sys/time.h> #include <sys/stat.h> #include <sys/sysctl.h> +#include <sys/signal.h> #include <sys/proc.h> #include <sys/ioctl.h> #include <sys/socket.h> @@ -77,7 +78,7 @@ int header = 1; /* true if -h flag: don't print heading */ int nflag = 1; /* true if -n flag: don't convert addrs */ int sortidle; /* sort by idle time */ char *sel_user; /* login of particular user selected */ -char domain[MAXHOSTNAMELEN]; +char domain[HOST_NAME_MAX+1]; #define NAME_WIDTH 8 #define HOST_WIDTH 16 @@ -110,7 +111,7 @@ main(int argc, char *argv[]) struct in_addr addr; int ch, i, nentries, nusers, wcmd; char *memf, *nlistf, *p, *x; - char buf[MAXHOSTNAMELEN], errbuf[_POSIX2_LINE_MAX]; + char buf[HOST_NAME_MAX+1], errbuf[_POSIX2_LINE_MAX]; /* Are we w(1) or uptime(1)? */ p = __progname; diff --git a/usr.bin/wall/wall.c b/usr.bin/wall/wall.c index cdb65aa979a..b44d1cffa5c 100644 --- a/usr.bin/wall/wall.c +++ b/usr.bin/wall/wall.c @@ -1,4 +1,4 @@ -/* $OpenBSD: wall.c,v 1.25 2009/10/27 23:59:49 deraadt Exp $ */ +/* $OpenBSD: wall.c,v 1.26 2015/01/16 06:40:14 deraadt Exp $ */ /* $NetBSD: wall.c,v 1.6 1994/11/17 07:17:58 jtc Exp $ */ /* @@ -35,7 +35,6 @@ * is entitled "Mechanisms for Broadcast and Selective Broadcast". */ -#include <sys/param.h> #include <sys/stat.h> #include <sys/time.h> #include <sys/uio.h> @@ -47,6 +46,7 @@ #include <stdlib.h> #include <string.h> #include <unistd.h> +#include <limits.h> #include <utmp.h> #include <vis.h> #include <err.h> @@ -148,7 +148,7 @@ makemsg(char *fname) time_t now; FILE *fp; int fd; - char *p, *whom, hostname[MAXHOSTNAMELEN], lbuf[100], tmpname[MAXPATHLEN]; + char *p, *whom, hostname[HOST_NAME_MAX+1], lbuf[100], tmpname[PATH_MAX]; char tmpbuf[5]; char *ttynam; diff --git a/usr.bin/wc/wc.c b/usr.bin/wc/wc.c index 5387cd03200..5f1d66f8942 100644 --- a/usr.bin/wc/wc.c +++ b/usr.bin/wc/wc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: wc.c,v 1.16 2013/11/27 13:32:02 okan Exp $ */ +/* $OpenBSD: wc.c,v 1.17 2015/01/16 06:40:14 deraadt Exp $ */ /* * Copyright (c) 1980, 1987, 1991, 1993 @@ -29,15 +29,15 @@ * SUCH DAMAGE. */ +#include <sys/param.h> /* MAXBSIZE */ +#include <sys/stat.h> +#include <sys/file.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <locale.h> #include <ctype.h> #include <err.h> -#include <sys/param.h> -#include <sys/stat.h> -#include <sys/file.h> #include <unistd.h> #include <util.h> diff --git a/usr.bin/which/which.c b/usr.bin/which/which.c index 419b32fe35c..1f2bb65fe0b 100644 --- a/usr.bin/which/which.c +++ b/usr.bin/which/which.c @@ -1,4 +1,4 @@ -/* $OpenBSD: which.c,v 1.19 2014/05/20 01:25:23 guenther Exp $ */ +/* $OpenBSD: which.c,v 1.20 2015/01/16 06:40:14 deraadt Exp $ */ /* * Copyright (c) 1997 Todd C. Miller <Todd.Miller@courtesan.com> @@ -16,7 +16,6 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#include <sys/param.h> #include <sys/stat.h> #include <sys/sysctl.h> @@ -28,6 +27,7 @@ #include <stdlib.h> #include <string.h> #include <unistd.h> +#include <limits.h> #define PROG_WHICH 1 #define PROG_WHEREIS 2 @@ -94,7 +94,7 @@ main(int argc, char *argv[]) int findprog(char *prog, char *path, int progmode, int allmatches) { - char *p, filename[MAXPATHLEN]; + char *p, filename[PATH_MAX]; int proglen, plen, rval = 0; struct stat sbuf; char *pathcpy; diff --git a/usr.bin/write/write.c b/usr.bin/write/write.c index 321bb42a5c0..be3bc10b964 100644 --- a/usr.bin/write/write.c +++ b/usr.bin/write/write.c @@ -1,4 +1,4 @@ -/* $OpenBSD: write.c,v 1.27 2013/04/16 19:24:55 deraadt Exp $ */ +/* $OpenBSD: write.c,v 1.28 2015/01/16 06:40:14 deraadt Exp $ */ /* $NetBSD: write.c,v 1.5 1995/08/31 21:48:32 jtc Exp $ */ /* @@ -33,7 +33,6 @@ * SUCH DAMAGE. */ -#include <sys/param.h> #include <sys/stat.h> #include <ctype.h> #include <stdio.h> @@ -45,6 +44,7 @@ #include <paths.h> #include <pwd.h> #include <unistd.h> +#include <limits.h> #include <utmp.h> #include <err.h> #include <vis.h> @@ -59,7 +59,7 @@ int utmp_chk(char *, char *); int main(int argc, char *argv[]) { - char tty[MAXPATHLEN], *mytty, *cp; + char tty[PATH_MAX], *mytty, *cp; int msgsok, myttyfd; time_t atime; uid_t myuid; @@ -204,7 +204,7 @@ int term_chk(char *tty, int *msgsokP, time_t *atimeP, int showerror) { struct stat s; - char path[MAXPATHLEN]; + char path[PATH_MAX]; (void)snprintf(path, sizeof(path), "%s%s", _PATH_DEV, tty); if (stat(path, &s) < 0) { @@ -226,7 +226,7 @@ do_write(char *tty, char *mytty, uid_t myuid) char *login, *nows; struct passwd *pwd; time_t now; - char path[MAXPATHLEN], host[MAXHOSTNAMELEN], line[512]; + char path[PATH_MAX], host[HOST_NAME_MAX+1], line[512]; gid_t gid; /* Determine our login name before the we reopen() stdout */ diff --git a/usr.bin/x99token/x99token.c b/usr.bin/x99token/x99token.c index 9cb268b3c4b..533fa79534c 100644 --- a/usr.bin/x99token/x99token.c +++ b/usr.bin/x99token/x99token.c @@ -1,4 +1,4 @@ -/* $OpenBSD: x99token.c,v 1.9 2013/11/27 00:13:22 deraadt Exp $ */ +/* $OpenBSD: x99token.c,v 1.10 2015/01/16 06:40:14 deraadt Exp $ */ /* * X9.9 calculator @@ -7,7 +7,7 @@ * * Donated to the Public Domain by Paul Borman */ -#include <sys/param.h> + #include <sys/stat.h> #include <ctype.h> @@ -18,6 +18,7 @@ #include <stdlib.h> #include <string.h> #include <unistd.h> +#include <limits.h> #include <openssl/des.h> #define KEYFILE ".keyfile.des" @@ -36,7 +37,7 @@ main(int argc, char **argv) char buf[256]; DES_key_schedule ks; DES_cblock key; - char _keyfile[MAXPATHLEN]; + char _keyfile[PATH_MAX]; char *keyfile = 0; FILE *fp; int init = 0; diff --git a/usr.bin/xargs/xargs.c b/usr.bin/xargs/xargs.c index 3684c43a6b3..dded1c6a11b 100644 --- a/usr.bin/xargs/xargs.c +++ b/usr.bin/xargs/xargs.c @@ -1,4 +1,4 @@ -/* $OpenBSD: xargs.c,v 1.27 2010/03/25 01:03:57 schwarze Exp $ */ +/* $OpenBSD: xargs.c,v 1.28 2015/01/16 06:40:14 deraadt Exp $ */ /* $FreeBSD: xargs.c,v 1.51 2003/05/03 19:09:11 obrien Exp $ */ /*- @@ -35,7 +35,6 @@ * $xMach: xargs.c,v 1.6 2002/02/23 05:27:47 tim Exp $ */ -#include <sys/param.h> #include <sys/wait.h> #include <ctype.h> diff --git a/usr.bin/xinstall/xinstall.c b/usr.bin/xinstall/xinstall.c index 68f6ec1222d..7b89632c832 100644 --- a/usr.bin/xinstall/xinstall.c +++ b/usr.bin/xinstall/xinstall.c @@ -1,4 +1,4 @@ -/* $OpenBSD: xinstall.c,v 1.57 2014/05/20 01:25:23 guenther Exp $ */ +/* $OpenBSD: xinstall.c,v 1.58 2015/01/16 06:40:15 deraadt Exp $ */ /* $NetBSD: xinstall.c,v 1.9 1995/12/20 10:25:17 jonathan Exp $ */ /* @@ -30,7 +30,7 @@ * SUCH DAMAGE. */ -#include <sys/param.h> +#include <sys/param.h> /* MAXBSIZE */ #include <sys/wait.h> #include <sys/mman.h> #include <sys/stat.h> @@ -46,11 +46,14 @@ #include <stdlib.h> #include <string.h> #include <unistd.h> +#include <limits.h> #include <sysexits.h> #include <utime.h> #include "pathnames.h" +#define MINIMUM(a, b) (((a) < (b)) ? (a) : (b)) + #define DIRECTORY 0x01 /* Tell install it's a directory. */ #define SETFLAGS 0x02 /* Tell install to set flags. */ #define NOCHANGEBITS (UF_IMMUTABLE | UF_APPEND | SF_IMMUTABLE | SF_APPEND) @@ -60,7 +63,7 @@ struct passwd *pp; struct group *gp; int dobackup, docompare, dodir, dopreserve, dostrip, safecopy; int mode = S_IRWXU|S_IRGRP|S_IXGRP|S_IROTH|S_IXOTH; -char pathbuf[MAXPATHLEN], tempfile[MAXPATHLEN]; +char pathbuf[PATH_MAX], tempfile[PATH_MAX]; char *suffix = BACKUP_SUFFIX; uid_t uid; gid_t gid; @@ -372,8 +375,8 @@ install(char *from_name, char *to_name, u_long fset, u_int flags) if (to_sb.st_flags & (NOCHANGEBITS)) (void)chflags(to_name, to_sb.st_flags & ~(NOCHANGEBITS)); if (dobackup) { - char backup[MAXPATHLEN]; - (void)snprintf(backup, MAXPATHLEN, "%s%s", to_name, + char backup[PATH_MAX]; + (void)snprintf(backup, PATH_MAX, "%s%s", to_name, suffix); /* It is ok for the target file not to exist. */ if (rename(to_name, backup) < 0 && errno != ENOENT) { @@ -498,7 +501,7 @@ compare(int from_fd, const char *from_name, size_t from_len, int to_fd, from_off = to_off = (off_t)0; remainder = from_len; do { - length = MIN(remainder, 8 * 1048576); + length = MINIMUM(remainder, 8 * 1048576); remainder -= length; if ((p1 = mmap(NULL, length, PROT_READ, MAP_PRIVATE, @@ -632,7 +635,7 @@ create_tempfile(char *path, char *temp, size_t tsize) int create_newfile(char *path, struct stat *sbp) { - char backup[MAXPATHLEN]; + char backup[PATH_MAX]; /* * Unlink now... avoid ETXTBSY errors later. Try and turn @@ -643,7 +646,7 @@ create_newfile(char *path, struct stat *sbp) (void)chflags(path, sbp->st_flags & ~(NOCHANGEBITS)); if (dobackup) { - (void)snprintf(backup, MAXPATHLEN, "%s%s", path, suffix); + (void)snprintf(backup, PATH_MAX, "%s%s", path, suffix); /* It is ok for the target file not to exist. */ if (rename(path, backup) < 0 && errno != ENOENT) err(EX_OSERR, "rename: %s to %s (errno %d)", path, backup, errno); @@ -729,7 +732,7 @@ file_write(int fd, char *str, size_t cnt, int *rem, int *isempt, int sz) * only examine up to the end of the current file block or * remaining characters to write, whatever is smaller */ - wcnt = MIN(cnt, *rem); + wcnt = MINIMUM(cnt, *rem); cnt -= wcnt; *rem -= wcnt; if (*isempt) { diff --git a/usr.bin/ypcat/ypcat.c b/usr.bin/ypcat/ypcat.c index 1355cf1a606..147b7c3963f 100644 --- a/usr.bin/ypcat/ypcat.c +++ b/usr.bin/ypcat/ypcat.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ypcat.c,v 1.14 2009/10/27 23:59:50 deraadt Exp $ */ +/* $OpenBSD: ypcat.c,v 1.15 2015/01/16 06:40:15 deraadt Exp $ */ /* * Copyright (c) 1992, 1993, 1996 Theo de Raadt <deraadt@theos.com> @@ -26,7 +26,6 @@ * SUCH DAMAGE. */ -#include <sys/param.h> #include <sys/types.h> #include <sys/socket.h> #include <unistd.h> diff --git a/usr.bin/ypmatch/ypmatch.c b/usr.bin/ypmatch/ypmatch.c index 1503633eb7e..d1b445a941c 100644 --- a/usr.bin/ypmatch/ypmatch.c +++ b/usr.bin/ypmatch/ypmatch.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ypmatch.c,v 1.14 2009/10/27 23:59:50 deraadt Exp $ */ +/* $OpenBSD: ypmatch.c,v 1.15 2015/01/16 06:40:15 deraadt Exp $ */ /* $NetBSD: ypmatch.c,v 1.8 1996/05/07 01:24:52 jtc Exp $ */ /* @@ -27,7 +27,6 @@ * SUCH DAMAGE. */ -#include <sys/param.h> #include <sys/types.h> #include <sys/socket.h> #include <stdio.h> diff --git a/usr.bin/ypwhich/ypwhich.c b/usr.bin/ypwhich/ypwhich.c index 961d87656ec..e773c6c207a 100644 --- a/usr.bin/ypwhich/ypwhich.c +++ b/usr.bin/ypwhich/ypwhich.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ypwhich.c,v 1.21 2013/11/15 22:20:04 millert Exp $ */ +/* $OpenBSD: ypwhich.c,v 1.22 2015/01/16 06:40:15 deraadt Exp $ */ /* $NetBSD: ypwhich.c,v 1.6 1996/05/13 02:43:48 thorpej Exp $ */ /* @@ -27,7 +27,6 @@ * SUCH DAMAGE. */ -#include <sys/param.h> #include <sys/types.h> #include <sys/socket.h> diff --git a/usr.sbin/apm/apm.c b/usr.sbin/apm/apm.c index a358f609b68..551a083f875 100644 --- a/usr.sbin/apm/apm.c +++ b/usr.sbin/apm/apm.c @@ -1,4 +1,4 @@ -/* $OpenBSD: apm.c,v 1.28 2014/10/17 07:43:33 jmc Exp $ */ +/* $OpenBSD: apm.c,v 1.29 2015/01/16 06:40:15 deraadt Exp $ */ /* * Copyright (c) 1996 John T. Kohl @@ -29,7 +29,7 @@ * */ -#include <sys/param.h> +#include <sys/types.h> #include <sys/sysctl.h> #include <sys/socket.h> #include <sys/un.h> diff --git a/usr.sbin/apmd/apmd.c b/usr.sbin/apmd/apmd.c index 87dc1ddeead..e73f35a95b3 100644 --- a/usr.sbin/apmd/apmd.c +++ b/usr.sbin/apmd/apmd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: apmd.c,v 1.73 2014/10/28 06:04:19 dcoppa Exp $ */ +/* $OpenBSD: apmd.c,v 1.74 2015/01/16 06:40:15 deraadt Exp $ */ /* * Copyright (c) 1995, 1996 John T. Kohl @@ -29,7 +29,6 @@ * */ -#include <sys/param.h> #include <sys/stat.h> #include <sys/ioctl.h> #include <sys/socket.h> @@ -48,7 +47,9 @@ #include <signal.h> #include <errno.h> #include <err.h> +#include <limits.h> #include <machine/apmvar.h> + #include "pathnames.h" #include "apm-proto.h" @@ -190,7 +191,7 @@ power_status(int fd, int force, struct apm_power_info *pinfo) return acon; } -char socketname[MAXPATHLEN]; +char socketname[PATH_MAX]; void sockunlink(void) diff --git a/usr.sbin/arp/arp.c b/usr.sbin/arp/arp.c index 3c070fbd579..fcd61491e3b 100644 --- a/usr.sbin/arp/arp.c +++ b/usr.sbin/arp/arp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: arp.c,v 1.62 2014/09/07 22:40:30 bluhm Exp $ */ +/* $OpenBSD: arp.c,v 1.63 2015/01/16 06:40:15 deraadt Exp $ */ /* $NetBSD: arp.c,v 1.12 1995/04/24 13:25:18 cgd Exp $ */ /* @@ -37,7 +37,6 @@ * arp - display, set, delete arp table entries and wake up hosts. */ -#include <sys/param.h> #include <sys/file.h> #include <sys/socket.h> #include <sys/sysctl.h> @@ -59,6 +58,7 @@ #include <string.h> #include <paths.h> #include <unistd.h> +#include <limits.h> #include <ifaddrs.h> void dump(void); @@ -841,7 +841,7 @@ do_wakeup(const char *eaddr, const char *iface, int bpf) int get_bpf(void) { - char path[MAXPATHLEN]; + char path[PATH_MAX]; int i, fd; for (i = 0; ; i++) { diff --git a/usr.sbin/bgpctl/irr_asset.c b/usr.sbin/bgpctl/irr_asset.c index 7d303befd54..6c579241327 100644 --- a/usr.sbin/bgpctl/irr_asset.c +++ b/usr.sbin/bgpctl/irr_asset.c @@ -1,4 +1,4 @@ -/* $OpenBSD: irr_asset.c,v 1.10 2014/10/08 16:15:37 deraadt Exp $ */ +/* $OpenBSD: irr_asset.c,v 1.11 2015/01/16 06:40:15 deraadt Exp $ */ /* * Copyright (c) 2007 Henning Brauer <henning@openbsd.org> @@ -17,7 +17,6 @@ */ #include <sys/types.h> -#include <sys/param.h> #include <err.h> #include <stdio.h> #include <stdlib.h> diff --git a/usr.sbin/bgpctl/irr_output.c b/usr.sbin/bgpctl/irr_output.c index 1f86bdb8ca6..36e77ffb99d 100644 --- a/usr.sbin/bgpctl/irr_output.c +++ b/usr.sbin/bgpctl/irr_output.c @@ -1,4 +1,4 @@ -/* $OpenBSD: irr_output.c,v 1.15 2013/11/22 15:15:16 deraadt Exp $ */ +/* $OpenBSD: irr_output.c,v 1.16 2015/01/16 06:40:15 deraadt Exp $ */ /* * Copyright (c) 2007 Henning Brauer <henning@openbsd.org> @@ -17,7 +17,6 @@ */ #include <sys/types.h> -#include <sys/param.h> #include <sys/stat.h> #include <sys/socket.h> #include <err.h> diff --git a/usr.sbin/bgpctl/irr_parser.c b/usr.sbin/bgpctl/irr_parser.c index c61e0aa3520..b707e97e39c 100644 --- a/usr.sbin/bgpctl/irr_parser.c +++ b/usr.sbin/bgpctl/irr_parser.c @@ -1,4 +1,4 @@ -/* $OpenBSD: irr_parser.c,v 1.11 2013/11/22 15:15:16 deraadt Exp $ */ +/* $OpenBSD: irr_parser.c,v 1.12 2015/01/16 06:40:15 deraadt Exp $ */ /* * Copyright (c) 2007 Henning Brauer <henning@openbsd.org> @@ -17,13 +17,13 @@ */ #include <sys/types.h> -#include <sys/param.h> #include <ctype.h> #include <err.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <unistd.h> +#include <limits.h> #include "irrfilter.h" diff --git a/usr.sbin/bgpctl/irr_prefix.c b/usr.sbin/bgpctl/irr_prefix.c index 80a645b0d55..f4bd3006df8 100644 --- a/usr.sbin/bgpctl/irr_prefix.c +++ b/usr.sbin/bgpctl/irr_prefix.c @@ -1,4 +1,4 @@ -/* $OpenBSD: irr_prefix.c,v 1.19 2014/10/08 16:15:37 deraadt Exp $ */ +/* $OpenBSD: irr_prefix.c,v 1.20 2015/01/16 06:40:15 deraadt Exp $ */ /* * Copyright (c) 2007 Henning Brauer <henning@openbsd.org> @@ -17,7 +17,6 @@ */ #include <sys/types.h> -#include <sys/param.h> #include <sys/socket.h> #include <err.h> #include <errno.h> diff --git a/usr.sbin/bgpctl/irrfilter.c b/usr.sbin/bgpctl/irrfilter.c index fb5b4f05fff..0873586dfb8 100644 --- a/usr.sbin/bgpctl/irrfilter.c +++ b/usr.sbin/bgpctl/irrfilter.c @@ -1,4 +1,4 @@ -/* $OpenBSD: irrfilter.c,v 1.4 2007/05/28 23:31:53 henning Exp $ */ +/* $OpenBSD: irrfilter.c,v 1.5 2015/01/16 06:40:15 deraadt Exp $ */ /* * Copyright (c) 2007 Henning Brauer <henning@openbsd.org> @@ -17,7 +17,6 @@ */ #include <sys/types.h> -#include <sys/param.h> #include <err.h> #include <stdio.h> #include <stdlib.h> diff --git a/usr.sbin/bgpd/timer.c b/usr.sbin/bgpd/timer.c index 1690708e7ce..65da0002955 100644 --- a/usr.sbin/bgpd/timer.c +++ b/usr.sbin/bgpd/timer.c @@ -1,4 +1,4 @@ -/* $OpenBSD: timer.c,v 1.15 2012/04/12 17:26:09 claudio Exp $ */ +/* $OpenBSD: timer.c,v 1.16 2015/01/16 06:40:15 deraadt Exp $ */ /* * Copyright (c) 2003-2007 Henning Brauer <henning@openbsd.org> @@ -16,13 +16,14 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#include <sys/param.h> #include <sys/types.h> #include <stdlib.h> #include "bgpd.h" #include "session.h" +#define MAXIMUM(a, b) (((a) > (b)) ? (a) : (b)) + time_t getmonotime(void) { @@ -63,7 +64,7 @@ timer_nextduein(struct peer *p) struct peer_timer *pt; if ((pt = TAILQ_FIRST(&p->timers)) != NULL && pt->val > 0) - return (MAX(pt->val - getmonotime(), 0)); + return (MAXIMUM(pt->val - getmonotime(), 0)); return (-1); } diff --git a/usr.sbin/config/config.h b/usr.sbin/config/config.h index f078f586afd..41aafc8fd17 100644 --- a/usr.sbin/config/config.h +++ b/usr.sbin/config/config.h @@ -1,4 +1,4 @@ -/* $OpenBSD: config.h,v 1.27 2014/05/18 09:29:54 espie Exp $ */ +/* $OpenBSD: config.h,v 1.28 2015/01/16 06:40:16 deraadt Exp $ */ /* $NetBSD: config.h,v 1.30 1997/02/02 21:12:30 thorpej Exp $ */ /* @@ -46,12 +46,8 @@ */ #include <sys/types.h> -#include <sys/param.h> -#if !defined(MAKE_BOOTSTRAP) && defined(BSD) #include <paths.h> -#endif /* ...BSD */ - #include <stdlib.h> #include <unistd.h> diff --git a/usr.sbin/config/files.c b/usr.sbin/config/files.c index b80f6e5cdd0..1610903d14c 100644 --- a/usr.sbin/config/files.c +++ b/usr.sbin/config/files.c @@ -1,4 +1,4 @@ -/* $OpenBSD: files.c,v 1.19 2012/09/17 17:36:13 espie Exp $ */ +/* $OpenBSD: files.c,v 1.20 2015/01/16 06:40:16 deraadt Exp $ */ /* $NetBSD: files.c,v 1.6 1996/03/17 13:18:17 cgd Exp $ */ /* @@ -41,8 +41,6 @@ * from: @(#)files.c 8.1 (Berkeley) 6/6/93 */ -#include <sys/param.h> - #include <errno.h> #include <stdio.h> #include <stdlib.h> diff --git a/usr.sbin/config/gram.y b/usr.sbin/config/gram.y index da4a6177a56..b4229937176 100644 --- a/usr.sbin/config/gram.y +++ b/usr.sbin/config/gram.y @@ -1,5 +1,5 @@ %{ -/* $OpenBSD: gram.y,v 1.23 2012/09/17 17:36:13 espie Exp $ */ +/* $OpenBSD: gram.y,v 1.24 2015/01/16 06:40:16 deraadt Exp $ */ /* $NetBSD: gram.y,v 1.14 1997/02/02 21:12:32 thorpej Exp $ */ /* @@ -42,11 +42,12 @@ * from: @(#)gram.y 8.1 (Berkeley) 6/6/93 */ +#include <sys/param.h> /* NODEV */ #include <sys/types.h> -#include <sys/param.h> #include <ctype.h> #include <stdio.h> #include <stdlib.h> +#include <limits.h> #include <string.h> #include <errno.h> #include "config.h" @@ -447,7 +448,7 @@ cleanup(void) static void setmachine(const char *mch, const char *mcharch) { - char buf[MAXPATHLEN]; + char buf[PATH_MAX]; machine = mch; machinearch = mcharch; diff --git a/usr.sbin/config/main.c b/usr.sbin/config/main.c index 0644a230cd4..6805b2665b4 100644 --- a/usr.sbin/config/main.c +++ b/usr.sbin/config/main.c @@ -1,4 +1,4 @@ -/* $OpenBSD: main.c,v 1.47 2014/05/18 09:29:54 espie Exp $ */ +/* $OpenBSD: main.c,v 1.48 2015/01/16 06:40:16 deraadt Exp $ */ /* $NetBSD: main.c,v 1.22 1997/02/02 21:12:33 thorpej Exp $ */ /* @@ -43,7 +43,6 @@ #include <sys/types.h> #include <sys/stat.h> -#include <sys/param.h> #include <ctype.h> #include <err.h> @@ -52,6 +51,7 @@ #include <stdlib.h> #include <string.h> #include <unistd.h> +#include <limits.h> #include "config.h" @@ -313,7 +313,7 @@ static int mksymlinks(void) { int ret; - char *p, buf[MAXPATHLEN]; + char *p, buf[PATH_MAX]; const char *q; snprintf(buf, sizeof buf, "arch/%s/include", machine); diff --git a/usr.sbin/config/mkheaders.c b/usr.sbin/config/mkheaders.c index 6f29be63686..497dcc8e3d8 100644 --- a/usr.sbin/config/mkheaders.c +++ b/usr.sbin/config/mkheaders.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mkheaders.c,v 1.20 2013/11/23 17:38:15 deraadt Exp $ */ +/* $OpenBSD: mkheaders.c,v 1.21 2015/01/16 06:40:16 deraadt Exp $ */ /* $NetBSD: mkheaders.c,v 1.12 1997/02/02 21:12:34 thorpej Exp $ */ /* @@ -41,8 +41,6 @@ * from: @(#)mkheaders.c 8.1 (Berkeley) 6/6/93 */ -#include <sys/param.h> - #include <ctype.h> #include <errno.h> #include <stdio.h> diff --git a/usr.sbin/config/mkioconf.c b/usr.sbin/config/mkioconf.c index ddc9ec586ea..7dc2ad2ca4d 100644 --- a/usr.sbin/config/mkioconf.c +++ b/usr.sbin/config/mkioconf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mkioconf.c,v 1.32 2014/05/18 09:29:54 espie Exp $ */ +/* $OpenBSD: mkioconf.c,v 1.33 2015/01/16 06:40:16 deraadt Exp $ */ /* $NetBSD: mkioconf.c,v 1.41 1996/11/11 14:18:49 mycroft Exp $ */ /* @@ -41,8 +41,6 @@ * from: @(#)mkioconf.c 8.1 (Berkeley) 6/6/93 */ -#include <sys/param.h> - #include <errno.h> #include <stdio.h> #include <stdlib.h> diff --git a/usr.sbin/config/mkmakefile.c b/usr.sbin/config/mkmakefile.c index 0f497f568cf..7d260aedb58 100644 --- a/usr.sbin/config/mkmakefile.c +++ b/usr.sbin/config/mkmakefile.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mkmakefile.c,v 1.40 2014/06/04 07:14:29 jsg Exp $ */ +/* $OpenBSD: mkmakefile.c,v 1.41 2015/01/16 06:40:16 deraadt Exp $ */ /* $NetBSD: mkmakefile.c,v 1.34 1997/02/02 21:12:36 thorpej Exp $ */ /* @@ -41,8 +41,6 @@ * from: @(#)mkmakefile.c 8.1 (Berkeley) 6/6/93 */ -#include <sys/param.h> - #include <ctype.h> #include <err.h> #include <errno.h> diff --git a/usr.sbin/config/mkswap.c b/usr.sbin/config/mkswap.c index 2783404496d..9926034092b 100644 --- a/usr.sbin/config/mkswap.c +++ b/usr.sbin/config/mkswap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mkswap.c,v 1.14 2013/04/19 15:03:02 florian Exp $ */ +/* $OpenBSD: mkswap.c,v 1.15 2015/01/16 06:40:16 deraadt Exp $ */ /* $NetBSD: mkswap.c,v 1.5 1996/08/31 20:58:27 mycroft Exp $ */ /* @@ -41,7 +41,7 @@ * from: @(#)mkswap.c 8.1 (Berkeley) 6/6/93 */ -#include <sys/param.h> +#include <sys/param.h> /* NODEV */ #include <errno.h> #include <stdio.h> diff --git a/usr.sbin/config/pack.c b/usr.sbin/config/pack.c index 93a74e6e64d..56cfb705f18 100644 --- a/usr.sbin/config/pack.c +++ b/usr.sbin/config/pack.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pack.c,v 1.17 2014/05/18 09:29:54 espie Exp $ */ +/* $OpenBSD: pack.c,v 1.18 2015/01/16 06:40:16 deraadt Exp $ */ /* $NetBSD: pack.c,v 1.5 1996/08/31 21:15:11 mycroft Exp $ */ /* @@ -41,8 +41,6 @@ * from: @(#)pack.c 8.1 (Berkeley) 6/6/93 */ -#include <sys/param.h> - #include <stdlib.h> #include <string.h> diff --git a/usr.sbin/config/scan.l b/usr.sbin/config/scan.l index f37ffc24548..b5c0543325c 100644 --- a/usr.sbin/config/scan.l +++ b/usr.sbin/config/scan.l @@ -1,5 +1,5 @@ %{ -/* $OpenBSD: scan.l,v 1.21 2012/09/17 17:36:13 espie Exp $ */ +/* $OpenBSD: scan.l,v 1.22 2015/01/16 06:40:16 deraadt Exp $ */ /* $NetBSD: scan.l,v 1.13 1997/02/02 21:12:37 thorpej Exp $ */ /* @@ -42,7 +42,6 @@ * from: @(#)scan.l 8.1 (Berkeley) 6/6/93 */ -#include <sys/param.h> #include <errno.h> #include <stdio.h> #include <stdlib.h> diff --git a/usr.sbin/config/sem.c b/usr.sbin/config/sem.c index 328d5f73f1a..87f03b0ac63 100644 --- a/usr.sbin/config/sem.c +++ b/usr.sbin/config/sem.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sem.c,v 1.34 2014/05/18 09:29:54 espie Exp $ */ +/* $OpenBSD: sem.c,v 1.35 2015/01/16 06:40:16 deraadt Exp $ */ /* $NetBSD: sem.c,v 1.10 1996/11/11 23:40:11 gwr Exp $ */ /* @@ -41,7 +41,7 @@ * from: @(#)sem.c 8.1 (Berkeley) 6/6/93 */ -#include <sys/param.h> +#include <sys/param.h> /* NODEV */ #include <ctype.h> #include <err.h> diff --git a/usr.sbin/crunchgen/crunchgen.c b/usr.sbin/crunchgen/crunchgen.c index 679b63d5de1..2da9aca88af 100644 --- a/usr.sbin/crunchgen/crunchgen.c +++ b/usr.sbin/crunchgen/crunchgen.c @@ -1,4 +1,4 @@ -/* $OpenBSD: crunchgen.c,v 1.13 2014/01/11 04:44:15 deraadt Exp $ */ +/* $OpenBSD: crunchgen.c,v 1.14 2015/01/16 06:40:16 deraadt Exp $ */ /* * Copyright (c) 1994 University of Maryland @@ -32,15 +32,16 @@ * Generates a Makefile and main C file for a crunched executable, * from specs given in a .conf file. */ +#include <sys/param.h> /* MACHINE */ +#include <sys/types.h> +#include <sys/stat.h> + #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <ctype.h> #include <string.h> - -#include <sys/types.h> -#include <sys/stat.h> -#include <sys/param.h> +#include <limits.h> #define CRUNCH_VERSION "1.3" @@ -82,15 +83,15 @@ typedef struct prog { strlst_t *srcdirs = NULL; strlst_t *libs = NULL; strlst_t *libdirs = NULL; -char objdir[MAXPATHLEN] = "obj"; +char objdir[PATH_MAX] = "obj"; prog_t *progs = NULL; char line[MAXLINELEN]; -char confname[MAXPATHLEN], infilename[MAXPATHLEN]; -char outmkname[MAXPATHLEN], outcfname[MAXPATHLEN]; -char cachename[MAXPATHLEN], curfilename[MAXPATHLEN]; -char topdir[MAXPATHLEN], execfname[MAXPATHLEN]; +char confname[PATH_MAX], infilename[PATH_MAX]; +char outmkname[PATH_MAX], outcfname[PATH_MAX]; +char cachename[PATH_MAX], curfilename[PATH_MAX]; +char topdir[PATH_MAX], execfname[PATH_MAX]; int linenum = -1; int goterror = 0; @@ -154,7 +155,7 @@ main(int argc, char *argv[]) elf_names = 1; break; case 'L': - if (strlen(optarg) >= MAXPATHLEN) + if (strlen(optarg) >= PATH_MAX) usage(); add_string(&libdirs, optarg); break; @@ -334,7 +335,7 @@ void add_srcdirs(int argc, char **argv) { int i; - char tmppath[MAXPATHLEN]; + char tmppath[PATH_MAX]; int overflow; for (i = 1; i < argc; i++) { @@ -372,8 +373,8 @@ void add_libdirs(int argc, char **argv) { int i; - char tmppath[MAXPATHLEN]; - char tmppath2[MAXPATHLEN]; + char tmppath[PATH_MAX]; + char tmppath2[PATH_MAX]; int overflow; for (i = 1; i < argc; i++) { @@ -581,7 +582,7 @@ gen_outputs(void) void fillin_program(prog_t * p) { - char path[MAXPATHLEN]; + char path[PATH_MAX]; char *srcparent; strlst_t *s; int i; @@ -651,7 +652,7 @@ fillin_program(prog_t * p) void fillin_program_objs(prog_t * p, char *path) { - char *cp, *obj, tempfname[MAXPATHLEN]; + char *cp, *obj, tempfname[PATH_MAX]; int fd, rc; FILE *f; @@ -850,7 +851,7 @@ genident(char *str) char * dir_search(char *progname) { - char path[MAXPATHLEN]; + char path[PATH_MAX]; strlst_t *dir; for (dir = srcdirs; dir != NULL; dir = dir->next) { diff --git a/usr.sbin/dev_mkdb/dev_mkdb.c b/usr.sbin/dev_mkdb/dev_mkdb.c index 08570b688b2..74a05d6d4aa 100644 --- a/usr.sbin/dev_mkdb/dev_mkdb.c +++ b/usr.sbin/dev_mkdb/dev_mkdb.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dev_mkdb.c,v 1.12 2013/11/27 13:32:02 okan Exp $ */ +/* $OpenBSD: dev_mkdb.c,v 1.13 2015/01/16 06:40:16 deraadt Exp $ */ /*- * Copyright (c) 1990, 1993 @@ -29,7 +29,6 @@ * SUCH DAMAGE. */ -#include <sys/param.h> #include <sys/stat.h> #include <db.h> @@ -60,7 +59,7 @@ main(int argc, char *argv[]) HASHINFO info; int ch; u_char buf[MAXNAMLEN + 1]; - char dbtmp[MAXPATHLEN], dbname[MAXPATHLEN]; + char dbtmp[PATH_MAX], dbname[PATH_MAX]; while ((ch = getopt(argc, argv, "")) != -1) switch(ch) { diff --git a/usr.sbin/dhcpd/dhcpd.c b/usr.sbin/dhcpd/dhcpd.c index 8c854bbf9dd..38bd308ddc0 100644 --- a/usr.sbin/dhcpd/dhcpd.c +++ b/usr.sbin/dhcpd/dhcpd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dhcpd.c,v 1.45 2014/07/11 09:42:27 yasuoka Exp $ */ +/* $OpenBSD: dhcpd.c,v 1.46 2015/01/16 06:40:16 deraadt Exp $ */ /* * Copyright (c) 2004 Henning Brauer <henning@cvs.openbsd.org> @@ -320,6 +320,8 @@ lease_ping_timeout(void *vlp) /* from memory.c - needed to be able to walk the lease table */ extern struct subnet *subnets; +#define MINIMUM(a,b) (((a)<(b))?(a):(b)) + void periodic_scan(void *p) { @@ -330,10 +332,10 @@ periodic_scan(void *p) struct lease *l; /* find the shortest lease this server gives out */ - x = MIN(root_group.default_lease_time, root_group.max_lease_time); + x = MINIMUM(root_group.default_lease_time, root_group.max_lease_time); for (n = subnets; n; n = n->next_subnet) for (g = n->group; g; g = g->next) - x = MIN(x, g->default_lease_time); + x = MINIMUM(x, g->default_lease_time); /* use half of the shortest lease as the scan interval */ y = x / 2; diff --git a/usr.sbin/dhcpd/pfutils.c b/usr.sbin/dhcpd/pfutils.c index 1a1d36846eb..cdf1af8b196 100644 --- a/usr.sbin/dhcpd/pfutils.c +++ b/usr.sbin/dhcpd/pfutils.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pfutils.c,v 1.10 2013/10/18 15:19:39 krw Exp $ */ +/* $OpenBSD: pfutils.c,v 1.11 2015/01/16 06:40:16 deraadt Exp $ */ /* * Copyright (c) 2006 Chris Kuethe <ckuethe@openbsd.org> * @@ -17,7 +17,6 @@ #include <sys/types.h> #include <sys/ioctl.h> -#include <sys/param.h> #include <sys/socket.h> #include <sys/time.h> diff --git a/usr.sbin/dhcpd/sync.c b/usr.sbin/dhcpd/sync.c index 27346b82854..3418559492b 100644 --- a/usr.sbin/dhcpd/sync.c +++ b/usr.sbin/dhcpd/sync.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sync.c,v 1.15 2013/10/18 15:19:40 krw Exp $ */ +/* $OpenBSD: sync.c,v 1.16 2015/01/16 06:40:16 deraadt Exp $ */ /* * Copyright (c) 2008 Bob Beck <beck@openbsd.org> @@ -17,7 +17,6 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#include <sys/param.h> #include <sys/stdint.h> #include <sys/file.h> #include <sys/wait.h> diff --git a/usr.sbin/dhcpd/udpsock.c b/usr.sbin/dhcpd/udpsock.c index 548767a14b0..182887ff17c 100644 --- a/usr.sbin/dhcpd/udpsock.c +++ b/usr.sbin/dhcpd/udpsock.c @@ -1,4 +1,4 @@ -/* $OpenBSD: udpsock.c,v 1.1 2014/07/11 09:42:27 yasuoka Exp $ */ +/* $OpenBSD: udpsock.c,v 1.2 2015/01/16 06:40:16 deraadt Exp $ */ /* * Copyright (c) 2014 YASUOKA Masahiko <yasuoka@openbsd.org> @@ -16,7 +16,7 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#include <sys/param.h> +#include <sys/param.h> /* nitems */ #include <sys/socket.h> #include <sys/uio.h> #include <sys/ioctl.h> diff --git a/usr.sbin/dvmrpd/dvmrpd.c b/usr.sbin/dvmrpd/dvmrpd.c index cca3415a6c5..1784b9be26a 100644 --- a/usr.sbin/dvmrpd/dvmrpd.c +++ b/usr.sbin/dvmrpd/dvmrpd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dvmrpd.c,v 1.16 2014/07/12 19:22:32 krw Exp $ */ +/* $OpenBSD: dvmrpd.c,v 1.17 2015/01/16 06:40:16 deraadt Exp $ */ /* * Copyright (c) 2005 Claudio Jeker <claudio@openbsd.org> @@ -23,7 +23,6 @@ #include <sys/queue.h> #include <sys/time.h> #include <sys/stat.h> -#include <sys/param.h> #include <sys/sysctl.h> #include <sys/wait.h> diff --git a/usr.sbin/dvmrpd/kroute.c b/usr.sbin/dvmrpd/kroute.c index d958a376d50..f90a2b2c642 100644 --- a/usr.sbin/dvmrpd/kroute.c +++ b/usr.sbin/dvmrpd/kroute.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kroute.c,v 1.8 2014/06/23 03:46:17 guenther Exp $ */ +/* $OpenBSD: kroute.c,v 1.9 2015/01/16 06:40:16 deraadt Exp $ */ /* * Copyright (c) 2004 Esben Norby <norby@openbsd.org> @@ -17,7 +17,6 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#include <sys/param.h> #include <sys/types.h> #include <sys/socket.h> #include <sys/sysctl.h> diff --git a/usr.sbin/edquota/edquota.c b/usr.sbin/edquota/edquota.c index 7471445c2a2..904569ecca1 100644 --- a/usr.sbin/edquota/edquota.c +++ b/usr.sbin/edquota/edquota.c @@ -33,7 +33,7 @@ /* * Disk quota editor. */ -#include <sys/param.h> +#include <sys/param.h> /* btodb dbtob */ #include <sys/stat.h> #include <sys/file.h> #include <sys/wait.h> @@ -51,6 +51,7 @@ #include <stdlib.h> #include <string.h> #include <unistd.h> +#include <limits.h> char *qfname = QUOTAFILENAME; char *qfextension[] = INITQFNAMES; @@ -61,7 +62,7 @@ struct quotause { struct quotause *next; long flags; struct dqblk dqblk; - char fsname[MAXPATHLEN]; + char fsname[PATH_MAX]; char qfname[1]; /* actually longer */ } *getprivs(u_int, int); #define FOUND 0x01 diff --git a/usr.sbin/eeprom/main.c b/usr.sbin/eeprom/main.c index 3500fbb366f..68fec1aa674 100644 --- a/usr.sbin/eeprom/main.c +++ b/usr.sbin/eeprom/main.c @@ -1,4 +1,4 @@ -/* $OpenBSD: main.c,v 1.19 2014/07/24 19:19:26 miod Exp $ */ +/* $OpenBSD: main.c,v 1.20 2015/01/16 06:40:16 deraadt Exp $ */ /* $NetBSD: main.c,v 1.3 1996/05/16 16:00:55 thorpej Exp $ */ /*- @@ -30,7 +30,6 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include <sys/param.h> #include <err.h> #include <string.h> #include <stdio.h> diff --git a/usr.sbin/hostapd/apme.c b/usr.sbin/hostapd/apme.c index 33ef473dcbe..df4ca930253 100644 --- a/usr.sbin/hostapd/apme.c +++ b/usr.sbin/hostapd/apme.c @@ -1,4 +1,4 @@ -/* $OpenBSD: apme.c,v 1.15 2007/02/08 11:15:55 reyk Exp $ */ +/* $OpenBSD: apme.c,v 1.16 2015/01/16 06:40:17 deraadt Exp $ */ /* * Copyright (c) 2004, 2005 Reyk Floeter <reyk@openbsd.org> @@ -16,9 +16,8 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#include <sys/param.h> +#include <sys/param.h> /* roundup isclr */ #include <sys/ioctl.h> -#include <sys/types.h> #include <sys/socket.h> #include <sys/time.h> #include <sys/uio.h> @@ -41,6 +40,7 @@ #include <stdio.h> #include <string.h> #include <unistd.h> +#include <limits.h> #include "hostapd.h" #include "iapp.h" diff --git a/usr.sbin/hostapd/handle.c b/usr.sbin/hostapd/handle.c index 052d97adb1f..77c6d07d875 100644 --- a/usr.sbin/hostapd/handle.c +++ b/usr.sbin/hostapd/handle.c @@ -1,4 +1,4 @@ -/* $OpenBSD: handle.c,v 1.11 2007/02/08 11:15:55 reyk Exp $ */ +/* $OpenBSD: handle.c,v 1.12 2015/01/16 06:40:17 deraadt Exp $ */ /* * Copyright (c) 2005, 2006 Reyk Floeter <reyk@openbsd.org> @@ -16,7 +16,6 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#include <sys/param.h> #include <sys/ioctl.h> #include <sys/types.h> #include <sys/socket.h> @@ -41,6 +40,7 @@ #include <stdio.h> #include <string.h> #include <unistd.h> +#include <limits.h> #include "hostapd.h" diff --git a/usr.sbin/hostapd/hostapd.c b/usr.sbin/hostapd/hostapd.c index 6ed01d656ac..0e43c64dffd 100644 --- a/usr.sbin/hostapd/hostapd.c +++ b/usr.sbin/hostapd/hostapd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: hostapd.c,v 1.34 2008/05/12 23:49:28 millert Exp $ */ +/* $OpenBSD: hostapd.c,v 1.35 2015/01/16 06:40:17 deraadt Exp $ */ /* * Copyright (c) 2004, 2005 Reyk Floeter <reyk@openbsd.org> @@ -17,9 +17,9 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#include <sys/param.h> #include <sys/ioctl.h> #include <sys/types.h> +#include <sys/signal.h> #include <sys/socket.h> #include <sys/time.h> #include <sys/queue.h> @@ -44,6 +44,7 @@ #include <stdarg.h> #include <string.h> #include <unistd.h> +#include <limits.h> #include <err.h> #include "hostapd.h" diff --git a/usr.sbin/hostapd/hostapd.h b/usr.sbin/hostapd/hostapd.h index 3bf4a9e1761..e01cfbcca94 100644 --- a/usr.sbin/hostapd/hostapd.h +++ b/usr.sbin/hostapd/hostapd.h @@ -1,4 +1,4 @@ -/* $OpenBSD: hostapd.h,v 1.20 2006/12/31 03:25:58 reyk Exp $ */ +/* $OpenBSD: hostapd.h,v 1.21 2015/01/16 06:40:17 deraadt Exp $ */ /* * Copyright (c) 2004, 2005 Reyk Floeter <reyk@openbsd.org> @@ -19,7 +19,6 @@ #ifndef _HOSTAPD_H #define _HOSTAPD_H -#include <sys/param.h> #include <sys/types.h> #include <sys/socket.h> #include <sys/tree.h> @@ -344,7 +343,7 @@ struct hostapd_config { struct event c_priv_ev; - char c_config[MAXPATHLEN]; + char c_config[PATH_MAX]; u_int c_verbose; u_int c_debug; diff --git a/usr.sbin/hostapd/iapp.c b/usr.sbin/hostapd/iapp.c index 308fbd813cc..68222c77c35 100644 --- a/usr.sbin/hostapd/iapp.c +++ b/usr.sbin/hostapd/iapp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: iapp.c,v 1.18 2009/04/16 20:13:13 sobrado Exp $ */ +/* $OpenBSD: iapp.c,v 1.19 2015/01/16 06:40:17 deraadt Exp $ */ /* * Copyright (c) 2004, 2005 Reyk Floeter <reyk@openbsd.org> @@ -16,7 +16,6 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#include <sys/param.h> #include <sys/ioctl.h> #include <sys/types.h> #include <sys/socket.h> @@ -38,6 +37,7 @@ #include <stdlib.h> #include <string.h> #include <unistd.h> +#include <limits.h> #include "hostapd.h" #include "iapp.h" diff --git a/usr.sbin/hostapd/llc.c b/usr.sbin/hostapd/llc.c index 82dfb7d3031..c12043043d4 100644 --- a/usr.sbin/hostapd/llc.c +++ b/usr.sbin/hostapd/llc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: llc.c,v 1.5 2007/02/08 11:15:55 reyk Exp $ */ +/* $OpenBSD: llc.c,v 1.6 2015/01/16 06:40:17 deraadt Exp $ */ /* * Copyright (c) 2004, 2005 Reyk Floeter <reyk@openbsd.org> @@ -16,7 +16,6 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#include <sys/param.h> #include <sys/ioctl.h> #include <sys/types.h> #include <sys/socket.h> @@ -38,6 +37,7 @@ #include <stdlib.h> #include <string.h> #include <unistd.h> +#include <limits.h> #include "hostapd.h" diff --git a/usr.sbin/hostapd/parse.y b/usr.sbin/hostapd/parse.y index 8a5ad076754..1ffd4c2de09 100644 --- a/usr.sbin/hostapd/parse.y +++ b/usr.sbin/hostapd/parse.y @@ -1,4 +1,4 @@ -/* $OpenBSD: parse.y,v 1.48 2014/11/20 05:51:20 jsg Exp $ */ +/* $OpenBSD: parse.y,v 1.49 2015/01/16 06:40:17 deraadt Exp $ */ /* * Copyright (c) 2004, 2005, 2006 Reyk Floeter <reyk@openbsd.org> @@ -21,7 +21,6 @@ */ %{ -#include <sys/param.h> #include <sys/ioctl.h> #include <sys/types.h> #include <sys/socket.h> @@ -52,6 +51,7 @@ #include <stdarg.h> #include <string.h> #include <unistd.h> +#include <limits.h> #include <stdint.h> #include <err.h> diff --git a/usr.sbin/hostapd/print-802_11.c b/usr.sbin/hostapd/print-802_11.c index 1e50ce3210d..66c4ce14ca6 100644 --- a/usr.sbin/hostapd/print-802_11.c +++ b/usr.sbin/hostapd/print-802_11.c @@ -1,4 +1,4 @@ -/* $OpenBSD: print-802_11.c,v 1.6 2006/06/26 23:06:07 reyk Exp $ */ +/* $OpenBSD: print-802_11.c,v 1.7 2015/01/16 06:40:17 deraadt Exp $ */ /* * Copyright (c) 2005 Reyk Floeter <reyk@openbsd.org> @@ -18,7 +18,6 @@ /* usr.sbin/tcpdump/print-802_11.c,v 1.3 2005/03/09 11:43:17 deraadt Exp */ -#include <sys/param.h> #include <sys/time.h> #include <sys/socket.h> #include <sys/file.h> @@ -41,6 +40,7 @@ #include <pcap.h> #include <stdio.h> #include <string.h> +#include <limits.h> #include "hostapd.h" diff --git a/usr.sbin/hostapd/privsep.c b/usr.sbin/hostapd/privsep.c index 7b27131fc4e..c4675587e71 100644 --- a/usr.sbin/hostapd/privsep.c +++ b/usr.sbin/hostapd/privsep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: privsep.c,v 1.23 2007/05/02 09:09:29 claudio Exp $ */ +/* $OpenBSD: privsep.c,v 1.24 2015/01/16 06:40:17 deraadt Exp $ */ /* * Copyright (c) 2004, 2005 Reyk Floeter <reyk@openbsd.org> @@ -17,7 +17,6 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#include <sys/param.h> #include <sys/ioctl.h> #include <sys/types.h> #include <sys/socket.h> @@ -48,6 +47,7 @@ #include <stdlib.h> #include <string.h> #include <unistd.h> +#include <limits.h> #include "hostapd.h" #include "iapp.h" diff --git a/usr.sbin/hostapd/roaming.c b/usr.sbin/hostapd/roaming.c index e62bf4c3191..47ddec60096 100644 --- a/usr.sbin/hostapd/roaming.c +++ b/usr.sbin/hostapd/roaming.c @@ -1,4 +1,4 @@ -/* $OpenBSD: roaming.c,v 1.5 2010/05/26 19:18:10 millert Exp $ */ +/* $OpenBSD: roaming.c,v 1.6 2015/01/16 06:40:17 deraadt Exp $ */ /* * Copyright (c) 2005, 2006 Reyk Floeter <reyk@openbsd.org> @@ -16,7 +16,6 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#include <sys/param.h> #include <sys/types.h> #include <sys/socket.h> #include <sys/tree.h> @@ -39,6 +38,7 @@ #include <unistd.h> #include <fcntl.h> #include <errno.h> +#include <limits.h> #include "hostapd.h" diff --git a/usr.sbin/httpd/httpd.c b/usr.sbin/httpd/httpd.c index 491c2d4d385..c7d8f9ff16c 100644 --- a/usr.sbin/httpd/httpd.c +++ b/usr.sbin/httpd/httpd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: httpd.c,v 1.28 2014/12/11 17:06:55 schwarze Exp $ */ +/* $OpenBSD: httpd.c,v 1.29 2015/01/16 06:40:17 deraadt Exp $ */ /* * Copyright (c) 2014 Reyk Floeter <reyk@openbsd.org> @@ -16,12 +16,14 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#include <sys/param.h> /* nitems */ #include <sys/types.h> #include <sys/queue.h> #include <sys/socket.h> #include <sys/stat.h> #include <sys/wait.h> #include <sys/resource.h> +#include <sys/signal.h> #include <net/if.h> #include <netinet/in.h> @@ -42,6 +44,8 @@ #include "httpd.h" +#define MAXIMUM(a, b) (((a) > (b)) ? (a) : (b)) + __dead void usage(void); int parent_configure(struct httpd *); @@ -678,7 +682,7 @@ socket_rlimit(int maxfd) if (maxfd == -1) rl.rlim_cur = rl.rlim_max; else - rl.rlim_cur = MAX(rl.rlim_max, (rlim_t)maxfd); + rl.rlim_cur = MAXIMUM(rl.rlim_max, (rlim_t)maxfd); if (setrlimit(RLIMIT_NOFILE, &rl) == -1) fatal("socket_rlimit: failed to set resource limit"); } diff --git a/usr.sbin/httpd/httpd.h b/usr.sbin/httpd/httpd.h index 3a8c7cafd9a..a6f470658b7 100644 --- a/usr.sbin/httpd/httpd.h +++ b/usr.sbin/httpd/httpd.h @@ -1,4 +1,4 @@ -/* $OpenBSD: httpd.h,v 1.67 2015/01/13 09:21:15 reyk Exp $ */ +/* $OpenBSD: httpd.h,v 1.68 2015/01/16 06:40:17 deraadt Exp $ */ /* * Copyright (c) 2006 - 2015 Reyk Floeter <reyk@openbsd.org> @@ -23,7 +23,6 @@ #include <sys/tree.h> -#include <sys/param.h> /* MAXHOSTNAMELEN */ #include <limits.h> #include <imsg.h> #include <tls.h> @@ -361,11 +360,11 @@ TAILQ_HEAD(log_files, log_file) log_files; struct server_config { u_int32_t id; - char name[MAXHOSTNAMELEN]; + char name[HOST_NAME_MAX+1]; char location[NAME_MAX]; char index[NAME_MAX]; - char root[MAXPATHLEN]; - char socket[MAXPATHLEN]; + char root[PATH_MAX]; + char socket[PATH_MAX]; char accesslog[NAME_MAX]; char errorlog[NAME_MAX]; diff --git a/usr.sbin/httpd/logger.c b/usr.sbin/httpd/logger.c index 672f3b820c1..ee215851f59 100644 --- a/usr.sbin/httpd/logger.c +++ b/usr.sbin/httpd/logger.c @@ -1,4 +1,4 @@ -/* $OpenBSD: logger.c,v 1.8 2014/12/21 00:54:49 guenther Exp $ */ +/* $OpenBSD: logger.c,v 1.9 2015/01/16 06:40:17 deraadt Exp $ */ /* * Copyright (c) 2014 Reyk Floeter <reyk@openbsd.org> @@ -16,6 +16,7 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#include <sys/param.h> /* nitems */ #include <sys/types.h> #include <sys/socket.h> #include <sys/queue.h> @@ -152,7 +153,7 @@ logger_open_fd(struct imsg *imsg) int logger_open_priv(struct imsg *imsg) { - char path[MAXPATHLEN]; + char path[PATH_MAX]; char name[NAME_MAX], *p; u_int32_t id; size_t len; diff --git a/usr.sbin/httpd/parse.y b/usr.sbin/httpd/parse.y index 5489738749b..f06927095a2 100644 --- a/usr.sbin/httpd/parse.y +++ b/usr.sbin/httpd/parse.y @@ -1,4 +1,4 @@ -/* $OpenBSD: parse.y,v 1.53 2015/01/13 09:21:15 reyk Exp $ */ +/* $OpenBSD: parse.y,v 1.54 2015/01/16 06:40:17 deraadt Exp $ */ /* * Copyright (c) 2007 - 2015 Reyk Floeter <reyk@openbsd.org> @@ -119,7 +119,7 @@ typedef struct { struct portrange port; struct { struct sockaddr_storage ss; - char name[MAXHOSTNAMELEN]; + char name[HOST_NAME_MAX+1]; } addr; } v; int lineno; diff --git a/usr.sbin/httpd/server.c b/usr.sbin/httpd/server.c index f4b6414c9fd..943e60af036 100644 --- a/usr.sbin/httpd/server.c +++ b/usr.sbin/httpd/server.c @@ -1,4 +1,4 @@ -/* $OpenBSD: server.c,v 1.51 2015/01/13 09:21:15 reyk Exp $ */ +/* $OpenBSD: server.c,v 1.52 2015/01/16 06:40:17 deraadt Exp $ */ /* * Copyright (c) 2006 - 2015 Reyk Floeter <reyk@openbsd.org> @@ -16,6 +16,7 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#include <sys/param.h> /* nitems */ #include <sys/types.h> #include <sys/queue.h> #include <sys/time.h> @@ -45,6 +46,8 @@ #include "httpd.h" +#define MINIMUM(a, b) (((a) < (b)) ? (a) : (b)) + int server_dispatch_parent(int, struct privsep_proc *, struct imsg *); int server_dispatch_logger(int, struct privsep_proc *, @@ -569,7 +572,7 @@ server_tls_readcb(int fd, short event, void *arg) } if (bufev->wm_read.high != 0) - howmuch = MIN(sizeof(rbuf), bufev->wm_read.high); + howmuch = MINIMUM(sizeof(rbuf), bufev->wm_read.high); ret = tls_read(clt->clt_tls_ctx, rbuf, howmuch, &len); if (ret == TLS_READ_AGAIN || ret == TLS_WRITE_AGAIN) { @@ -1025,7 +1028,7 @@ server_sendlog(struct server_config *srv_conf, int cmd, const char *emsg, ...) void server_log(struct client *clt, const char *msg) { - char ibuf[MAXHOSTNAMELEN], obuf[MAXHOSTNAMELEN]; + char ibuf[HOST_NAME_MAX+1], obuf[HOST_NAME_MAX+1]; struct server_config *srv_conf = clt->clt_srv_conf; char *ptr = NULL; int debug_cmd = -1; diff --git a/usr.sbin/httpd/server_fcgi.c b/usr.sbin/httpd/server_fcgi.c index 012e2eaaea8..d4135aa3925 100644 --- a/usr.sbin/httpd/server_fcgi.c +++ b/usr.sbin/httpd/server_fcgi.c @@ -1,4 +1,4 @@ -/* $OpenBSD: server_fcgi.c,v 1.45 2015/01/13 08:54:01 reyk Exp $ */ +/* $OpenBSD: server_fcgi.c,v 1.46 2015/01/16 06:40:17 deraadt Exp $ */ /* * Copyright (c) 2014 Florian Obser <florian@openbsd.org> @@ -97,7 +97,7 @@ server_fcgi(struct httpd *env, struct client *clt) struct http_descriptor *desc = clt->clt_descreq; struct fcgi_record_header *h; struct fcgi_begin_request_body *begin; - char hbuf[MAXHOSTNAMELEN]; + char hbuf[HOST_NAME_MAX+1]; size_t scriptlen; int pathlen; int fd = -1, ret; diff --git a/usr.sbin/httpd/server_file.c b/usr.sbin/httpd/server_file.c index e12644dd6f6..447a0ddd701 100644 --- a/usr.sbin/httpd/server_file.c +++ b/usr.sbin/httpd/server_file.c @@ -1,4 +1,4 @@ -/* $OpenBSD: server_file.c,v 1.46 2015/01/13 09:21:15 reyk Exp $ */ +/* $OpenBSD: server_file.c,v 1.47 2015/01/16 06:40:17 deraadt Exp $ */ /* * Copyright (c) 2006 - 2015 Reyk Floeter <reyk@openbsd.org> @@ -43,6 +43,9 @@ #include "httpd.h" #include "http.h" +#define MINIMUM(a, b) (((a) < (b)) ? (a) : (b)) +#define MAXIMUM(a, b) (((a) > (b)) ? (a) : (b)) + int server_file_access(struct httpd *, struct client *, char *, size_t); int server_file_request(struct httpd *, struct client *, char *, struct stat *); @@ -150,7 +153,7 @@ server_file(struct httpd *env, struct client *clt) { struct http_descriptor *desc = clt->clt_descreq; struct server_config *srv_conf = clt->clt_srv_conf; - char path[MAXPATHLEN]; + char path[PATH_MAX]; const char *stripped, *errstr = NULL; int ret = 500; @@ -221,7 +224,7 @@ server_file_request(struct httpd *env, struct client *clt, char *path, media = media_find(env->sc_mediatypes, path); ret = server_response_http(clt, 200, media, st->st_size, - MIN(time(NULL), st->st_mtim.tv_sec)); + MINIMUM(time(NULL), st->st_mtim.tv_sec)); switch (ret) { case -1: goto fail; @@ -270,7 +273,7 @@ server_file_request(struct httpd *env, struct client *clt, char *path, int server_file_index(struct httpd *env, struct client *clt, struct stat *st) { - char path[MAXPATHLEN]; + char path[PATH_MAX]; char tmstr[21]; struct http_descriptor *desc = clt->clt_descreq; struct server_config *srv_conf = clt->clt_srv_conf; @@ -299,7 +302,7 @@ server_file_index(struct httpd *env, struct client *clt, struct stat *st) goto abort; /* Save last modification time */ - dir_mtime = MIN(time(NULL), st->st_mtim.tv_sec); + dir_mtime = MINIMUM(time(NULL), st->st_mtim.tv_sec); if ((evb = evbuffer_new()) == NULL) goto abort; @@ -349,13 +352,13 @@ server_file_index(struct httpd *env, struct client *clt, struct stat *st) if (evbuffer_add_printf(evb, "<a href=\"%s\">%s/</a>%*s%s%20s\n", dp->d_name, dp->d_name, - MAX(namewidth, 0), " ", tmstr, "-") == -1) + MAXIMUM(namewidth, 0), " ", tmstr, "-") == -1) skip = 1; } else if (S_ISREG(st->st_mode)) { if (evbuffer_add_printf(evb, "<a href=\"%s\">%s</a>%*s%s%20llu\n", dp->d_name, dp->d_name, - MAX(namewidth, 0), " ", tmstr, st->st_size) == -1) + MAXIMUM(namewidth, 0), " ", tmstr, st->st_size) == -1) skip = 1; } free(dp); diff --git a/usr.sbin/httpd/server_http.c b/usr.sbin/httpd/server_http.c index 4e1d627e17f..c5dd4ab5650 100644 --- a/usr.sbin/httpd/server_http.c +++ b/usr.sbin/httpd/server_http.c @@ -1,4 +1,4 @@ -/* $OpenBSD: server_http.c,v 1.63 2015/01/13 09:21:15 reyk Exp $ */ +/* $OpenBSD: server_http.c,v 1.64 2015/01/16 06:40:17 deraadt Exp $ */ /* * Copyright (c) 2006 - 2015 Reyk Floeter <reyk@openbsd.org> @@ -34,6 +34,7 @@ #include <stdlib.h> #include <string.h> #include <unistd.h> +#include <limits.h> #include <stdio.h> #include <err.h> #include <pwd.h> @@ -571,7 +572,7 @@ server_http_time(time_t t, char *tmbuf, size_t len) const char * server_http_host(struct sockaddr_storage *ss, char *buf, size_t len) { - char hbuf[MAXHOSTNAMELEN]; + char hbuf[HOST_NAME_MAX+1]; in_port_t port; if (print_host(ss, buf, len) == NULL) @@ -768,8 +769,8 @@ server_close_http(struct client *clt) int server_response(struct httpd *httpd, struct client *clt) { - char path[MAXPATHLEN]; - char hostname[MAXHOSTNAMELEN]; + char path[PATH_MAX]; + char hostname[HOST_NAME_MAX+1]; struct http_descriptor *desc = clt->clt_descreq; struct http_descriptor *resp = clt->clt_descresp; struct server *srv = clt->clt_srv; diff --git a/usr.sbin/identd/identd.c b/usr.sbin/identd/identd.c index 7dc119a5b40..cd11699bf9a 100644 --- a/usr.sbin/identd/identd.c +++ b/usr.sbin/identd/identd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: identd.c,v 1.26 2014/07/13 17:53:41 claudio Exp $ */ +/* $OpenBSD: identd.c,v 1.27 2015/01/16 06:40:17 deraadt Exp $ */ /* * Copyright (c) 2013 David Gwynne <dlg@openbsd.org> @@ -38,6 +38,7 @@ #include <fcntl.h> #include <pwd.h> #include <stdio.h> +#include <limits.h> #include <stdlib.h> #include <string.h> #include <syslog.h> @@ -436,7 +437,7 @@ parent_token(struct ident_resolver *r, struct passwd *pw) void parent_noident(struct ident_resolver *r, struct passwd *pw) { - char path[MAXPATHLEN]; + char path[PATH_MAX]; struct stat st; int rv; diff --git a/usr.sbin/ikectl/ikeca.c b/usr.sbin/ikectl/ikeca.c index dd18a208443..7e25f7fb609 100644 --- a/usr.sbin/ikectl/ikeca.c +++ b/usr.sbin/ikectl/ikeca.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ikeca.c,v 1.29 2014/08/26 17:47:24 jsing Exp $ */ +/* $OpenBSD: ikeca.c,v 1.30 2015/01/16 06:40:17 deraadt Exp $ */ /* * Copyright (c) 2010 Jonathan Gray <jsg@openbsd.org> @@ -16,7 +16,6 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#include <sys/param.h> #include <sys/types.h> #include <sys/stat.h> #include <stdio.h> @@ -29,6 +28,7 @@ #include <fcntl.h> #include <fts.h> #include <dirent.h> +#include <limits.h> #include <openssl/rand.h> #include <openssl/rsa.h> @@ -189,7 +189,7 @@ int ca_sign(struct ca *ca, char *keyname, int type, char *envargs) { char cmd[PATH_MAX * 2]; - char hostname[MAXHOSTNAMELEN]; + char hostname[HOST_NAME_MAX+1]; char name[128]; strlcpy(name, keyname, sizeof(name)); diff --git a/usr.sbin/ikectl/ikectl.c b/usr.sbin/ikectl/ikectl.c index 1c5a04eef91..5e85ab8859c 100644 --- a/usr.sbin/ikectl/ikectl.c +++ b/usr.sbin/ikectl/ikectl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ikectl.c,v 1.18 2013/11/14 20:48:52 deraadt Exp $ */ +/* $OpenBSD: ikectl.c,v 1.19 2015/01/16 06:40:17 deraadt Exp $ */ /* * Copyright (c) 2007-2013 Reyk Floeter <reyk@openbsd.org> @@ -19,7 +19,6 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#include <sys/param.h> #include <sys/types.h> #include <sys/socket.h> #include <sys/queue.h> diff --git a/usr.sbin/ikectl/parser.c b/usr.sbin/ikectl/parser.c index 4ee5bb26fa7..6c21436ac31 100644 --- a/usr.sbin/ikectl/parser.c +++ b/usr.sbin/ikectl/parser.c @@ -1,4 +1,4 @@ -/* $OpenBSD: parser.c,v 1.12 2013/01/08 10:38:19 reyk Exp $ */ +/* $OpenBSD: parser.c,v 1.13 2015/01/16 06:40:17 deraadt Exp $ */ /* * Copyright (c) 2010-2013 Reyk Floeter <reyk@openbsd.org> @@ -18,7 +18,6 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#include <sys/param.h> #include <sys/types.h> #include <sys/socket.h> #include <sys/queue.h> diff --git a/usr.sbin/inetd/inetd.c b/usr.sbin/inetd/inetd.c index d74e11554a3..85661194cc7 100644 --- a/usr.sbin/inetd/inetd.c +++ b/usr.sbin/inetd/inetd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: inetd.c,v 1.142 2014/10/29 03:33:14 dlg Exp $ */ +/* $OpenBSD: inetd.c,v 1.143 2015/01/16 06:40:17 deraadt Exp $ */ /* * Copyright (c) 1983,1991 The Regents of the University of California. @@ -121,7 +121,6 @@ * */ -#include <sys/param.h> #include <sys/stat.h> #include <sys/ioctl.h> #include <sys/socket.h> @@ -145,6 +144,7 @@ #include <stdio.h> #include <stdlib.h> #include <unistd.h> +#include <limits.h> #include <string.h> #include <login_cap.h> #include <ifaddrs.h> @@ -154,6 +154,8 @@ #include <event.h> #include "pathnames.h" +#define MINIMUM(a, b) (((a) < (b)) ? (a) : (b)) + #define TOOMANY 256 /* don't start more than TOOMANY */ #define CNT_INTVL 60 /* servers in CNT_INTVL sec. */ #define RETRYTIME (60*10) /* retry after bind or server fail */ @@ -1428,8 +1430,8 @@ bump_nofile(void) syslog(LOG_ERR, "getrlimit: %m"); return -1; } - rl.rlim_cur = MIN(rl.rlim_max, rl.rlim_cur + FD_CHUNK); - rl.rlim_cur = MIN(FD_SETSIZE, rl.rlim_cur + FD_CHUNK); + rl.rlim_cur = MINIMUM(rl.rlim_max, rl.rlim_cur + FD_CHUNK); + rl.rlim_cur = MINIMUM(FD_SETSIZE, rl.rlim_cur + FD_CHUNK); if (rl.rlim_cur <= rlim_nofile_cur) { syslog(LOG_ERR, "bump_nofile: cannot extend file limit, max = %d", diff --git a/usr.sbin/iscsictl/iscsictl.c b/usr.sbin/iscsictl/iscsictl.c index 5e1aea8ea4c..cb981131fad 100644 --- a/usr.sbin/iscsictl/iscsictl.c +++ b/usr.sbin/iscsictl/iscsictl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: iscsictl.c,v 1.8 2014/04/21 20:20:37 claudio Exp $ */ +/* $OpenBSD: iscsictl.c,v 1.9 2015/01/16 06:40:17 deraadt Exp $ */ /* * Copyright (c) 2010 Claudio Jeker <claudio@openbsd.org> @@ -16,8 +16,7 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#include <sys/types.h> -#include <sys/param.h> +#include <sys/param.h> /* nitems */ #include <sys/queue.h> #include <sys/socket.h> #include <sys/uio.h> diff --git a/usr.sbin/kgmon/kgmon.c b/usr.sbin/kgmon/kgmon.c index 91505950cdf..87cbf116217 100644 --- a/usr.sbin/kgmon/kgmon.c +++ b/usr.sbin/kgmon/kgmon.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kgmon.c,v 1.20 2013/11/27 13:32:02 okan Exp $ */ +/* $OpenBSD: kgmon.c,v 1.21 2015/01/16 06:40:17 deraadt Exp $ */ /* * Copyright (c) 1983, 1992, 1993 @@ -29,7 +29,6 @@ * SUCH DAMAGE. */ -#include <sys/param.h> #include <sys/file.h> #include <sys/sysctl.h> #include <sys/gmon.h> diff --git a/usr.sbin/kvm_mkdb/kvm_mkdb.c b/usr.sbin/kvm_mkdb/kvm_mkdb.c index 6223ae6d2d1..2ab71c0a749 100644 --- a/usr.sbin/kvm_mkdb/kvm_mkdb.c +++ b/usr.sbin/kvm_mkdb/kvm_mkdb.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kvm_mkdb.c,v 1.19 2014/12/23 03:29:52 tedu Exp $ */ +/* $OpenBSD: kvm_mkdb.c,v 1.20 2015/01/16 06:40:17 deraadt Exp $ */ /*- * Copyright (c) 1990, 1993 @@ -29,7 +29,6 @@ * SUCH DAMAGE. */ -#include <sys/param.h> #include <sys/stat.h> #include <sys/types.h> #include <sys/time.h> @@ -67,7 +66,7 @@ main(int argc, char *argv[]) struct rlimit rl; int fd, rval, ch, verbose = 0; char *nlistpath, *nlistname; - char dbdir[MAXPATHLEN]; + char dbdir[PATH_MAX]; /* Increase our data size to the max if we can. */ if (getrlimit(RLIMIT_DATA, &rl) == 0) { @@ -129,7 +128,7 @@ kvm_mkdb(int fd, const char *dbdir, char *nlistpath, char *nlistname, int verbose) { DB *db; - char dbtemp[MAXPATHLEN], dbname[MAXPATHLEN]; + char dbtemp[PATH_MAX], dbname[PATH_MAX]; int r; struct group *gr; diff --git a/usr.sbin/kvm_mkdb/nlist.c b/usr.sbin/kvm_mkdb/nlist.c index 1de7eb7ce7c..841bab91902 100644 --- a/usr.sbin/kvm_mkdb/nlist.c +++ b/usr.sbin/kvm_mkdb/nlist.c @@ -1,4 +1,4 @@ -/* $OpenBSD: nlist.c,v 1.45 2014/05/20 01:25:24 guenther Exp $ */ +/* $OpenBSD: nlist.c,v 1.46 2015/01/16 06:40:17 deraadt Exp $ */ /*- * Copyright (c) 1990, 1993 @@ -29,7 +29,7 @@ * SUCH DAMAGE. */ -#include <sys/param.h> +#include <sys/types.h> #include <a.out.h> #include <db.h> diff --git a/usr.sbin/kvm_mkdb/testdb.c b/usr.sbin/kvm_mkdb/testdb.c index c4c52ac5188..a804634e61c 100644 --- a/usr.sbin/kvm_mkdb/testdb.c +++ b/usr.sbin/kvm_mkdb/testdb.c @@ -1,4 +1,4 @@ -/* $OpenBSD: testdb.c,v 1.8 2009/10/27 23:59:51 deraadt Exp $ */ +/* $OpenBSD: testdb.c,v 1.9 2015/01/16 06:40:17 deraadt Exp $ */ /*- * Copyright (c) 1992, 1993 @@ -29,7 +29,7 @@ * SUCH DAMAGE. */ -#include <sys/param.h> +#include <sys/types.h> #include <sys/sysctl.h> #include <db.h> diff --git a/usr.sbin/ldpd/kroute.c b/usr.sbin/ldpd/kroute.c index e55a03f15fb..8ae9ad4fde9 100644 --- a/usr.sbin/ldpd/kroute.c +++ b/usr.sbin/ldpd/kroute.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kroute.c,v 1.33 2014/06/23 03:46:17 guenther Exp $ */ +/* $OpenBSD: kroute.c,v 1.34 2015/01/16 06:40:17 deraadt Exp $ */ /* * Copyright (c) 2009 Michele Marchetto <michele@openbsd.org> @@ -18,7 +18,6 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#include <sys/param.h> #include <sys/types.h> #include <sys/socket.h> #include <sys/sysctl.h> @@ -38,6 +37,7 @@ #include <stdlib.h> #include <string.h> #include <unistd.h> +#include <limits.h> #include "ldpd.h" #include "log.h" diff --git a/usr.sbin/ldpd/ldpd.c b/usr.sbin/ldpd/ldpd.c index 621ff71d7a6..847c782d99a 100644 --- a/usr.sbin/ldpd/ldpd.c +++ b/usr.sbin/ldpd/ldpd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ldpd.c,v 1.20 2014/07/12 20:16:38 krw Exp $ */ +/* $OpenBSD: ldpd.c,v 1.21 2015/01/16 06:40:17 deraadt Exp $ */ /* * Copyright (c) 2005 Claudio Jeker <claudio@openbsd.org> @@ -24,7 +24,6 @@ #include <sys/time.h> #include <sys/stat.h> #include <sys/wait.h> -#include <sys/param.h> #include <netinet/in.h> #include <arpa/inet.h> diff --git a/usr.sbin/lpr/common_source/common.c b/usr.sbin/lpr/common_source/common.c index fd48614df1c..e2d4a063545 100644 --- a/usr.sbin/lpr/common_source/common.c +++ b/usr.sbin/lpr/common_source/common.c @@ -1,4 +1,4 @@ -/* $OpenBSD: common.c,v 1.37 2014/11/02 13:56:55 deraadt Exp $ */ +/* $OpenBSD: common.c,v 1.38 2015/01/16 06:40:17 deraadt Exp $ */ /* $NetBSD: common.c,v 1.21 2000/08/09 14:28:50 itojun Exp $ */ /* @@ -35,7 +35,6 @@ * SUCH DAMAGE. */ -#include <sys/param.h> #include <sys/stat.h> #include <sys/time.h> @@ -48,6 +47,7 @@ #include <errno.h> #include <fcntl.h> #include <unistd.h> +#include <limits.h> #include <stdlib.h> #include <stdio.h> #include <string.h> diff --git a/usr.sbin/lpr/common_source/common_vars.c b/usr.sbin/lpr/common_source/common_vars.c index a7cdb5fb494..372e7bae96b 100644 --- a/usr.sbin/lpr/common_source/common_vars.c +++ b/usr.sbin/lpr/common_source/common_vars.c @@ -1,4 +1,4 @@ -/* $OpenBSD: common_vars.c,v 1.4 2009/10/27 23:59:51 deraadt Exp $ */ +/* $OpenBSD: common_vars.c,v 1.5 2015/01/16 06:40:17 deraadt Exp $ */ /* $NetBSD: common.c,v 1.15 1999/09/26 10:32:27 mrg Exp $ */ /* @@ -35,13 +35,14 @@ * SUCH DAMAGE. */ -#include <sys/param.h> +#include <sys/types.h> +#include <limits.h> #include "pathnames.h" char *name; /* program name */ char *printer; /* printer name */ -char host[MAXHOSTNAMELEN+1]; /* host machine name */ +char host[HOST_NAME_MAX+1 + 1]; /* host machine name */ char *from = host; /* client's machine name */ char *printcapdb[2] = { _PATH_PRINTCAP, 0 }; char *bp; /* pointer into printcap buffer. */ diff --git a/usr.sbin/lpr/common_source/displayq.c b/usr.sbin/lpr/common_source/displayq.c index 5f3301e785b..0d401b7a7b5 100644 --- a/usr.sbin/lpr/common_source/displayq.c +++ b/usr.sbin/lpr/common_source/displayq.c @@ -1,4 +1,4 @@ -/* $OpenBSD: displayq.c,v 1.35 2014/05/21 18:38:42 pascal Exp $ */ +/* $OpenBSD: displayq.c,v 1.36 2015/01/16 06:40:17 deraadt Exp $ */ /* $NetBSD: displayq.c,v 1.21 2001/08/30 00:51:50 itojun Exp $ */ /* @@ -30,7 +30,6 @@ * SUCH DAMAGE. */ -#include <sys/param.h> #include <sys/file.h> #include <sys/ioctl.h> #include <sys/stat.h> @@ -39,6 +38,7 @@ #include <errno.h> #include <dirent.h> #include <fcntl.h> +#include <limits.h> #include <signal.h> #include <stdio.h> #include <stdlib.h> diff --git a/usr.sbin/lpr/common_source/lp.h b/usr.sbin/lpr/common_source/lp.h index 1c3307daba0..d1c997fd2e9 100644 --- a/usr.sbin/lpr/common_source/lp.h +++ b/usr.sbin/lpr/common_source/lp.h @@ -1,4 +1,4 @@ -/* $OpenBSD: lp.h,v 1.18 2013/12/10 16:38:04 naddy Exp $ */ +/* $OpenBSD: lp.h,v 1.19 2015/01/16 06:40:17 deraadt Exp $ */ /* $NetBSD: lp.h,v 1.14 2000/04/16 14:43:58 mrg Exp $ */ /* @@ -78,7 +78,7 @@ extern char line[BUFSIZ]; extern char *bp; /* pointer into printcap buffer */ extern char *printer; /* printer name */ /* host machine name */ -extern char host[MAXHOSTNAMELEN]; +extern char host[HOST_NAME_MAX+1]; extern char *from; /* client's machine name */ extern int remote; /* true if sending files to a remote host */ extern char *printcapdb[]; /* printcap database array */ diff --git a/usr.sbin/lpr/common_source/rmjob.c b/usr.sbin/lpr/common_source/rmjob.c index f481a7aabf0..e58822aa349 100644 --- a/usr.sbin/lpr/common_source/rmjob.c +++ b/usr.sbin/lpr/common_source/rmjob.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rmjob.c,v 1.21 2013/11/24 21:32:32 deraadt Exp $ */ +/* $OpenBSD: rmjob.c,v 1.22 2015/01/16 06:40:17 deraadt Exp $ */ /* $NetBSD: rmjob.c,v 1.16 2000/04/16 14:43:58 mrg Exp $ */ /* @@ -30,13 +30,12 @@ * SUCH DAMAGE. */ -#include <sys/param.h> - #include <signal.h> #include <errno.h> #include <fcntl.h> #include <dirent.h> #include <unistd.h> +#include <limits.h> #include <stdlib.h> #include <stdio.h> #include <string.h> diff --git a/usr.sbin/lpr/common_source/startdaemon.c b/usr.sbin/lpr/common_source/startdaemon.c index 6274215387f..84988f3e3ed 100644 --- a/usr.sbin/lpr/common_source/startdaemon.c +++ b/usr.sbin/lpr/common_source/startdaemon.c @@ -1,4 +1,4 @@ -/* $OpenBSD: startdaemon.c,v 1.14 2014/07/20 01:38:40 guenther Exp $ */ +/* $OpenBSD: startdaemon.c,v 1.15 2015/01/16 06:40:17 deraadt Exp $ */ /* $NetBSD: startdaemon.c,v 1.10 1998/07/18 05:04:39 lukem Exp $ */ /* @@ -30,7 +30,6 @@ * SUCH DAMAGE. */ -#include <sys/param.h> #include <sys/socket.h> #include <sys/un.h> @@ -39,6 +38,7 @@ #include <errno.h> #include <stdio.h> #include <unistd.h> +#include <limits.h> #include <string.h> #include <signal.h> diff --git a/usr.sbin/lpr/lpc/cmds.c b/usr.sbin/lpr/lpc/cmds.c index bd73855b824..d27788c9429 100644 --- a/usr.sbin/lpr/lpc/cmds.c +++ b/usr.sbin/lpr/lpc/cmds.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmds.c,v 1.26 2013/12/29 14:26:22 krw Exp $ */ +/* $OpenBSD: cmds.c,v 1.27 2015/01/16 06:40:18 deraadt Exp $ */ /* $NetBSD: cmds.c,v 1.12 1997/10/05 15:12:06 mrg Exp $ */ /* @@ -35,7 +35,6 @@ * lpc -- line printer control program -- commands: */ -#include <sys/param.h> #include <sys/time.h> #include <sys/stat.h> #include <sys/file.h> @@ -45,6 +44,7 @@ #include <errno.h> #include <dirent.h> #include <unistd.h> +#include <limits.h> #include <stdlib.h> #include <stdio.h> #include <ctype.h> @@ -189,7 +189,7 @@ static void upstat(char *msg) { int fd; - char statfile[MAXPATHLEN]; + char statfile[PATH_MAX]; if (cgetstr(bp, "st", &ST) == -1) ST = DEFSTAT; diff --git a/usr.sbin/lpr/lpc/lpc.c b/usr.sbin/lpr/lpc/lpc.c index 833a3369479..2661119f60d 100644 --- a/usr.sbin/lpr/lpc/lpc.c +++ b/usr.sbin/lpr/lpc/lpc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: lpc.c,v 1.18 2009/10/27 23:59:52 deraadt Exp $ */ +/* $OpenBSD: lpc.c,v 1.19 2015/01/16 06:40:18 deraadt Exp $ */ /* $NetBSD: lpc.c,v 1.11 2001/11/14 03:01:15 enami Exp $ */ /* @@ -31,8 +31,6 @@ * SUCH DAMAGE. */ -#include <sys/param.h> - #include <dirent.h> #include <signal.h> #include <syslog.h> @@ -41,6 +39,7 @@ #include <stdio.h> #include <err.h> #include <errno.h> +#include <limits.h> #include <ctype.h> #include <string.h> #include <grp.h> @@ -278,7 +277,7 @@ static int ingroup(char *grname) { static struct group *gptr = NULL; - static gid_t groups[NGROUPS]; + static gid_t groups[NGROUPS_MAX]; static int ngroups; gid_t gid; int i; @@ -288,7 +287,7 @@ ingroup(char *grname) warnx("Warning: unknown group `%s'", grname); return(0); } - if ((ngroups = getgroups(NGROUPS, groups)) < 0) + if ((ngroups = getgroups(NGROUPS_MAX, groups)) < 0) err(1, "getgroups"); } gid = gptr->gr_gid; diff --git a/usr.sbin/lpr/lpd/key.c b/usr.sbin/lpr/lpd/key.c index be14b708fe7..a065494e44f 100644 --- a/usr.sbin/lpr/lpd/key.c +++ b/usr.sbin/lpr/lpd/key.c @@ -1,4 +1,4 @@ -/* $OpenBSD: key.c,v 1.7 2009/10/27 23:59:52 deraadt Exp $ */ +/* $OpenBSD: key.c,v 1.8 2015/01/16 06:40:18 deraadt Exp $ */ /* $NetBSD: key.c,v 1.3 1997/10/20 08:08:28 scottr Exp $ */ /*- @@ -30,15 +30,16 @@ * SUCH DAMAGE. */ -#include <sys/param.h> #include <sys/types.h> #include <errno.h> +#include <signal.h> #include <stdlib.h> #include <stdio.h> #include <string.h> #include <syslog.h> #include <dirent.h> +#include <limits.h> #include <termios.h> #include "lp.h" diff --git a/usr.sbin/lpr/lpd/lpd.c b/usr.sbin/lpr/lpd/lpd.c index f6721e6990d..38b37e96c3f 100644 --- a/usr.sbin/lpr/lpd/lpd.c +++ b/usr.sbin/lpr/lpd/lpd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: lpd.c,v 1.56 2014/10/17 06:11:27 deraadt Exp $ */ +/* $OpenBSD: lpd.c,v 1.57 2015/01/16 06:40:18 deraadt Exp $ */ /* $NetBSD: lpd.c,v 1.33 2002/01/21 14:42:29 wiz Exp $ */ /* @@ -63,7 +63,6 @@ * Users can't touch the spool w/o the help of one of the lp* programs. */ -#include <sys/param.h> #include <sys/wait.h> #include <sys/types.h> #include <sys/socket.h> @@ -86,6 +85,7 @@ #include <string.h> #include <syslog.h> #include <unistd.h> +#include <limits.h> #include "lp.h" #include "lp.local.h" diff --git a/usr.sbin/lpr/lpd/modes.c b/usr.sbin/lpr/lpd/modes.c index b59fda51ad7..b62b18c0d0b 100644 --- a/usr.sbin/lpr/lpd/modes.c +++ b/usr.sbin/lpr/lpd/modes.c @@ -1,4 +1,4 @@ -/* $OpenBSD: modes.c,v 1.7 2009/10/27 23:59:52 deraadt Exp $ */ +/* $OpenBSD: modes.c,v 1.8 2015/01/16 06:40:18 deraadt Exp $ */ /* $NetBSD: modes.c,v 1.3 1997/10/20 08:08:31 scottr Exp $ */ /*- @@ -30,7 +30,6 @@ * SUCH DAMAGE. */ -#include <sys/param.h> #include <sys/types.h> #include <stddef.h> #include <string.h> diff --git a/usr.sbin/lpr/lpd/printjob.c b/usr.sbin/lpr/lpd/printjob.c index 226f299b458..5445a50ad6b 100644 --- a/usr.sbin/lpr/lpd/printjob.c +++ b/usr.sbin/lpr/lpd/printjob.c @@ -1,4 +1,4 @@ -/* $OpenBSD: printjob.c,v 1.53 2014/12/16 03:35:49 millert Exp $ */ +/* $OpenBSD: printjob.c,v 1.54 2015/01/16 06:40:18 deraadt Exp $ */ /* $NetBSD: printjob.c,v 1.31 2002/01/21 14:42:30 wiz Exp $ */ /* @@ -38,7 +38,6 @@ * it does not need to be removed because file locks are dynamic. */ -#include <sys/param.h> #include <sys/wait.h> #include <sys/stat.h> #include <sys/types.h> @@ -54,6 +53,7 @@ #include <errno.h> #include <stdio.h> #include <string.h> +#include <limits.h> #include <stdlib.h> #include <stdarg.h> #include <ctype.h> @@ -91,12 +91,12 @@ static char title[80]; /* ``pr'' title */ static int tof; /* true if at top of form */ static char class[32]; /* classification field */ -static char fromhost[MAXHOSTNAMELEN]; /* user's host machine */ +static char fromhost[HOST_NAME_MAX+1]; /* user's host machine */ /* indentation size in static characters */ static char indent[10] = "-i0"; static char jobname[NAME_MAX]; /* job or file name */ static char length[10] = "-l"; /* page length in lines */ -static char logname[MAXLOGNAME]; /* user's login name */ +static char logname[LOGIN_NAME_MAX];/* user's login name */ static char pxlength[10] = "-y"; /* page length in pixels */ static char pxwidth[10] = "-x"; /* page width in pixels */ static char tempfile[] = "errsXXXXXXXXXX"; /* file name for filter output */ diff --git a/usr.sbin/lpr/lpd/recvjob.c b/usr.sbin/lpr/lpd/recvjob.c index 5ab57f223d2..787da15b308 100644 --- a/usr.sbin/lpr/lpd/recvjob.c +++ b/usr.sbin/lpr/lpd/recvjob.c @@ -1,4 +1,4 @@ -/* $OpenBSD: recvjob.c,v 1.25 2009/10/27 23:59:52 deraadt Exp $ */ +/* $OpenBSD: recvjob.c,v 1.26 2015/01/16 06:40:18 deraadt Exp $ */ /* $NetBSD: recvjob.c,v 1.14 2001/12/04 22:52:44 christos Exp $ */ /* @@ -35,7 +35,7 @@ * Receive printer jobs from the network, queue them and * start the printer daemon. */ -#include <sys/param.h> +#include <sys/types.h> #include <sys/mount.h> #include <sys/stat.h> @@ -49,6 +49,7 @@ #include <stdlib.h> #include <string.h> #include <stdarg.h> +#include <limits.h> #include "lp.h" #include "lp.local.h" #include "extern.h" diff --git a/usr.sbin/lpr/lpq/lpq.c b/usr.sbin/lpr/lpq/lpq.c index 934ec081ef1..6947dfb7fe2 100644 --- a/usr.sbin/lpr/lpq/lpq.c +++ b/usr.sbin/lpr/lpq/lpq.c @@ -1,4 +1,4 @@ -/* $OpenBSD: lpq.c,v 1.20 2013/11/24 21:32:32 deraadt Exp $ */ +/* $OpenBSD: lpq.c,v 1.21 2015/01/16 06:40:18 deraadt Exp $ */ /* $NetBSD: lpq.c,v 1.9 1999/12/07 14:54:47 mrg Exp $ */ /* @@ -41,15 +41,16 @@ * -P used to identify printer as per lpr/lprm */ -#include <sys/param.h> #include <ctype.h> +#include <signal.h> #include <dirent.h> #include <err.h> #include <errno.h> #include <unistd.h> #include <stdlib.h> #include <stdio.h> +#include <limits.h> #include <syslog.h> #include "lp.h" diff --git a/usr.sbin/lpr/lpr/lpr.c b/usr.sbin/lpr/lpr/lpr.c index dc13643acd6..5027435df47 100644 --- a/usr.sbin/lpr/lpr/lpr.c +++ b/usr.sbin/lpr/lpr/lpr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: lpr.c,v 1.46 2014/05/20 01:25:24 guenther Exp $ */ +/* $OpenBSD: lpr.c,v 1.47 2015/01/16 06:40:18 deraadt Exp $ */ /* $NetBSD: lpr.c,v 1.19 2000/10/11 20:23:52 is Exp $ */ /* @@ -43,7 +43,6 @@ * using information from a printer data base. */ -#include <sys/param.h> #include <sys/stat.h> #include <sys/file.h> @@ -55,6 +54,7 @@ #include <pwd.h> #include <grp.h> #include <unistd.h> +#include <limits.h> #include <stdlib.h> #include <stdio.h> #include <ctype.h> @@ -109,7 +109,7 @@ main(int argc, char **argv) struct passwd *pw; struct group *gptr; char *arg, *cp; - char buf[MAXPATHLEN]; + char buf[PATH_MAX]; int i, f, ch; struct stat stb; @@ -439,7 +439,7 @@ static char * linked(char *file) { char *cp; - static char buf[MAXPATHLEN]; + static char buf[PATH_MAX]; int ret; if (*file != '/') { diff --git a/usr.sbin/lpr/lprm/lprm.c b/usr.sbin/lpr/lprm/lprm.c index d29af91e6f7..0fa579e936b 100644 --- a/usr.sbin/lpr/lprm/lprm.c +++ b/usr.sbin/lpr/lprm/lprm.c @@ -1,4 +1,4 @@ -/* $OpenBSD: lprm.c,v 1.20 2014/01/22 19:31:00 tobias Exp $ */ +/* $OpenBSD: lprm.c,v 1.21 2015/01/16 06:40:18 deraadt Exp $ */ /* $$NetBSD: lprm.c,v 1.9 1999/08/16 03:12:32 simonb Exp $ */ /* @@ -42,9 +42,9 @@ * entries, otherwise one can only remove their own. */ -#include <sys/param.h> #include <ctype.h> +#include <signal.h> #include <dirent.h> #include <err.h> #include <errno.h> @@ -54,6 +54,7 @@ #include <string.h> #include <syslog.h> #include <unistd.h> +#include <limits.h> #include "lp.h" #include "lp.local.h" @@ -67,7 +68,7 @@ int requests; /* # of spool requests */ char *user[MAXUSERS]; /* users to process */ int users; /* # of users in user array */ volatile sig_atomic_t gotintr; /* set when we receive SIGINT */ -static char luser[MAXLOGNAME]; /* buffer for person */ +static char luser[LOGIN_NAME_MAX]; /* buffer for person */ static __dead void usage(void); diff --git a/usr.sbin/map-mbone/mapper.c b/usr.sbin/map-mbone/mapper.c index e4fe726e699..dc71c059a14 100644 --- a/usr.sbin/map-mbone/mapper.c +++ b/usr.sbin/map-mbone/mapper.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mapper.c,v 1.21 2014/11/26 18:34:51 millert Exp $ */ +/* $OpenBSD: mapper.c,v 1.22 2015/01/16 06:40:18 deraadt Exp $ */ /* $NetBSD: mapper.c,v 1.3 1995/12/10 11:12:04 mycroft Exp $ */ /* Mapper for connections between MRouteD multicast routers. @@ -42,6 +42,7 @@ #include <arpa/inet.h> #include <stdarg.h> #include <poll.h> +#include <limits.h> #include <err.h> #define DEFAULT_TIMEOUT 2 /* How long to wait before retrying requests */ @@ -689,7 +690,7 @@ void graph_edges(Node *node) { Interface *ifc; Neighbor *nb; - char name[MAXHOSTNAMELEN]; + char name[HOST_NAME_MAX+1]; if (node) { graph_edges(node->left); @@ -872,9 +873,7 @@ int main(int argc, char *argv[]) memset(&addr, 0, sizeof addr); addr.sin_family = AF_INET; -#if (defined(BSD) && (BSD >= 199103)) addr.sin_len = sizeof addr; -#endif addr.sin_addr.s_addr = dvmrp_group; addr.sin_port = htons(2000); /* any port over 1024 will do... */ if ((udp = socket(AF_INET, SOCK_DGRAM, 0)) < 0 diff --git a/usr.sbin/mrinfo/mrinfo.c b/usr.sbin/mrinfo/mrinfo.c index 72da4b033f6..55de2f0c8bc 100644 --- a/usr.sbin/mrinfo/mrinfo.c +++ b/usr.sbin/mrinfo/mrinfo.c @@ -81,6 +81,7 @@ #include <arpa/inet.h> #include <stdarg.h> #include <poll.h> +#include <limits.h> #include <err.h> #define DEFAULT_TIMEOUT 4 /* How long to wait before retrying requests */ @@ -370,9 +371,7 @@ main(int argc, char *argv[]) addrlen = sizeof(addr); memset(&addr, 0, sizeof addr); addr.sin_family = AF_INET; -#if (defined(BSD) && (BSD >= 199103)) addr.sin_len = sizeof addr; -#endif addr.sin_addr.s_addr = target_addr; addr.sin_port = htons(2000); /* any port over 1024 will * do... */ diff --git a/usr.sbin/mrouted/defs.h b/usr.sbin/mrouted/defs.h index 2fb2ea62f83..f4d3a6acc66 100644 --- a/usr.sbin/mrouted/defs.h +++ b/usr.sbin/mrouted/defs.h @@ -18,7 +18,6 @@ #include <syslog.h> #include <signal.h> #include <string.h> -#include <sys/param.h> #include <sys/types.h> #include <sys/socket.h> #include <sys/ioctl.h> @@ -127,12 +126,6 @@ extern char s2[]; extern char s3[]; extern char s4[]; -#if !(defined(BSD) && (BSD >= 199103)) -extern int errno; -extern int sys_nerr; -extern char * sys_errlist[]; -#endif - #ifdef OLD_KERNEL #define MRT_INIT DVMRP_INIT #define MRT_DONE DVMRP_DONE diff --git a/usr.sbin/mrouted/igmp.c b/usr.sbin/mrouted/igmp.c index f32df762bb4..46a652e6c5f 100644 --- a/usr.sbin/mrouted/igmp.c +++ b/usr.sbin/mrouted/igmp.c @@ -328,9 +328,7 @@ send_igmp(u_int32_t src, u_int32_t dst, int type, int code, bzero(&sdst, sizeof(sdst)); sdst.sin_family = AF_INET; -#if (defined(BSD) && (BSD >= 199103)) sdst.sin_len = sizeof(sdst); -#endif sdst.sin_addr.s_addr = dst; if (sendto(igmp_socket, send_buf, ntohs(ip->ip_len), 0, (struct sockaddr *)&sdst, sizeof(sdst)) < 0) { diff --git a/usr.sbin/mrouted/pathnames.h b/usr.sbin/mrouted/pathnames.h index 1bdcfdcd9fe..c1021c7b541 100644 --- a/usr.sbin/mrouted/pathnames.h +++ b/usr.sbin/mrouted/pathnames.h @@ -11,12 +11,6 @@ #define _PATH_MROUTED_CONF "/etc/mrouted.conf" -#if (defined(BSD) && (BSD >= 199103)) #define _PATH_MROUTED_GENID "/var/run/mrouted.genid" #define _PATH_MROUTED_DUMP "/var/tmp/mrouted.dump" #define _PATH_MROUTED_CACHE "/var/tmp/mrouted.cache" -#else -#define _PATH_MROUTED_GENID "/etc/mrouted.genid" -#define _PATH_MROUTED_DUMP "/usr/tmp/mrouted.dump" -#define _PATH_MROUTED_CACHE "/usr/tmp/mrouted.cache" -#endif diff --git a/usr.sbin/mrouted/rsrr.c b/usr.sbin/mrouted/rsrr.c index 317b1f1c673..252cdea2fea 100644 --- a/usr.sbin/mrouted/rsrr.c +++ b/usr.sbin/mrouted/rsrr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rsrr.c,v 1.12 2013/04/21 06:42:43 tedu Exp $ */ +/* $OpenBSD: rsrr.c,v 1.13 2015/01/16 06:40:18 deraadt Exp $ */ /* $NetBSD: rsrr.c,v 1.3 1995/12/10 10:07:14 mycroft Exp $ */ /* @@ -40,10 +40,7 @@ #ifdef RSRR #include "defs.h" -#include <sys/param.h> -#if (defined(BSD) && (BSD >= 199103)) #include <stddef.h> -#endif /* Taken from prune.c */ /* @@ -96,13 +93,9 @@ rsrr_init(void) bzero((char *) &serv_addr, sizeof(serv_addr)); serv_addr.sun_family = AF_UNIX; strlcpy(serv_addr.sun_path, RSRR_SERV_PATH, sizeof serv_addr.sun_path); -#if (defined(BSD) && (BSD >= 199103)) servlen = offsetof(struct sockaddr_un, sun_path) + strlen(serv_addr.sun_path); serv_addr.sun_len = servlen; -#else - servlen = sizeof(serv_addr.sun_family) + strlen(serv_addr.sun_path); -#endif if (bind(rsrr_socket, (struct sockaddr *) &serv_addr, servlen) < 0) logit(LOG_ERR, errno, "Can't bind RSRR socket"); diff --git a/usr.sbin/mrouted/vif.c b/usr.sbin/mrouted/vif.c index 7b7a540afc7..a427f427d56 100644 --- a/usr.sbin/mrouted/vif.c +++ b/usr.sbin/mrouted/vif.c @@ -699,9 +699,7 @@ accept_neighbor_request(u_int32_t src, u_int32_t dst) memset(&addr, 0, sizeof addr); addr.sin_family = AF_INET; -#if (defined(BSD) && (BSD >= 199103)) addr.sin_len = sizeof addr; -#endif addr.sin_addr.s_addr = dst; addr.sin_port = htons(2000); /* any port over 1024 will do... */ if ((udp = socket(AF_INET, SOCK_DGRAM, 0)) < 0 @@ -786,9 +784,7 @@ accept_neighbor_request2(u_int32_t src, u_int32_t dst) memset(&addr, 0, sizeof addr); addr.sin_family = AF_INET; -#if (defined(BSD) && (BSD >= 199103)) addr.sin_len = sizeof addr; -#endif addr.sin_addr.s_addr = dst; addr.sin_port = htons(2000); /* any port over 1024 will do... */ if ((udp = socket(AF_INET, SOCK_DGRAM, 0)) < 0 diff --git a/usr.sbin/mtrace/mtrace.c b/usr.sbin/mtrace/mtrace.c index c881db9a167..556f20e9afb 100644 --- a/usr.sbin/mtrace/mtrace.c +++ b/usr.sbin/mtrace/mtrace.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mtrace.c,v 1.32 2013/11/24 00:54:12 deraadt Exp $ */ +/* $OpenBSD: mtrace.c,v 1.33 2015/01/16 06:40:18 deraadt Exp $ */ /* $NetBSD: mtrace.c,v 1.5 1995/12/10 10:57:15 mycroft Exp $ */ /* @@ -1277,9 +1277,7 @@ usage: mtrace [-lMnpsv] [-g gateway] [-i if_addr] [-m max_hops] [-q nqueries]\n\ */ memset(&addr, 0, sizeof addr); addr.sin_family = AF_INET; -#if (defined(BSD) && (BSD >= 199103)) addr.sin_len = sizeof(addr); -#endif addr.sin_addr.s_addr = qgrp; addr.sin_port = htons(2000); /* Any port above 1024 will do */ @@ -1299,7 +1297,7 @@ usage: mtrace [-lMnpsv] [-g gateway] [-i if_addr] [-m max_hops] [-q nqueries]\n\ * mtrace -i [if_addr] will have to be used. */ if (addr.sin_addr.s_addr == 0) { - char myhostname[MAXHOSTNAMELEN]; + char myhostname[HOST_NAME_MAX+1]; struct hostent *hp; int error; diff --git a/usr.sbin/mtree/compare.c b/usr.sbin/mtree/compare.c index 21c0fca9ba1..454a458d37a 100644 --- a/usr.sbin/mtree/compare.c +++ b/usr.sbin/mtree/compare.c @@ -1,5 +1,5 @@ /* $NetBSD: compare.c,v 1.11 1996/09/05 09:56:48 mycroft Exp $ */ -/* $OpenBSD: compare.c,v 1.23 2012/07/08 21:19:42 naddy Exp $ */ +/* $OpenBSD: compare.c,v 1.24 2015/01/16 06:40:18 deraadt Exp $ */ /*- * Copyright (c) 1989, 1993 @@ -30,7 +30,6 @@ * SUCH DAMAGE. */ -#include <sys/param.h> #include <sys/stat.h> #include <fcntl.h> #include <fts.h> @@ -38,6 +37,7 @@ #include <stdio.h> #include <time.h> #include <unistd.h> +#include <limits.h> #include <md5.h> #include <rmd160.h> #include <sha1.h> @@ -399,7 +399,7 @@ ftype(u_int type) char * rlink(char *name) { - static char lbuf[MAXPATHLEN]; + static char lbuf[PATH_MAX]; int len; if ((len = readlink(name, lbuf, sizeof(lbuf)-1)) == -1) diff --git a/usr.sbin/mtree/create.c b/usr.sbin/mtree/create.c index 777a9bff344..eac12974748 100644 --- a/usr.sbin/mtree/create.c +++ b/usr.sbin/mtree/create.c @@ -1,5 +1,5 @@ /* $NetBSD: create.c,v 1.11 1996/09/05 09:24:19 mycroft Exp $ */ -/* $OpenBSD: create.c,v 1.29 2013/08/22 04:43:41 guenther Exp $ */ +/* $OpenBSD: create.c,v 1.30 2015/01/16 06:40:18 deraadt Exp $ */ /*- * Copyright (c) 1989, 1993 @@ -30,7 +30,6 @@ * SUCH DAMAGE. */ -#include <sys/param.h> #include <sys/stat.h> #include <time.h> #include <fcntl.h> @@ -40,6 +39,7 @@ #include <pwd.h> #include <errno.h> #include <unistd.h> +#include <limits.h> #include <stdio.h> #include <stdarg.h> #include <vis.h> @@ -57,7 +57,7 @@ extern u_int32_t crc_total; extern int ftsoptions; extern int dflag, iflag, nflag, sflag; extern u_int keys; -extern char fullpath[MAXPATHLEN]; +extern char fullpath[PATH_MAX]; static gid_t gid; static uid_t uid; @@ -74,7 +74,7 @@ cwalk(void) FTS *t; FTSENT *p; time_t clock; - char *argv[2], host[MAXHOSTNAMELEN]; + char *argv[2], host[HOST_NAME_MAX+1]; int indent = 0; (void)time(&clock); diff --git a/usr.sbin/mtree/mtree.c b/usr.sbin/mtree/mtree.c index 837b2fe1b97..f0b6987ff17 100644 --- a/usr.sbin/mtree/mtree.c +++ b/usr.sbin/mtree/mtree.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mtree.c,v 1.21 2013/11/27 13:32:02 okan Exp $ */ +/* $OpenBSD: mtree.c,v 1.22 2015/01/16 06:40:18 deraadt Exp $ */ /* $NetBSD: mtree.c,v 1.7 1996/09/05 23:29:22 thorpej Exp $ */ /*- @@ -30,11 +30,11 @@ * SUCH DAMAGE. */ -#include <sys/param.h> #include <sys/stat.h> #include <errno.h> #include <unistd.h> #include <stdio.h> +#include <limits.h> #include <fts.h> #include "mtree.h" #include "extern.h" @@ -45,7 +45,7 @@ int ftsoptions = FTS_PHYSICAL; int cflag, dflag, eflag, iflag, lflag, nflag, qflag, rflag, sflag, tflag, uflag, Uflag; u_int keys; -char fullpath[MAXPATHLEN]; +char fullpath[PATH_MAX]; static void usage(void); diff --git a/usr.sbin/mtree/verify.c b/usr.sbin/mtree/verify.c index 763e5b9b53c..c82f799fc95 100644 --- a/usr.sbin/mtree/verify.c +++ b/usr.sbin/mtree/verify.c @@ -1,4 +1,4 @@ -/* $OpenBSD: verify.c,v 1.19 2009/10/27 23:59:53 deraadt Exp $ */ +/* $OpenBSD: verify.c,v 1.20 2015/01/16 06:40:18 deraadt Exp $ */ /* $NetBSD: verify.c,v 1.10 1995/03/07 21:26:28 cgd Exp $ */ /*- @@ -30,7 +30,6 @@ * SUCH DAMAGE. */ -#include <sys/param.h> #include <sys/stat.h> #include <dirent.h> #include <fts.h> @@ -38,16 +37,17 @@ #include <unistd.h> #include <errno.h> #include <stdio.h> +#include <limits.h> #include "mtree.h" #include "extern.h" extern u_int32_t crc_total; extern int ftsoptions; extern int dflag, eflag, qflag, rflag, sflag, uflag; -extern char fullpath[MAXPATHLEN]; +extern char fullpath[PATH_MAX]; static NODE *root; -static char path[MAXPATHLEN]; +static char path[PATH_MAX]; static void miss(NODE *, char *, size_t); static int vwalk(void); diff --git a/usr.sbin/ndp/ndp.c b/usr.sbin/ndp/ndp.c index 73a7b60678d..bd8b76f8505 100644 --- a/usr.sbin/ndp/ndp.c +++ b/usr.sbin/ndp/ndp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ndp.c,v 1.58 2014/09/07 22:40:30 bluhm Exp $ */ +/* $OpenBSD: ndp.c,v 1.59 2015/01/16 06:40:18 deraadt Exp $ */ /* $KAME: ndp.c,v 1.101 2002/07/17 08:46:33 itojun Exp $ */ /* @@ -74,7 +74,6 @@ */ -#include <sys/param.h> #include <sys/file.h> #include <sys/ioctl.h> #include <sys/socket.h> diff --git a/usr.sbin/ospf6d/kroute.c b/usr.sbin/ospf6d/kroute.c index 2931d68418a..b1efa74c578 100644 --- a/usr.sbin/ospf6d/kroute.c +++ b/usr.sbin/ospf6d/kroute.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kroute.c,v 1.44 2014/06/23 03:46:17 guenther Exp $ */ +/* $OpenBSD: kroute.c,v 1.45 2015/01/16 06:40:19 deraadt Exp $ */ /* * Copyright (c) 2004 Esben Norby <norby@openbsd.org> @@ -17,7 +17,6 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#include <sys/param.h> #include <sys/types.h> #include <sys/socket.h> #include <sys/sysctl.h> @@ -36,6 +35,7 @@ #include <stdlib.h> #include <string.h> #include <unistd.h> +#include <limits.h> #include "ospf6d.h" #include "ospfe.h" diff --git a/usr.sbin/ospf6d/ospf6d.c b/usr.sbin/ospf6d/ospf6d.c index 4478b527df6..1f18fc5270f 100644 --- a/usr.sbin/ospf6d/ospf6d.c +++ b/usr.sbin/ospf6d/ospf6d.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ospf6d.c,v 1.25 2014/07/12 20:16:38 krw Exp $ */ +/* $OpenBSD: ospf6d.c,v 1.26 2015/01/16 06:40:19 deraadt Exp $ */ /* * Copyright (c) 2005 Claudio Jeker <claudio@openbsd.org> @@ -24,7 +24,6 @@ #include <sys/time.h> #include <sys/stat.h> #include <sys/wait.h> -#include <sys/param.h> #include <sys/sysctl.h> #include <netinet/in.h> diff --git a/usr.sbin/ospf6d/rde.c b/usr.sbin/ospf6d/rde.c index b60d263e756..4e4154c1c20 100644 --- a/usr.sbin/ospf6d/rde.c +++ b/usr.sbin/ospf6d/rde.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rde.c,v 1.62 2014/07/12 20:16:38 krw Exp $ */ +/* $OpenBSD: rde.c,v 1.63 2015/01/16 06:40:19 deraadt Exp $ */ /* * Copyright (c) 2004, 2005 Claudio Jeker <claudio@openbsd.org> @@ -18,7 +18,6 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#include <sys/param.h> /* for MIN() */ #include <sys/types.h> #include <sys/socket.h> #include <sys/queue.h> @@ -40,6 +39,8 @@ #include "log.h" #include "rde.h" +#define MINIMUM(a, b) (((a) < (b)) ? (a) : (b)) + void rde_sig_handler(int sig, short, void *); void rde_shutdown(void); void rde_dispatch_imsg(int, short, void *); @@ -1315,7 +1316,7 @@ prefix_compare(struct prefix_node *a, struct prefix_node *b) p = a->prefix; q = b->prefix; - len = MIN(LSA_PREFIXSIZE(p->prefixlen), LSA_PREFIXSIZE(q->prefixlen)); + len = MINIMUM(LSA_PREFIXSIZE(p->prefixlen), LSA_PREFIXSIZE(q->prefixlen)); i = memcmp(p + 1, q + 1, len); if (i) diff --git a/usr.sbin/ospfd/kroute.c b/usr.sbin/ospfd/kroute.c index c4c72a54f37..9f6841c7363 100644 --- a/usr.sbin/ospfd/kroute.c +++ b/usr.sbin/ospfd/kroute.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kroute.c,v 1.94 2014/06/23 03:46:17 guenther Exp $ */ +/* $OpenBSD: kroute.c,v 1.95 2015/01/16 06:40:19 deraadt Exp $ */ /* * Copyright (c) 2004 Esben Norby <norby@openbsd.org> @@ -17,7 +17,6 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#include <sys/param.h> #include <sys/types.h> #include <sys/socket.h> #include <sys/sysctl.h> @@ -36,6 +35,7 @@ #include <stdlib.h> #include <string.h> #include <unistd.h> +#include <limits.h> #include "ospfd.h" #include "log.h" diff --git a/usr.sbin/ospfd/ospfd.c b/usr.sbin/ospfd/ospfd.c index f24d947d94b..edce6fd599c 100644 --- a/usr.sbin/ospfd/ospfd.c +++ b/usr.sbin/ospfd/ospfd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ospfd.c,v 1.81 2014/07/12 20:16:38 krw Exp $ */ +/* $OpenBSD: ospfd.c,v 1.82 2015/01/16 06:40:19 deraadt Exp $ */ /* * Copyright (c) 2005 Claudio Jeker <claudio@openbsd.org> @@ -24,7 +24,6 @@ #include <sys/time.h> #include <sys/stat.h> #include <sys/wait.h> -#include <sys/param.h> #include <sys/sysctl.h> #include <netinet/in.h> diff --git a/usr.sbin/pcidump/pcidump.c b/usr.sbin/pcidump/pcidump.c index 065d2cf9402..0ae2377c14b 100644 --- a/usr.sbin/pcidump/pcidump.c +++ b/usr.sbin/pcidump/pcidump.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pcidump.c,v 1.36 2014/05/20 01:25:24 guenther Exp $ */ +/* $OpenBSD: pcidump.c,v 1.37 2015/01/16 06:40:19 deraadt Exp $ */ /* * Copyright (c) 2006, 2007 David Gwynne <loki@animata.net> @@ -16,8 +16,8 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#include <sys/types.h> #include <sys/ioctl.h> -#include <sys/param.h> #include <sys/pciio.h> #include <dev/pci/pcireg.h> @@ -32,6 +32,7 @@ #include <stdlib.h> #include <string.h> #include <unistd.h> +#include <limits.h> #define PCIDEV "/dev/pci" @@ -104,7 +105,7 @@ main(int argc, char *argv[]) { int nfuncs; int bus, dev, func; - char pcidev[MAXPATHLEN] = PCIDEV; + char pcidev[PATH_MAX] = PCIDEV; char *romfile = NULL; const char *errstr; int c, error = 0, dumpall = 1, domid = 0; diff --git a/usr.sbin/pppd/auth.c b/usr.sbin/pppd/auth.c index 6837010f532..286bb49fbcf 100644 --- a/usr.sbin/pppd/auth.c +++ b/usr.sbin/pppd/auth.c @@ -1,4 +1,4 @@ -/* $OpenBSD: auth.c,v 1.33 2014/11/13 06:19:51 schwarze Exp $ */ +/* $OpenBSD: auth.c,v 1.34 2015/01/16 06:40:19 deraadt Exp $ */ /* * auth.c - PPP authentication and phase control. @@ -77,6 +77,7 @@ #include <stddef.h> #include <stdlib.h> #include <unistd.h> +#include <limits.h> #include <syslog.h> #include <pwd.h> #include <string.h> @@ -552,7 +553,7 @@ auth_check_options() /* Default our_name to hostname, and user to our_name */ if (our_name[0] == 0 || usehostname) - strlcpy(our_name, hostname, MAXHOSTNAMELEN); + strlcpy(our_name, hostname, HOST_NAME_MAX+1); if (user[0] == 0) strlcpy(user, our_name, MAXNAMELEN); diff --git a/usr.sbin/pppd/demand.c b/usr.sbin/pppd/demand.c index fda74ca5faa..5d09d0beb19 100644 --- a/usr.sbin/pppd/demand.c +++ b/usr.sbin/pppd/demand.c @@ -1,4 +1,4 @@ -/* $OpenBSD: demand.c,v 1.10 2011/04/30 18:49:38 nicm Exp $ */ +/* $OpenBSD: demand.c,v 1.11 2015/01/16 06:40:19 deraadt Exp $ */ /* * demand.c - Support routines for demand-dialling. @@ -35,14 +35,6 @@ * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <errno.h> -#include <fcntl.h> -#include <syslog.h> -#include <netdb.h> -#include <sys/param.h> #include <sys/types.h> #include <sys/wait.h> #include <sys/time.h> @@ -54,6 +46,12 @@ #include <net/bpf.h> #include <pcap.h> #endif +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <errno.h> +#include <fcntl.h> +#include <syslog.h> #include "pppd.h" #include "fsm.h" diff --git a/usr.sbin/pppd/ipcp.c b/usr.sbin/pppd/ipcp.c index 1577557ab77..245f73fc28c 100644 --- a/usr.sbin/pppd/ipcp.c +++ b/usr.sbin/pppd/ipcp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ipcp.c,v 1.13 2010/05/10 02:00:50 krw Exp $ */ +/* $OpenBSD: ipcp.c,v 1.14 2015/01/16 06:40:19 deraadt Exp $ */ /* * ipcp.c - PPP IP Control Protocol. @@ -46,15 +46,14 @@ * TODO: */ +#include <sys/types.h> +#include <sys/socket.h> +#include <netinet/in.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <syslog.h> #include <netdb.h> -#include <sys/param.h> -#include <sys/types.h> -#include <sys/socket.h> -#include <netinet/in.h> #include "pppd.h" #include "fsm.h" diff --git a/usr.sbin/pppd/main.c b/usr.sbin/pppd/main.c index 7d74d74f92e..08ee24bb118 100644 --- a/usr.sbin/pppd/main.c +++ b/usr.sbin/pppd/main.c @@ -1,4 +1,4 @@ -/* $OpenBSD: main.c,v 1.50 2014/10/08 04:51:29 deraadt Exp $ */ +/* $OpenBSD: main.c,v 1.51 2015/01/16 06:40:19 deraadt Exp $ */ /* * main.c - Point-to-Point Protocol main module @@ -42,11 +42,19 @@ * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#include <sys/types.h> +#include <sys/wait.h> +#include <sys/time.h> +#include <sys/resource.h> +#include <sys/stat.h> +#include <sys/socket.h> +#include <net/if.h> #include <stdio.h> #include <ctype.h> #include <stdlib.h> #include <string.h> #include <unistd.h> +#include <limits.h> #include <signal.h> #include <errno.h> #include <fcntl.h> @@ -54,14 +62,6 @@ #include <netdb.h> #include <utmp.h> #include <pwd.h> -#include <sys/param.h> -#include <sys/types.h> -#include <sys/wait.h> -#include <sys/time.h> -#include <sys/resource.h> -#include <sys/stat.h> -#include <sys/socket.h> -#include <net/if.h> #include "pppd.h" #include "magic.h" @@ -91,9 +91,9 @@ char ifname[IFNAMSIZ]; /* Interface name */ int ifunit; /* Interface unit number */ char *progname; /* Name of this program */ -char hostname[MAXHOSTNAMELEN]; /* Our hostname */ -static char pidfilename[MAXPATHLEN]; /* name of pid file */ -static char default_devnam[MAXPATHLEN]; /* name of default device */ +char hostname[HOST_NAME_MAX+1]; /* Our hostname */ +static char pidfilename[PATH_MAX]; /* name of pid file */ +static char default_devnam[PATH_MAX]; /* name of default device */ static pid_t pid; /* Our pid */ static uid_t uid; /* Our real user-id */ static int conn_running; /* we have a [dis]connector running */ @@ -194,7 +194,7 @@ main(argc, argv) phase = PHASE_INITIALIZE; p = ttyname(0); if (p) - strlcpy(devnam, p, MAXPATHLEN); + strlcpy(devnam, p, PATH_MAX); strlcpy(default_devnam, devnam, sizeof default_devnam); script_env = NULL; @@ -1217,11 +1217,9 @@ run_program(prog, args, must_exist) dup2 (0, 2); /* stderr -> /dev/null */ } -#ifdef BSD /* Force the priority back to zero if pppd is running higher. */ if (setpriority (PRIO_PROCESS, 0, 0) < 0) syslog (LOG_WARNING, "can't reset priority to 0: %m"); -#endif /* SysV recommends a second fork at this point. */ diff --git a/usr.sbin/pppd/options.c b/usr.sbin/pppd/options.c index 99c29d8e10f..349d498e789 100644 --- a/usr.sbin/pppd/options.c +++ b/usr.sbin/pppd/options.c @@ -1,4 +1,4 @@ -/* $OpenBSD: options.c,v 1.27 2014/12/10 03:39:54 jsg Exp $ */ +/* $OpenBSD: options.c,v 1.28 2015/01/16 06:40:19 deraadt Exp $ */ /* * options.c - handles option processing for PPP. @@ -97,7 +97,7 @@ int dflag = 0; /* Tell libpcap we want debugging */ int debug = 0; /* Debug flag */ int kdebugflag = 0; /* Tell kernel to print debug messages */ int default_device = 1; /* Using /dev/tty or equivalent */ -char devnam[MAXPATHLEN] = "/dev/tty"; /* Device name */ +char devnam[PATH_MAX] = "/dev/tty"; /* Device name */ int crtscts = 0; /* Use hardware flow control */ int modem = 1; /* Use modem control lines */ int modem_chat = 0; /* Use modem control lines during chat */ @@ -1567,7 +1567,7 @@ setdevname(cp, quiet) int quiet; { struct stat statbuf; - char dev[MAXPATHLEN]; + char dev[PATH_MAX]; if (*cp == 0) return 0; @@ -1588,7 +1588,7 @@ setdevname(cp, quiet) return -1; } - (void) strlcpy(devnam, cp, MAXPATHLEN); + (void) strlcpy(devnam, cp, PATH_MAX); default_device = FALSE; devnam_info.priv = privileged_option; devnam_info.source = option_source; diff --git a/usr.sbin/pppd/pppd.h b/usr.sbin/pppd/pppd.h index 815b8bed73a..eaef54aa4db 100644 --- a/usr.sbin/pppd/pppd.h +++ b/usr.sbin/pppd/pppd.h @@ -1,4 +1,4 @@ -/* $OpenBSD: pppd.h,v 1.17 2011/04/30 18:49:38 nicm Exp $ */ +/* $OpenBSD: pppd.h,v 1.18 2015/01/16 06:40:19 deraadt Exp $ */ /* * pppd.h - PPP daemon global declarations. @@ -49,12 +49,11 @@ #ifndef __PPPD_H__ #define __PPPD_H__ -#include <stdio.h> /* for FILE */ -#include <stdarg.h> -#include <sys/param.h> /* for MAXPATHLEN and BSD4_4, if defined */ #include <sys/types.h> /* for u_int32_t, if defined */ #include <sys/time.h> /* for struct timeval */ #include <net/ppp_defs.h> +#include <stdio.h> /* for FILE */ +#include <stdarg.h> /* * Limits. diff --git a/usr.sbin/pppd/pppstats/pppstats.c b/usr.sbin/pppd/pppstats/pppstats.c index 0d0fde8840c..640ca0c82da 100644 --- a/usr.sbin/pppd/pppstats/pppstats.c +++ b/usr.sbin/pppd/pppstats/pppstats.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pppstats.c,v 1.10 2009/10/27 23:59:53 deraadt Exp $ */ +/* $OpenBSD: pppstats.c,v 1.11 2015/01/16 06:40:19 deraadt Exp $ */ /* * print PPP statistics: @@ -47,6 +47,12 @@ * SUCH DAMAGE. */ +#include <sys/types.h> +#include <sys/ioctl.h> +#include <sys/socket.h> +#include <net/ppp_defs.h> +#include <net/if.h> +#include <net/if_ppp.h> #include <stdio.h> #include <stddef.h> #include <stdlib.h> @@ -57,13 +63,6 @@ #include <fcntl.h> #include <err.h> #include <unistd.h> -#include <sys/param.h> -#include <sys/types.h> -#include <sys/ioctl.h> -#include <sys/socket.h> -#include <net/ppp_defs.h> -#include <net/if.h> -#include <net/if_ppp.h> int vflag, rflag, zflag; /* select type of display */ int aflag; /* print absolute values, not deltas */ diff --git a/usr.sbin/procmap/procmap.c b/usr.sbin/procmap/procmap.c index 15fc3118e39..b7e29e67ffd 100644 --- a/usr.sbin/procmap/procmap.c +++ b/usr.sbin/procmap/procmap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: procmap.c,v 1.57 2014/11/16 12:31:01 deraadt Exp $ */ +/* $OpenBSD: procmap.c,v 1.58 2015/01/16 06:40:19 deraadt Exp $ */ /* $NetBSD: pmap.c,v 1.1 2002/09/01 20:32:44 atatat Exp $ */ /* @@ -30,8 +30,8 @@ * POSSIBILITY OF SUCH DAMAGE. */ +#include <sys/param.h> /* MAXCOMLEN */ #include <sys/types.h> -#include <sys/param.h> #include <sys/time.h> #include <sys/exec.h> #include <sys/proc.h> diff --git a/usr.sbin/pstat/pstat.c b/usr.sbin/pstat/pstat.c index 6aa3f568a92..2db691b82bd 100644 --- a/usr.sbin/pstat/pstat.c +++ b/usr.sbin/pstat/pstat.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pstat.c,v 1.96 2014/12/19 14:12:00 tedu Exp $ */ +/* $OpenBSD: pstat.c,v 1.97 2015/01/16 06:40:19 deraadt Exp $ */ /* $NetBSD: pstat.c,v 1.27 1996/10/23 22:50:06 cgd Exp $ */ /*- @@ -30,7 +30,8 @@ * SUCH DAMAGE. */ -#include <sys/param.h> +#include <sys/param.h> /* MAXCOMLEN DEV_BSIZE */ +#include <sys/types.h> #include <sys/proc.h> #include <sys/time.h> #include <sys/vnode.h> diff --git a/usr.sbin/pwd_mkdb/pwd_mkdb.c b/usr.sbin/pwd_mkdb/pwd_mkdb.c index 02ff7493a86..3c128e9b582 100644 --- a/usr.sbin/pwd_mkdb/pwd_mkdb.c +++ b/usr.sbin/pwd_mkdb/pwd_mkdb.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pwd_mkdb.c,v 1.45 2014/08/25 07:50:26 doug Exp $ */ +/* $OpenBSD: pwd_mkdb.c,v 1.46 2015/01/16 06:40:19 deraadt Exp $ */ /*- * Copyright (c) 1991, 1993, 1994 @@ -31,7 +31,7 @@ * SUCH DAMAGE. */ -#include <sys/param.h> +#include <sys/param.h> /* MAXBSIZE */ #include <sys/stat.h> #include <db.h> @@ -46,8 +46,11 @@ #include <stdlib.h> #include <string.h> #include <unistd.h> +#include <limits.h> #include <util.h> +#define MINIMUM(a, b) (((a) < (b)) ? (a) : (b)) + #define INSECURE 1 #define SECURE 2 #define PERM_INSECURE (S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH) @@ -97,7 +100,7 @@ main(int argc, char **argv) uid_t olduid; gid_t shadow; int ch, tfd, makeold, secureonly, flags, checkonly; - char *username, buf[MAX(MAXPATHLEN, LINE_MAX * 2)]; + char *username, buf[MAX(PATH_MAX, LINE_MAX * 2)]; flags = checkonly = makeold = secureonly = 0; username = NULL; @@ -108,7 +111,7 @@ main(int argc, char **argv) break; case 'd': basedir = optarg; - if (strlen(basedir) > MAXPATHLEN - 40) + if (strlen(basedir) > PATH_MAX - 40) errx(1, "basedir too long"); break; case 'p': /* create V7 "file.orig" */ @@ -178,7 +181,7 @@ main(int argc, char **argv) /* Tweak openinfo values for large passwd files. */ if (st.st_size > (off_t)100*1024) - openinfo.cachesize = MIN(st.st_size * 20, (off_t)12*1024*1024); + openinfo.cachesize = MINIMUM(st.st_size * 20, (off_t)12*1024*1024); if (st.st_size / 128 > openinfo.nelem) openinfo.nelem = st.st_size / 128; @@ -399,7 +402,7 @@ cp(char *from, char *to, mode_t mode) void mv(char *from, char *to) { - char buf[MAXPATHLEN * 2]; + char buf[PATH_MAX * 2]; if (rename(from, to)) { int sverrno = errno; @@ -439,7 +442,7 @@ errorx(char *name) void cleanup(void) { - char buf[MAXPATHLEN]; + char buf[PATH_MAX]; if (clean & FILE_ORIG) { (void)snprintf(buf, sizeof(buf), "%s.orig", pname); @@ -468,7 +471,7 @@ usage(void) char * changedir(char *path, char *dir) { - static char fixed[MAXPATHLEN]; + static char fixed[PATH_MAX]; char *p; if (!dir) diff --git a/usr.sbin/quot/quot.c b/usr.sbin/quot/quot.c index 8935b1a1758..588b6334de2 100644 --- a/usr.sbin/quot/quot.c +++ b/usr.sbin/quot/quot.c @@ -1,4 +1,4 @@ -/* $OpenBSD: quot.c,v 1.24 2013/11/12 22:27:12 deraadt Exp $ */ +/* $OpenBSD: quot.c,v 1.25 2015/01/16 06:40:19 deraadt Exp $ */ /* * Copyright (C) 1991, 1994 Wolfgang Solfrank. @@ -31,7 +31,7 @@ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include <sys/param.h> +#include <sys/param.h> /* MAXFRAG DEV_BSIZE MAXBSIZE */ #include <sys/mount.h> #include <sys/time.h> #include <ufs/ufs/dinode.h> diff --git a/usr.sbin/quotaon/quotaon.c b/usr.sbin/quotaon/quotaon.c index c906cdf636d..d2e3acfba32 100644 --- a/usr.sbin/quotaon/quotaon.c +++ b/usr.sbin/quotaon/quotaon.c @@ -33,7 +33,6 @@ /* * Turn quota on/off for a filesystem. */ -#include <sys/param.h> #include <sys/file.h> #include <sys/mount.h> #include <ufs/ufs/quota.h> diff --git a/usr.sbin/rarpd/arptab.c b/usr.sbin/rarpd/arptab.c index 87fd7686faf..c713805cf13 100644 --- a/usr.sbin/rarpd/arptab.c +++ b/usr.sbin/rarpd/arptab.c @@ -1,4 +1,4 @@ -/* $OpenBSD: arptab.c,v 1.22 2013/11/12 19:49:42 deraadt Exp $ */ +/* $OpenBSD: arptab.c,v 1.23 2015/01/16 06:40:19 deraadt Exp $ */ /* * Copyright (c) 1984, 1993 @@ -37,7 +37,6 @@ */ -#include <sys/param.h> #include <sys/file.h> #include <sys/socket.h> #include <sys/sysctl.h> diff --git a/usr.sbin/rarpd/rarpd.c b/usr.sbin/rarpd/rarpd.c index 98360e0b3c8..61e96b2ae9d 100644 --- a/usr.sbin/rarpd/rarpd.c +++ b/usr.sbin/rarpd/rarpd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rarpd.c,v 1.57 2014/12/16 03:35:49 millert Exp $ */ +/* $OpenBSD: rarpd.c,v 1.58 2015/01/16 06:40:19 deraadt Exp $ */ /* $NetBSD: rarpd.c,v 1.25 1998/04/23 02:48:33 mrg Exp $ */ /* @@ -26,23 +26,24 @@ * rarpd - Reverse ARP Daemon */ -#include <stdio.h> -#include <stdlib.h> -#include <syslog.h> -#include <string.h> -#include <stdarg.h> -#include <sys/param.h> -#include <unistd.h> #include <sys/time.h> -#include <net/bpf.h> +#include <sys/file.h> #include <sys/socket.h> #include <sys/ioctl.h> +#include <net/bpf.h> #include <net/if.h> #include <net/if_dl.h> #include <net/if_types.h> #include <netinet/in.h> #include <netinet/if_ether.h> -#include <sys/file.h> + +#include <stdio.h> +#include <stdlib.h> +#include <syslog.h> +#include <string.h> +#include <stdarg.h> +#include <unistd.h> +#include <limits.h> #include <errno.h> #include <netdb.h> #include <arpa/inet.h> @@ -518,7 +519,7 @@ choose_ipaddr(u_int32_t **alist, u_int32_t net, u_int32_t netmask) void rarp_process(struct if_info *ii, u_char *pkt) { - char ename[MAXHOSTNAMELEN]; + char ename[HOST_NAME_MAX+1]; u_int32_t target_ipaddr; struct ether_header *ep; struct ether_addr *ea; diff --git a/usr.sbin/rbootd/bpf.c b/usr.sbin/rbootd/bpf.c index 64a536e813b..f6c37be1bde 100644 --- a/usr.sbin/rbootd/bpf.c +++ b/usr.sbin/rbootd/bpf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bpf.c,v 1.20 2014/11/02 02:44:50 deraadt Exp $ */ +/* $OpenBSD: bpf.c,v 1.21 2015/01/16 06:40:19 deraadt Exp $ */ /* $NetBSD: bpf.c,v 1.5.2.1 1995/11/14 08:45:42 thorpej Exp $ */ /* @@ -43,7 +43,6 @@ * Author: Jeff Forys, University of Utah CSS */ -#include <sys/param.h> #include <sys/ioctl.h> #include <sys/socket.h> diff --git a/usr.sbin/rbootd/conf.c b/usr.sbin/rbootd/conf.c index 90e53369f33..8c7508645cb 100644 --- a/usr.sbin/rbootd/conf.c +++ b/usr.sbin/rbootd/conf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: conf.c,v 1.7 2009/10/27 23:59:54 deraadt Exp $ */ +/* $OpenBSD: conf.c,v 1.8 2015/01/16 06:40:19 deraadt Exp $ */ /* $NetBSD: conf.c,v 1.5 1995/10/06 05:12:13 thorpej Exp $ */ /* @@ -43,10 +43,10 @@ * Author: Jeff Forys, University of Utah CSS */ -#include <sys/param.h> #include <sys/time.h> #include <stdio.h> +#include <limits.h> #include "defs.h" #include "pathnames.h" @@ -60,7 +60,7 @@ ** simplify the boot file search code. */ -char MyHost[MAXHOSTNAMELEN]; /* host name */ +char MyHost[HOST_NAME_MAX+1]; /* host name */ int DebugFlg = 0; /* set true if debugging */ int BootAny = 0; /* set true if we boot anyone */ diff --git a/usr.sbin/rbootd/defs.h b/usr.sbin/rbootd/defs.h index feb03805231..eff3f0419a2 100644 --- a/usr.sbin/rbootd/defs.h +++ b/usr.sbin/rbootd/defs.h @@ -1,4 +1,4 @@ -/* $OpenBSD: defs.h,v 1.8 2013/04/20 20:17:17 miod Exp $ */ +/* $OpenBSD: defs.h,v 1.9 2015/01/16 06:40:19 deraadt Exp $ */ /* $NetBSD: defs.h,v 1.5 1995/10/06 05:12:14 thorpej Exp $ */ /* @@ -52,13 +52,6 @@ */ /* - * This may be defined in <sys/param.h>, if not, it's defined here. - */ -#ifndef MAXHOSTNAMELEN -#define MAXHOSTNAMELEN 64 -#endif - -/* * SIGUSR1 and SIGUSR2 are defined in <signal.h> for 4.3BSD systems. */ #ifndef SIGUSR1 diff --git a/usr.sbin/rbootd/parseconf.c b/usr.sbin/rbootd/parseconf.c index f2d36b75afc..583f8ad32f4 100644 --- a/usr.sbin/rbootd/parseconf.c +++ b/usr.sbin/rbootd/parseconf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: parseconf.c,v 1.11 2013/11/28 18:26:46 deraadt Exp $ */ +/* $OpenBSD: parseconf.c,v 1.12 2015/01/16 06:40:19 deraadt Exp $ */ /* $NetBSD: parseconf.c,v 1.4 1995/10/06 05:12:16 thorpej Exp $ */ /* @@ -43,7 +43,6 @@ * Author: Jeff Forys, University of Utah CSS */ -#include <sys/param.h> #include <sys/stat.h> #include <ctype.h> diff --git a/usr.sbin/rbootd/rbootd.c b/usr.sbin/rbootd/rbootd.c index d2e0bae497a..bfc09695442 100644 --- a/usr.sbin/rbootd/rbootd.c +++ b/usr.sbin/rbootd/rbootd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rbootd.c,v 1.25 2014/05/17 21:37:51 chl Exp $ */ +/* $OpenBSD: rbootd.c,v 1.26 2015/01/16 06:40:19 deraadt Exp $ */ /* $NetBSD: rbootd.c,v 1.5 1995/10/06 05:12:17 thorpej Exp $ */ /* @@ -43,7 +43,6 @@ * Author: Jeff Forys, University of Utah CSS */ -#include <sys/param.h> #include <sys/time.h> #include <ctype.h> @@ -56,6 +55,7 @@ #include <string.h> #include <syslog.h> #include <unistd.h> +#include <limits.h> #include <util.h> #include <pwd.h> #include <poll.h> @@ -158,7 +158,7 @@ main(int argc, char *argv[]) (void) signal(SIGINT, Exit); (void) signal(SIGTERM, Exit); - gethostname(MyHost, MAXHOSTNAMELEN); + gethostname(MyHost, HOST_NAME_MAX+1); if (pidfile(NULL) < 0) syslog(LOG_WARNING, "pidfile: failed"); diff --git a/usr.sbin/rbootd/rmpproto.c b/usr.sbin/rbootd/rmpproto.c index 809cf83ac43..2831eaad74e 100644 --- a/usr.sbin/rbootd/rmpproto.c +++ b/usr.sbin/rbootd/rmpproto.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rmpproto.c,v 1.10 2009/10/27 23:59:54 deraadt Exp $ */ +/* $OpenBSD: rmpproto.c,v 1.11 2015/01/16 06:40:19 deraadt Exp $ */ /* $NetBSD: rmpproto.c,v 1.5.2.1 1995/11/14 08:45:44 thorpej Exp $ */ /* @@ -43,7 +43,6 @@ * Author: Jeff Forys, University of Utah CSS */ -#include <sys/param.h> #include <sys/time.h> #include <errno.h> diff --git a/usr.sbin/rbootd/utils.c b/usr.sbin/rbootd/utils.c index 3ad5792d51a..b89e6e4611d 100644 --- a/usr.sbin/rbootd/utils.c +++ b/usr.sbin/rbootd/utils.c @@ -1,4 +1,4 @@ -/* $OpenBSD: utils.c,v 1.12 2013/08/22 04:43:41 guenther Exp $ */ +/* $OpenBSD: utils.c,v 1.13 2015/01/16 06:40:19 deraadt Exp $ */ /* $NetBSD: utils.c,v 1.5.2.1 1995/11/14 08:45:46 thorpej Exp $ */ /* @@ -43,8 +43,6 @@ * Author: Jeff Forys, University of Utah CSS */ -#include <sys/param.h> - #include <fcntl.h> #include <signal.h> #include <stdio.h> diff --git a/usr.sbin/rdate/ntp.c b/usr.sbin/rdate/ntp.c index e06f236dc8f..688436ac4de 100644 --- a/usr.sbin/rdate/ntp.c +++ b/usr.sbin/rdate/ntp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ntp.c,v 1.32 2014/10/29 04:00:44 deraadt Exp $ */ +/* $OpenBSD: ntp.c,v 1.33 2015/01/16 06:40:20 deraadt Exp $ */ /* * Copyright (c) 1996, 1997 by N.M. Maclaren. All rights reserved. @@ -29,7 +29,6 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include <sys/param.h> #include <sys/socket.h> #include <sys/time.h> #include <netinet/in.h> diff --git a/usr.sbin/rdate/rdate.c b/usr.sbin/rdate/rdate.c index 1c503dc64bf..d14bb783a62 100644 --- a/usr.sbin/rdate/rdate.c +++ b/usr.sbin/rdate/rdate.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rdate.c,v 1.30 2013/11/12 22:27:13 deraadt Exp $ */ +/* $OpenBSD: rdate.c,v 1.31 2015/01/16 06:40:20 deraadt Exp $ */ /* $NetBSD: rdate.c,v 1.4 1996/03/16 12:37:45 pk Exp $ */ /* @@ -38,7 +38,6 @@ * midnight January 1st 1900. */ -#include <sys/param.h> #include <sys/socket.h> #include <sys/time.h> diff --git a/usr.sbin/rdate/rfc868time.c b/usr.sbin/rdate/rfc868time.c index 7f1b23bc283..be97fcd4785 100644 --- a/usr.sbin/rdate/rfc868time.c +++ b/usr.sbin/rdate/rfc868time.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rfc868time.c,v 1.9 2013/11/12 22:27:13 deraadt Exp $ */ +/* $OpenBSD: rfc868time.c,v 1.10 2015/01/16 06:40:20 deraadt Exp $ */ /* $NetBSD: rdate.c,v 1.4 1996/03/16 12:37:45 pk Exp $ */ /* @@ -39,7 +39,6 @@ * midnight January 1st 1900. */ -#include <sys/param.h> #include <sys/socket.h> #include <sys/time.h> #include <netinet/in.h> diff --git a/usr.sbin/relayctl/relayctl.c b/usr.sbin/relayctl/relayctl.c index 9c57db4da43..e42dc5ec671 100644 --- a/usr.sbin/relayctl/relayctl.c +++ b/usr.sbin/relayctl/relayctl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: relayctl.c,v 1.51 2014/07/09 16:42:05 reyk Exp $ */ +/* $OpenBSD: relayctl.c,v 1.52 2015/01/16 06:40:20 deraadt Exp $ */ /* * Copyright (c) 2007 - 2013 Reyk Floeter <reyk@openbsd.org> @@ -332,7 +332,7 @@ show_summary_msg(struct imsg *imsg, int type) struct router *rt; struct netroute *nr; struct ctl_stats stats[RELAY_MAXPROC]; - char name[MAXHOSTNAMELEN]; + char name[HOST_NAME_MAX+1]; switch (imsg->hdr.type) { case IMSG_CTL_RDR: diff --git a/usr.sbin/repquota/repquota.c b/usr.sbin/repquota/repquota.c index 57f2acda532..df68703913c 100644 --- a/usr.sbin/repquota/repquota.c +++ b/usr.sbin/repquota/repquota.c @@ -33,7 +33,7 @@ /* * Quota report */ -#include <sys/param.h> +#include <sys/param.h> /* dbtob */ #include <sys/stat.h> #include <ufs/ufs/quota.h> #include <fstab.h> diff --git a/usr.sbin/ripd/kroute.c b/usr.sbin/ripd/kroute.c index 619e885b21d..87579af8052 100644 --- a/usr.sbin/ripd/kroute.c +++ b/usr.sbin/ripd/kroute.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kroute.c,v 1.25 2014/06/23 03:46:17 guenther Exp $ */ +/* $OpenBSD: kroute.c,v 1.26 2015/01/16 06:40:20 deraadt Exp $ */ /* * Copyright (c) 2004 Esben Norby <norby@openbsd.org> @@ -17,7 +17,6 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#include <sys/param.h> #include <sys/types.h> #include <sys/socket.h> #include <sys/sysctl.h> diff --git a/usr.sbin/ripd/rde.c b/usr.sbin/ripd/rde.c index 6915add3d1c..79f033b1f88 100644 --- a/usr.sbin/ripd/rde.c +++ b/usr.sbin/ripd/rde.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rde.c,v 1.17 2014/07/12 20:16:38 krw Exp $ */ +/* $OpenBSD: rde.c,v 1.18 2015/01/16 06:40:20 deraadt Exp $ */ /* * Copyright (c) 2006 Michele Marchetto <mydecay@openbeer.it> @@ -19,7 +19,6 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#include <sys/param.h> /* for MIN() */ #include <sys/socket.h> #include <sys/queue.h> #include <netinet/in.h> @@ -39,6 +38,8 @@ #include "log.h" #include "rde.h" +#define MINIMUM(a, b) (((a) < (b)) ? (a) : (b)) + struct ripd_conf *rdeconf = NULL; struct imsgev *iev_ripe; struct imsgev *iev_main; @@ -401,7 +402,7 @@ rde_check_route(struct rip_route *e) if ((iface = if_find_index(e->ifindex)) == NULL) return (-1); - metric = MIN(INFINITY, e->metric + iface->cost); + metric = MINIMUM(INFINITY, e->metric + iface->cost); if ((rn = rt_find(e->address.s_addr, e->mask.s_addr)) == NULL) { if (metric >= INFINITY) diff --git a/usr.sbin/ripd/ripd.c b/usr.sbin/ripd/ripd.c index 9ba92b91f81..f779aaf25eb 100644 --- a/usr.sbin/ripd/ripd.c +++ b/usr.sbin/ripd/ripd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ripd.c,v 1.23 2014/07/12 20:16:38 krw Exp $ */ +/* $OpenBSD: ripd.c,v 1.24 2015/01/16 06:40:20 deraadt Exp $ */ /* * Copyright (c) 2006 Michele Marchetto <mydecay@openbeer.it> @@ -25,7 +25,6 @@ #include <sys/time.h> #include <sys/stat.h> #include <sys/wait.h> -#include <sys/param.h> #include <sys/sysctl.h> #include <netinet/in.h> diff --git a/usr.sbin/rmt/rmt.c b/usr.sbin/rmt/rmt.c index 7e457121f71..28d31dd1c33 100644 --- a/usr.sbin/rmt/rmt.c +++ b/usr.sbin/rmt/rmt.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rmt.c,v 1.14 2013/12/03 00:20:03 deraadt Exp $ */ +/* $OpenBSD: rmt.c,v 1.15 2015/01/16 06:40:20 deraadt Exp $ */ /* * Copyright (c) 1983 Regents of the University of California. @@ -38,12 +38,12 @@ #include <sys/stat.h> #include <sys/ioctl.h> #include <sys/mtio.h> -#include <sys/param.h> #include <unistd.h> #include <stdio.h> #include <stdlib.h> #include <errno.h> #include <string.h> +#include <limits.h> int tape = -1; @@ -51,7 +51,7 @@ char *record; int maxrecsize = -1; #define STRSIZE 64 -char device[MAXPATHLEN]; +char device[PATH_MAX]; char count[STRSIZE], mode[STRSIZE], pos[STRSIZE], op[STRSIZE]; char resp[BUFSIZ]; diff --git a/usr.sbin/route6d/route6d.c b/usr.sbin/route6d/route6d.c index 9b9f3ad8e0a..faecab21631 100644 --- a/usr.sbin/route6d/route6d.c +++ b/usr.sbin/route6d/route6d.c @@ -1,4 +1,4 @@ -/* $OpenBSD: route6d.c,v 1.63 2014/10/08 10:57:17 deraadt Exp $ */ +/* $OpenBSD: route6d.c,v 1.64 2015/01/16 06:40:20 deraadt Exp $ */ /* $KAME: route6d.c,v 1.111 2006/10/25 06:38:13 jinmei Exp $ */ /* @@ -47,7 +47,6 @@ #include <poll.h> #include <sys/types.h> -#include <sys/param.h> #include <sys/file.h> #include <sys/socket.h> #include <sys/ioctl.h> diff --git a/usr.sbin/rpc.lockd/lockd.c b/usr.sbin/rpc.lockd/lockd.c index 0befb6d5d29..f0c8fbd943f 100644 --- a/usr.sbin/rpc.lockd/lockd.c +++ b/usr.sbin/rpc.lockd/lockd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: lockd.c,v 1.12 2009/11/15 09:07:56 chl Exp $ */ +/* $OpenBSD: lockd.c,v 1.13 2015/01/16 06:40:20 deraadt Exp $ */ /* * Copyright (c) 1995 @@ -33,7 +33,6 @@ * */ -#include <sys/param.h> #include <sys/socket.h> #include <netinet/in.h> #include <rpc/rpc.h> diff --git a/usr.sbin/rpc.lockd/lockd_lock.c b/usr.sbin/rpc.lockd/lockd_lock.c index c22fe6f68f6..bd687a7c803 100644 --- a/usr.sbin/rpc.lockd/lockd_lock.c +++ b/usr.sbin/rpc.lockd/lockd_lock.c @@ -1,4 +1,4 @@ -/* $OpenBSD: lockd_lock.c,v 1.8 2013/04/23 18:17:22 deraadt Exp $ */ +/* $OpenBSD: lockd_lock.c,v 1.9 2015/01/16 06:40:20 deraadt Exp $ */ /* * Copyright (c) 2000 Manuel Bouyer. @@ -26,6 +26,10 @@ * */ +#include <sys/socket.h> +#include <sys/stat.h> +#include <sys/mount.h> +#include <sys/wait.h> #include <stdio.h> #include <stdlib.h> #include <unistd.h> @@ -36,11 +40,6 @@ #include <string.h> #include <signal.h> #include <rpc/rpc.h> -#include <sys/socket.h> -#include <sys/stat.h> -#include <sys/param.h> -#include <sys/mount.h> -#include <sys/wait.h> #include <rpcsvc/sm_inter.h> #include <rpcsvc/nlm_prot.h> #include "lockd_lock.h" diff --git a/usr.sbin/rpc.lockd/procs.c b/usr.sbin/rpc.lockd/procs.c index af8a71c5751..be4319c55e8 100644 --- a/usr.sbin/rpc.lockd/procs.c +++ b/usr.sbin/rpc.lockd/procs.c @@ -1,4 +1,4 @@ -/* $OpenBSD: procs.c,v 1.14 2011/03/22 10:16:23 okan Exp $ */ +/* $OpenBSD: procs.c,v 1.15 2015/01/16 06:40:20 deraadt Exp $ */ /* * Copyright (c) 1995 @@ -33,7 +33,6 @@ * */ -#include <sys/param.h> #include <sys/socket.h> #include <netinet/in.h> #include <rpc/rpc.h> @@ -46,6 +45,7 @@ #include <stdlib.h> #include <string.h> #include <netdb.h> +#include <limits.h> #include "lockd.h" #include "lockd_lock.h" @@ -65,7 +65,7 @@ log_from_addr(char *fun_name, struct svc_req *req) { struct sockaddr_in *addr; struct hostent *host; - char hostname_buf[MAXHOSTNAMELEN]; + char hostname_buf[HOST_NAME_MAX+1]; addr = svc_getcaller(req->rq_xprt); host = gethostbyaddr((char *) &(addr->sin_addr), addr->sin_len, AF_INET); diff --git a/usr.sbin/rpc.statd/statd.c b/usr.sbin/rpc.statd/statd.c index a6aa05390bb..9bc448c1e68 100644 --- a/usr.sbin/rpc.statd/statd.c +++ b/usr.sbin/rpc.statd/statd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: statd.c,v 1.1 2008/06/15 04:43:28 sturm Exp $ */ +/* $OpenBSD: statd.c,v 1.2 2015/01/16 06:40:20 deraadt Exp $ */ /* * Copyright (c) 1997 Christos Zoulas. All rights reserved. @@ -39,7 +39,6 @@ /* file was generated by running rpcgen /usr/include/rpcsvc/sm_inter.x */ /* The actual program logic is in the file procs.c */ -#include <sys/param.h> #include <sys/wait.h> #include <err.h> @@ -241,7 +240,7 @@ change_host(char *hostnamep, HostInfo *hp) { DBT key, data; char *ptr; - char hostname[MAXHOSTNAMELEN + 1]; + char hostname[HOST_NAME_MAX+1 + 1]; HostInfo h; strlcpy(hostname, hostnamep, sizeof(hostname)); @@ -561,7 +560,7 @@ notify_one_host(char *hostname) CLIENT *cli; char dummy; stat_chge arg; - char our_hostname[MAXHOSTNAMELEN + 1]; + char our_hostname[HOST_NAME_MAX+1 + 1]; gethostname(our_hostname, sizeof(our_hostname)); our_hostname[sizeof(our_hostname) - 1] = '\0'; diff --git a/usr.sbin/rtadvd/config.c b/usr.sbin/rtadvd/config.c index 3f56f61ca3a..554f1af31a1 100644 --- a/usr.sbin/rtadvd/config.c +++ b/usr.sbin/rtadvd/config.c @@ -1,4 +1,4 @@ -/* $OpenBSD: config.c,v 1.42 2014/07/04 22:39:31 guenther Exp $ */ +/* $OpenBSD: config.c,v 1.43 2015/01/16 06:40:20 deraadt Exp $ */ /* $KAME: config.c,v 1.62 2002/05/29 10:13:10 itojun Exp $ */ /* @@ -30,7 +30,6 @@ * SUCH DAMAGE. */ -#include <sys/param.h> #include <sys/ioctl.h> #include <sys/socket.h> #include <sys/time.h> diff --git a/usr.sbin/rtadvd/if.c b/usr.sbin/rtadvd/if.c index db8bbd861a1..d530c538229 100644 --- a/usr.sbin/rtadvd/if.c +++ b/usr.sbin/rtadvd/if.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if.c,v 1.26 2014/06/29 00:58:45 deraadt Exp $ */ +/* $OpenBSD: if.c,v 1.27 2015/01/16 06:40:20 deraadt Exp $ */ /* $KAME: if.c,v 1.17 2001/01/21 15:27:30 itojun Exp $ */ /* @@ -30,7 +30,6 @@ * SUCH DAMAGE. */ -#include <sys/param.h> #include <sys/socket.h> #include <sys/sysctl.h> #include <sys/queue.h> diff --git a/usr.sbin/rtadvd/rrenum.c b/usr.sbin/rtadvd/rrenum.c index 712ecef91aa..f42b4a827a3 100644 --- a/usr.sbin/rtadvd/rrenum.c +++ b/usr.sbin/rtadvd/rrenum.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rrenum.c,v 1.17 2014/06/29 00:58:45 deraadt Exp $ */ +/* $OpenBSD: rrenum.c,v 1.18 2015/01/16 06:40:20 deraadt Exp $ */ /* $KAME: rrenum.c,v 1.11 2002/05/21 14:26:55 itojun Exp $ */ /* @@ -30,7 +30,6 @@ * SUCH DAMAGE. */ #include <sys/types.h> -#include <sys/param.h> #include <sys/ioctl.h> #include <sys/socket.h> #include <sys/sysctl.h> diff --git a/usr.sbin/rtadvd/rtadvd.c b/usr.sbin/rtadvd/rtadvd.c index 7fa6180caad..f4075911262 100644 --- a/usr.sbin/rtadvd/rtadvd.c +++ b/usr.sbin/rtadvd/rtadvd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rtadvd.c,v 1.52 2015/01/01 20:28:27 florian Exp $ */ +/* $OpenBSD: rtadvd.c,v 1.53 2015/01/16 06:40:20 deraadt Exp $ */ /* $KAME: rtadvd.c,v 1.66 2002/05/29 14:18:36 itojun Exp $ */ /* @@ -30,8 +30,9 @@ * SUCH DAMAGE. */ -#include <sys/param.h> +#include <sys/types.h> #include <sys/socket.h> +#include <sys/signal.h> #include <sys/uio.h> #include <sys/time.h> #include <sys/queue.h> diff --git a/usr.sbin/sa/extern.h b/usr.sbin/sa/extern.h index 5d6584a1d69..722043c2f4d 100644 --- a/usr.sbin/sa/extern.h +++ b/usr.sbin/sa/extern.h @@ -27,11 +27,10 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * $Id: extern.h,v 1.3 2002/02/16 21:28:09 millert Exp $ + * $Id: extern.h,v 1.4 2015/01/16 06:40:20 deraadt Exp $ */ -#include <sys/types.h> -#include <sys/param.h> +#include <sys/param.h> /* MAXCOMLEN */ #include <db.h> /* structures */ diff --git a/usr.sbin/sasyncd/monitor.c b/usr.sbin/sasyncd/monitor.c index c4174d732bb..27c734ed7ef 100644 --- a/usr.sbin/sasyncd/monitor.c +++ b/usr.sbin/sasyncd/monitor.c @@ -1,4 +1,4 @@ -/* $OpenBSD: monitor.c,v 1.18 2014/06/29 00:58:45 deraadt Exp $ */ +/* $OpenBSD: monitor.c,v 1.19 2015/01/16 06:40:20 deraadt Exp $ */ /* * Copyright (c) 2005 Håkan Olsson. All rights reserved. @@ -25,7 +25,6 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include <sys/param.h> #include <sys/types.h> #include <sys/ioctl.h> #include <sys/socket.h> @@ -43,6 +42,7 @@ #include <string.h> #include <stdlib.h> #include <unistd.h> +#include <limits.h> #include <imsg.h> #include "types.h" /* iked imsg types */ @@ -70,7 +70,7 @@ monitor_init(void) { struct passwd *pw = getpwnam(SASYNCD_USER); extern char *__progname; - char root[MAXPATHLEN]; + char root[PATH_MAX]; int p[2]; if (socketpair(AF_UNIX, SOCK_STREAM, PF_UNSPEC, p) != 0) { diff --git a/usr.sbin/sasyncd/pfkey.c b/usr.sbin/sasyncd/pfkey.c index 8f8c9834418..a0ee2d80276 100644 --- a/usr.sbin/sasyncd/pfkey.c +++ b/usr.sbin/sasyncd/pfkey.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pfkey.c,v 1.22 2014/10/26 14:47:37 chl Exp $ */ +/* $OpenBSD: pfkey.c,v 1.23 2015/01/16 06:40:20 deraadt Exp $ */ /* * Copyright (c) 2005 Håkan Olsson. All rights reserved. @@ -30,7 +30,6 @@ */ -#include <sys/param.h> #include <sys/types.h> #include <sys/ioctl.h> #include <sys/socket.h> diff --git a/usr.sbin/sensorsd/sensorsd.c b/usr.sbin/sensorsd/sensorsd.c index 146cd313f89..5e1a61bfbc2 100644 --- a/usr.sbin/sensorsd/sensorsd.c +++ b/usr.sbin/sensorsd/sensorsd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sensorsd.c,v 1.53 2014/06/29 00:58:45 deraadt Exp $ */ +/* $OpenBSD: sensorsd.c,v 1.54 2015/01/16 06:40:20 deraadt Exp $ */ /* * Copyright (c) 2003 Henning Brauer <henning@openbsd.org> @@ -18,7 +18,7 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#include <sys/param.h> +#include <sys/types.h> #include <sys/sysctl.h> #include <sys/queue.h> #include <sys/sensors.h> @@ -32,6 +32,7 @@ #include <syslog.h> #include <time.h> #include <unistd.h> +#include <limits.h> #define RFBUFSIZ 28 /* buffer size for print_sensor */ #define RFBUFCNT 4 /* ring buffers */ diff --git a/usr.sbin/slowcgi/slowcgi.c b/usr.sbin/slowcgi/slowcgi.c index fdf0cd9fac0..44595bb0e1a 100644 --- a/usr.sbin/slowcgi/slowcgi.c +++ b/usr.sbin/slowcgi/slowcgi.c @@ -1,4 +1,4 @@ -/* $OpenBSD: slowcgi.c,v 1.41 2014/12/08 12:12:46 blambert Exp $ */ +/* $OpenBSD: slowcgi.c,v 1.42 2015/01/16 06:40:20 deraadt Exp $ */ /* * Copyright (c) 2013 David Gwynne <dlg@openbsd.org> * Copyright (c) 2013 Florian Obser <florian@openbsd.org> @@ -30,6 +30,7 @@ #include <errno.h> #include <event.h> #include <netdb.h> +#include <limits.h> #include <pwd.h> #include <signal.h> #include <stdio.h> @@ -118,7 +119,7 @@ struct request { struct fcgi_response_head response_head; struct fcgi_stdin_head stdin_head; uint16_t id; - char script_name[MAXPATHLEN]; + char script_name[PATH_MAX]; struct env_head env; int env_count; pid_t script_pid; @@ -745,11 +746,11 @@ parse_params(uint8_t *buf, uint16_t n, struct request *c, uint16_t id) n -= name_len; env_entry->val[name_len] = '\0'; - if (val_len < MAXPATHLEN && strcmp(env_entry->val, + if (val_len < PATH_MAX && strcmp(env_entry->val, "SCRIPT_NAME") == 0 && c->script_name[0] == '\0') { bcopy(buf, c->script_name, val_len); c->script_name[val_len] = '\0'; - } else if (val_len < MAXPATHLEN && strcmp(env_entry->val, + } else if (val_len < PATH_MAX && strcmp(env_entry->val, "SCRIPT_FILENAME") == 0) { bcopy(buf, c->script_name, val_len); c->script_name[val_len] = '\0'; diff --git a/usr.sbin/smtpd/ber.c b/usr.sbin/smtpd/ber.c index 58c134c88ee..be19f726939 100644 --- a/usr.sbin/smtpd/ber.c +++ b/usr.sbin/smtpd/ber.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ber.c,v 1.4 2013/12/26 17:25:32 eric Exp $ */ +/* $OpenBSD: ber.c,v 1.5 2015/01/16 06:40:20 deraadt Exp $ */ /* * Copyright (c) 2007 Reyk Floeter <reyk@vantronix.net> @@ -19,7 +19,6 @@ */ #include <sys/types.h> -#include <sys/param.h> #include <errno.h> #include <limits.h> @@ -32,6 +31,7 @@ #include "ber.h" +#define MINIMUM(a, b) (((a) < (b)) ? (a) : (b)) #define BER_TYPE_CONSTRUCTED 0x20 /* otherwise primitive */ #define BER_TYPE_SINGLE_MAX 30 @@ -1164,7 +1164,7 @@ ber_readbuf(struct ber *b, void *buf, size_t nbytes) return -1; sz = b->br_rend - b->br_rptr; - len = MIN(nbytes, sz); + len = MINIMUM(nbytes, sz); if (len == 0) { errno = ECANCELED; return (-1); /* end of buffer and parser wants more data */ diff --git a/usr.sbin/smtpd/ca.c b/usr.sbin/smtpd/ca.c index 11d691a688a..932cf8afee4 100644 --- a/usr.sbin/smtpd/ca.c +++ b/usr.sbin/smtpd/ca.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ca.c,v 1.12 2014/12/24 08:43:58 eric Exp $ */ +/* $OpenBSD: ca.c,v 1.13 2015/01/16 06:40:20 deraadt Exp $ */ /* * Copyright (c) 2014 Reyk Floeter <reyk@openbsd.org> @@ -23,6 +23,7 @@ #include <signal.h> #include <string.h> +#include <limits.h> #include <stdlib.h> #include <unistd.h> #include <imsg.h> diff --git a/usr.sbin/smtpd/config.c b/usr.sbin/smtpd/config.c index 6443e4506c6..cfb69093528 100644 --- a/usr.sbin/smtpd/config.c +++ b/usr.sbin/smtpd/config.c @@ -1,4 +1,4 @@ -/* $OpenBSD: config.c,v 1.31 2014/05/01 15:50:20 reyk Exp $ */ +/* $OpenBSD: config.c,v 1.32 2015/01/16 06:40:20 deraadt Exp $ */ /* * Copyright (c) 2008 Pierre-Yves Ritschard <pyr@openbsd.org> @@ -26,6 +26,7 @@ #include <imsg.h> #include <stdio.h> #include <stdlib.h> +#include <limits.h> #include <string.h> #include <unistd.h> diff --git a/usr.sbin/smtpd/envelope.c b/usr.sbin/smtpd/envelope.c index 9def08ed7f0..65dbef0d574 100644 --- a/usr.sbin/smtpd/envelope.c +++ b/usr.sbin/smtpd/envelope.c @@ -1,4 +1,4 @@ -/* $OpenBSD: envelope.c,v 1.29 2014/04/19 12:30:54 gilles Exp $ */ +/* $OpenBSD: envelope.c,v 1.30 2015/01/16 06:40:20 deraadt Exp $ */ /* * Copyright (c) 2013 Eric Faurot <eric@openbsd.org> @@ -35,6 +35,7 @@ #include <inttypes.h> #include <libgen.h> #include <pwd.h> +#include <limits.h> #include <stdio.h> #include <stdlib.h> #include <string.h> diff --git a/usr.sbin/smtpd/lka.c b/usr.sbin/smtpd/lka.c index d6c4664a910..82627c22778 100644 --- a/usr.sbin/smtpd/lka.c +++ b/usr.sbin/smtpd/lka.c @@ -1,4 +1,4 @@ -/* $OpenBSD: lka.c,v 1.173 2014/09/03 07:42:47 giovanni Exp $ */ +/* $OpenBSD: lka.c,v 1.174 2015/01/16 06:40:20 deraadt Exp $ */ /* * Copyright (c) 2008 Pierre-Yves Ritschard <pyr@openbsd.org> @@ -36,6 +36,7 @@ #include <openssl/ssl.h> #include <pwd.h> #include <resolv.h> +#include <limits.h> #include <signal.h> #include <stdio.h> #include <stdlib.h> diff --git a/usr.sbin/smtpd/makemap.c b/usr.sbin/smtpd/makemap.c index b3fdf3dcba5..f46260569da 100644 --- a/usr.sbin/smtpd/makemap.c +++ b/usr.sbin/smtpd/makemap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: makemap.c,v 1.50 2014/10/25 18:48:30 gilles Exp $ */ +/* $OpenBSD: makemap.c,v 1.51 2015/01/16 06:40:20 deraadt Exp $ */ /* * Copyright (c) 2008 Gilles Chehade <gilles@poolp.org> @@ -34,6 +34,7 @@ #include <stdlib.h> #include <string.h> #include <unistd.h> +#include <limits.h> #include <util.h> #include "smtpd.h" diff --git a/usr.sbin/smtpd/mproc.c b/usr.sbin/smtpd/mproc.c index c36775a6539..07333c2af8f 100644 --- a/usr.sbin/smtpd/mproc.c +++ b/usr.sbin/smtpd/mproc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mproc.c,v 1.10 2014/07/08 13:49:09 eric Exp $ */ +/* $OpenBSD: mproc.c,v 1.11 2015/01/16 06:40:20 deraadt Exp $ */ /* * Copyright (c) 2012 Eric Faurot <eric@faurot.net> @@ -32,6 +32,7 @@ #include <imsg.h> #include <stdio.h> #include <stdlib.h> +#include <limits.h> #include <string.h> #include <unistd.h> diff --git a/usr.sbin/smtpd/mta.c b/usr.sbin/smtpd/mta.c index a0973cb888b..fd7e789222f 100644 --- a/usr.sbin/smtpd/mta.c +++ b/usr.sbin/smtpd/mta.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mta.c,v 1.189 2014/07/08 13:02:42 eric Exp $ */ +/* $OpenBSD: mta.c,v 1.190 2015/01/16 06:40:20 deraadt Exp $ */ /* * Copyright (c) 2008 Pierre-Yves Ritschard <pyr@openbsd.org> @@ -31,6 +31,7 @@ #include <imsg.h> #include <inttypes.h> #include <netdb.h> +#include <limits.h> #include <pwd.h> #include <signal.h> #include <stdio.h> diff --git a/usr.sbin/smtpd/mta_session.c b/usr.sbin/smtpd/mta_session.c index ce8793490ca..507aab18003 100644 --- a/usr.sbin/smtpd/mta_session.c +++ b/usr.sbin/smtpd/mta_session.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mta_session.c,v 1.69 2014/12/24 13:51:31 eric Exp $ */ +/* $OpenBSD: mta_session.c,v 1.70 2015/01/16 06:40:20 deraadt Exp $ */ /* * Copyright (c) 2008 Pierre-Yves Ritschard <pyr@openbsd.org> @@ -35,6 +35,7 @@ #include <openssl/ssl.h> #include <pwd.h> #include <resolv.h> +#include <limits.h> #include <signal.h> #include <stdio.h> #include <stdlib.h> diff --git a/usr.sbin/smtpd/parse.y b/usr.sbin/smtpd/parse.y index c8ae7e6587b..5619d022fee 100644 --- a/usr.sbin/smtpd/parse.y +++ b/usr.sbin/smtpd/parse.y @@ -1,4 +1,4 @@ -/* $OpenBSD: parse.y,v 1.149 2014/11/20 05:51:21 jsg Exp $ */ +/* $OpenBSD: parse.y,v 1.150 2015/01/16 06:40:20 deraadt Exp $ */ /* * Copyright (c) 2008 Gilles Chehade <gilles@poolp.org> @@ -41,6 +41,7 @@ #include <imsg.h> #include <inttypes.h> #include <netdb.h> +#include <limits.h> #include <paths.h> #include <pwd.h> #include <stdio.h> @@ -772,7 +773,7 @@ main : BOUNCEWARN { } } filter_args; | PKI STRING { - char buf[MAXHOSTNAMELEN]; + char buf[HOST_NAME_MAX+1]; xlowercase(buf, $2, sizeof(buf)); free($2); pki = dict_get(conf->sc_pki_dict, buf); diff --git a/usr.sbin/smtpd/queue_backend.c b/usr.sbin/smtpd/queue_backend.c index 504e798391e..245e0d9fc03 100644 --- a/usr.sbin/smtpd/queue_backend.c +++ b/usr.sbin/smtpd/queue_backend.c @@ -1,4 +1,4 @@ -/* $OpenBSD: queue_backend.c,v 1.53 2014/12/08 08:19:36 gilles Exp $ */ +/* $OpenBSD: queue_backend.c,v 1.54 2015/01/16 06:40:21 deraadt Exp $ */ /* * Copyright (c) 2011 Gilles Chehade <gilles@poolp.org> @@ -28,6 +28,7 @@ #include <event.h> #include <fcntl.h> #include <imsg.h> +#include <limits.h> #include <inttypes.h> #include <libgen.h> #include <pwd.h> @@ -179,7 +180,7 @@ queue_message_create(uint32_t *msgid) int queue_message_delete(uint32_t msgid) { - char msgpath[MAXPATHLEN]; + char msgpath[PATH_MAX]; int r; profile_enter("queue_message_delete"); @@ -200,8 +201,8 @@ int queue_message_commit(uint32_t msgid) { int r; - char msgpath[MAXPATHLEN]; - char tmppath[MAXPATHLEN]; + char msgpath[PATH_MAX]; + char tmppath[PATH_MAX]; FILE *ifp = NULL; FILE *ofp = NULL; diff --git a/usr.sbin/smtpd/queue_fs.c b/usr.sbin/smtpd/queue_fs.c index 2541e00c085..25a7f17b404 100644 --- a/usr.sbin/smtpd/queue_fs.c +++ b/usr.sbin/smtpd/queue_fs.c @@ -1,4 +1,4 @@ -/* $OpenBSD: queue_fs.c,v 1.6 2014/07/08 15:45:32 eric Exp $ */ +/* $OpenBSD: queue_fs.c,v 1.7 2015/01/16 06:40:21 deraadt Exp $ */ /* * Copyright (c) 2011 Gilles Chehade <gilles@poolp.org> @@ -17,12 +17,11 @@ */ #include <sys/types.h> +#include <sys/mount.h> #include <sys/queue.h> #include <sys/tree.h> #include <sys/socket.h> #include <sys/stat.h> -#include <sys/param.h> -#include <sys/mount.h> #include <ctype.h> #include <err.h> diff --git a/usr.sbin/smtpd/queue_proc.c b/usr.sbin/smtpd/queue_proc.c index da321715e16..87de867831b 100644 --- a/usr.sbin/smtpd/queue_proc.c +++ b/usr.sbin/smtpd/queue_proc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: queue_proc.c,v 1.3 2014/07/08 15:45:32 eric Exp $ */ +/* $OpenBSD: queue_proc.c,v 1.4 2015/01/16 06:40:21 deraadt Exp $ */ /* * Copyright (c) 2013 Eric Faurot <eric@openbsd.org> @@ -19,7 +19,6 @@ #include <sys/types.h> #include <sys/queue.h> #include <sys/tree.h> -#include <sys/param.h> #include <sys/socket.h> #include <sys/stat.h> diff --git a/usr.sbin/smtpd/scheduler_proc.c b/usr.sbin/smtpd/scheduler_proc.c index 5dcc8ddc5d8..4db950f2273 100644 --- a/usr.sbin/smtpd/scheduler_proc.c +++ b/usr.sbin/smtpd/scheduler_proc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: scheduler_proc.c,v 1.5 2014/07/10 14:45:02 eric Exp $ */ +/* $OpenBSD: scheduler_proc.c,v 1.6 2015/01/16 06:40:21 deraadt Exp $ */ /* * Copyright (c) 2013 Eric Faurot <eric@openbsd.org> @@ -19,7 +19,6 @@ #include <sys/types.h> #include <sys/queue.h> #include <sys/tree.h> -#include <sys/param.h> #include <sys/socket.h> #include <ctype.h> diff --git a/usr.sbin/smtpd/smtp.c b/usr.sbin/smtpd/smtp.c index 2ebd932941c..9f120eed517 100644 --- a/usr.sbin/smtpd/smtp.c +++ b/usr.sbin/smtpd/smtp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: smtp.c,v 1.141 2014/11/05 19:38:09 gilles Exp $ */ +/* $OpenBSD: smtp.c,v 1.142 2015/01/16 06:40:21 deraadt Exp $ */ /* * Copyright (c) 2008 Gilles Chehade <gilles@poolp.org> @@ -30,6 +30,7 @@ #include <netdb.h> #include <pwd.h> #include <signal.h> +#include <limits.h> #include <stdio.h> #include <stdlib.h> #include <string.h> diff --git a/usr.sbin/smtpd/smtp_session.c b/usr.sbin/smtpd/smtp_session.c index 59a5f1b28fc..078a4d331e3 100644 --- a/usr.sbin/smtpd/smtp_session.c +++ b/usr.sbin/smtpd/smtp_session.c @@ -1,4 +1,4 @@ -/* $OpenBSD: smtp_session.c,v 1.225 2015/01/14 08:50:32 gilles Exp $ */ +/* $OpenBSD: smtp_session.c,v 1.226 2015/01/16 06:40:21 deraadt Exp $ */ /* * Copyright (c) 2008 Gilles Chehade <gilles@poolp.org> @@ -31,6 +31,7 @@ #include <errno.h> #include <event.h> #include <imsg.h> +#include <limits.h> #include <inttypes.h> #include <openssl/ssl.h> #include <resolv.h> diff --git a/usr.sbin/smtpd/smtpd.c b/usr.sbin/smtpd/smtpd.c index 9ba5fdfa0a3..36b2c6bb300 100644 --- a/usr.sbin/smtpd/smtpd.c +++ b/usr.sbin/smtpd/smtpd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: smtpd.c,v 1.236 2015/01/15 09:05:37 gilles Exp $ */ +/* $OpenBSD: smtpd.c,v 1.237 2015/01/16 06:40:21 deraadt Exp $ */ /* * Copyright (c) 2008 Gilles Chehade <gilles@poolp.org> @@ -40,6 +40,7 @@ #include <pwd.h> #include <signal.h> #include <stdio.h> +#include <limits.h> #include <stdlib.h> #include <string.h> #include <time.h> diff --git a/usr.sbin/smtpd/ssl_smtpd.c b/usr.sbin/smtpd/ssl_smtpd.c index d7181bda243..49c379a4273 100644 --- a/usr.sbin/smtpd/ssl_smtpd.c +++ b/usr.sbin/smtpd/ssl_smtpd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ssl_smtpd.c,v 1.7 2014/04/29 19:13:14 reyk Exp $ */ +/* $OpenBSD: ssl_smtpd.c,v 1.8 2015/01/16 06:40:21 deraadt Exp $ */ /* * Copyright (c) 2008 Pierre-Yves Ritschard <pyr@openbsd.org> @@ -27,6 +27,7 @@ #include <ctype.h> #include <event.h> #include <fcntl.h> +#include <limits.h> #include <imsg.h> #include <pwd.h> #include <stdio.h> diff --git a/usr.sbin/smtpd/table_passwd.c b/usr.sbin/smtpd/table_passwd.c index b290054cd4c..0da86673c45 100644 --- a/usr.sbin/smtpd/table_passwd.c +++ b/usr.sbin/smtpd/table_passwd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: table_passwd.c,v 1.8 2014/09/29 08:41:55 gilles Exp $ */ +/* $OpenBSD: table_passwd.c,v 1.9 2015/01/16 06:40:21 deraadt Exp $ */ /* * Copyright (c) 2013 Gilles Chehade <gilles@poolp.org> @@ -22,6 +22,7 @@ #include <pwd.h> #include <stdio.h> #include <stdlib.h> +#include <limits.h> #include <string.h> #include <unistd.h> diff --git a/usr.sbin/smtpd/table_proc.c b/usr.sbin/smtpd/table_proc.c index c968ccedc29..ed4e5dd8786 100644 --- a/usr.sbin/smtpd/table_proc.c +++ b/usr.sbin/smtpd/table_proc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: table_proc.c,v 1.3 2014/07/08 13:49:09 eric Exp $ */ +/* $OpenBSD: table_proc.c,v 1.4 2015/01/16 06:40:21 deraadt Exp $ */ /* * Copyright (c) 2013 Eric Faurot <eric@openbsd.org> @@ -19,7 +19,6 @@ #include <sys/types.h> #include <sys/queue.h> #include <sys/tree.h> -#include <sys/param.h> #include <sys/socket.h> #include <ctype.h> diff --git a/usr.sbin/smtpd/table_sqlite.c b/usr.sbin/smtpd/table_sqlite.c index 9ce3a2b0bf2..57e95939fe1 100644 --- a/usr.sbin/smtpd/table_sqlite.c +++ b/usr.sbin/smtpd/table_sqlite.c @@ -1,4 +1,4 @@ -/* $OpenBSD: table_sqlite.c,v 1.14 2014/07/08 13:49:09 eric Exp $ */ +/* $OpenBSD: table_sqlite.c,v 1.15 2015/01/16 06:40:21 deraadt Exp $ */ /* * Copyright (c) 2013 Eric Faurot <eric@openbsd.org> @@ -22,6 +22,7 @@ #include <fcntl.h> #include <sqlite3.h> #include <stdio.h> +#include <limits.h> #include <stdlib.h> #include <string.h> #include <time.h> diff --git a/usr.sbin/smtpd/to.c b/usr.sbin/smtpd/to.c index 51a3cabab7a..2ac22b523a5 100644 --- a/usr.sbin/smtpd/to.c +++ b/usr.sbin/smtpd/to.c @@ -1,4 +1,4 @@ -/* $OpenBSD: to.c,v 1.17 2014/04/19 14:27:29 gilles Exp $ */ +/* $OpenBSD: to.c,v 1.18 2015/01/16 06:40:21 deraadt Exp $ */ /* * Copyright (c) 2009 Jacek Masiulaniec <jacekm@dobremiasto.net> @@ -35,6 +35,7 @@ #include <fcntl.h> #include <fts.h> #include <imsg.h> +#include <limits.h> #include <inttypes.h> #include <libgen.h> #include <netdb.h> diff --git a/usr.sbin/smtpd/util.c b/usr.sbin/smtpd/util.c index a6c619891c6..9f8c86c97e8 100644 --- a/usr.sbin/smtpd/util.c +++ b/usr.sbin/smtpd/util.c @@ -1,4 +1,4 @@ -/* $OpenBSD: util.c,v 1.110 2014/05/25 10:55:36 espie Exp $ */ +/* $OpenBSD: util.c,v 1.111 2015/01/16 06:40:21 deraadt Exp $ */ /* * Copyright (c) 2000,2001 Markus Friedl. All rights reserved. @@ -39,6 +39,7 @@ #include <libgen.h> #include <netdb.h> #include <pwd.h> +#include <limits.h> #include <resolv.h> #include <stdarg.h> #include <stdio.h> diff --git a/usr.sbin/snmpctl/snmpclient.c b/usr.sbin/snmpctl/snmpclient.c index 6254e24260c..b62128fa99f 100644 --- a/usr.sbin/snmpctl/snmpclient.c +++ b/usr.sbin/snmpctl/snmpclient.c @@ -1,4 +1,4 @@ -/* $OpenBSD: snmpclient.c,v 1.12 2014/11/18 20:54:29 krw Exp $ */ +/* $OpenBSD: snmpclient.c,v 1.13 2015/01/16 06:40:21 deraadt Exp $ */ /* * Copyright (c) 2013 Reyk Floeter <reyk@openbsd.org> @@ -17,7 +17,6 @@ */ #include <sys/queue.h> -#include <sys/param.h> #include <sys/types.h> #include <sys/stat.h> #include <sys/socket.h> diff --git a/usr.sbin/syslogd/privsep.c b/usr.sbin/syslogd/privsep.c index b69d687c087..9e527943a41 100644 --- a/usr.sbin/syslogd/privsep.c +++ b/usr.sbin/syslogd/privsep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: privsep.c,v 1.49 2014/12/31 13:55:57 bluhm Exp $ */ +/* $OpenBSD: privsep.c,v 1.50 2015/01/16 06:40:21 deraadt Exp $ */ /* * Copyright (c) 2003 Anil Madhavapeddy <anil@recoil.org> @@ -15,8 +15,8 @@ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ + #include <sys/ioctl.h> -#include <sys/param.h> #include <sys/queue.h> #include <sys/uio.h> #include <sys/types.h> @@ -37,6 +37,7 @@ #include <unistd.h> #include <util.h> #include <utmp.h> +#include <limits.h> #include "syslogd.h" /* @@ -74,14 +75,14 @@ enum cmd_types { static int priv_fd = -1; static volatile pid_t child_pid = -1; -static char config_file[MAXPATHLEN]; +static char config_file[PATH_MAX]; static struct stat cf_info; static int allow_getnameinfo = 0; static volatile sig_atomic_t cur_state = STATE_INIT; /* Queue for the allowed logfiles */ struct logname { - char path[MAXPATHLEN]; + char path[PATH_MAX]; TAILQ_ENTRY(logname) next; }; static TAILQ_HEAD(, logname) lognames; @@ -102,7 +103,7 @@ priv_init(char *conf, int numeric, int lockfd, int nullfd, char *argv[]) { int i, fd, socks[2], cmd, addr_len, result, restart; size_t path_len, protoname_len, hostname_len, servname_len; - char path[MAXPATHLEN], protoname[5], hostname[MAXHOSTNAMELEN]; + char path[PATH_MAX], protoname[5], hostname[HOST_NAME_MAX+1]; char servname[NI_MAXSERV]; struct sockaddr_storage addr; struct stat cf_stat; @@ -527,7 +528,7 @@ check_log_name(char *lognam, size_t logsize) lg = malloc(sizeof(struct logname)); if (!lg) err(1, "check_log_name() malloc"); - strlcpy(lg->path, lognam, MAXPATHLEN); + strlcpy(lg->path, lognam, PATH_MAX); TAILQ_INSERT_TAIL(&lognames, lg, next); break; case STATE_RUNNING: @@ -564,7 +565,7 @@ increase_state(int state) int priv_open_tty(const char *tty) { - char path[MAXPATHLEN]; + char path[PATH_MAX]; int cmd, fd; size_t path_len; @@ -587,7 +588,7 @@ priv_open_tty(const char *tty) int priv_open_log(const char *lognam) { - char path[MAXPATHLEN]; + char path[PATH_MAX]; int cmd, fd; size_t path_len; @@ -698,7 +699,7 @@ int priv_getaddrinfo(char *proto, char *host, char *serv, struct sockaddr *addr, size_t addr_len) { - char protocpy[5], hostcpy[MAXHOSTNAMELEN], servcpy[NI_MAXSERV]; + char protocpy[5], hostcpy[HOST_NAME_MAX+1], servcpy[NI_MAXSERV]; int cmd, ret_len; size_t protoname_len, hostname_len, servname_len; diff --git a/usr.sbin/syslogd/privsep_fdpass.c b/usr.sbin/syslogd/privsep_fdpass.c index 6984929fa9e..4ae2ee272fd 100644 --- a/usr.sbin/syslogd/privsep_fdpass.c +++ b/usr.sbin/syslogd/privsep_fdpass.c @@ -1,4 +1,4 @@ -/* $OpenBSD: privsep_fdpass.c,v 1.8 2012/04/04 17:24:50 deraadt Exp $ */ +/* $OpenBSD: privsep_fdpass.c,v 1.9 2015/01/16 06:40:21 deraadt Exp $ */ /* * Copyright 2001 Niels Provos <provos@citi.umich.edu> @@ -31,7 +31,7 @@ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ -#include <sys/param.h> + #include <sys/uio.h> #include <sys/types.h> #include <sys/socket.h> diff --git a/usr.sbin/syslogd/ringbuf.c b/usr.sbin/syslogd/ringbuf.c index 80f06fe603d..1af7d7d6fa0 100644 --- a/usr.sbin/syslogd/ringbuf.c +++ b/usr.sbin/syslogd/ringbuf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ringbuf.c,v 1.7 2005/09/21 23:25:32 djm Exp $ */ +/* $OpenBSD: ringbuf.c,v 1.8 2015/01/16 06:40:21 deraadt Exp $ */ /* * Copyright (c) 2004 Damien Miller @@ -21,13 +21,14 @@ */ #include <sys/types.h> -#include <sys/param.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include "syslogd.h" +#define MINIMUM(a, b) (((a) < (b)) ? (a) : (b)) + /* Initialise a ring buffer */ struct ringbuf * ringbuf_init(size_t len) @@ -141,7 +142,7 @@ ringbuf_to_string(char *buf, size_t len, struct ringbuf *rb) if (buf == NULL || rb == NULL || len == 0) return (-1); - copy_len = MIN(len - 1, ringbuf_used(rb)); + copy_len = MINIMUM(len - 1, ringbuf_used(rb)); if (copy_len == 0) return (copy_len); @@ -151,9 +152,9 @@ ringbuf_to_string(char *buf, size_t len, struct ringbuf *rb) else { /* If the buffer is wrapped, copy each hunk separately */ n = rb->len - rb->start; - memcpy(buf, rb->buf + rb->start, MIN(n, copy_len)); + memcpy(buf, rb->buf + rb->start, MINIMUM(n, copy_len)); if (copy_len > n) - memcpy(buf + n, rb->buf, MIN(rb->end, copy_len - n)); + memcpy(buf + n, rb->buf, MINIMUM(rb->end, copy_len - n)); } buf[copy_len] = '\0'; diff --git a/usr.sbin/syslogd/syslogd.c b/usr.sbin/syslogd/syslogd.c index d70fd9f6a2a..c94936e342d 100644 --- a/usr.sbin/syslogd/syslogd.c +++ b/usr.sbin/syslogd/syslogd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: syslogd.c,v 1.141 2015/01/15 11:49:59 bluhm Exp $ */ +/* $OpenBSD: syslogd.c,v 1.142 2015/01/16 06:40:21 deraadt Exp $ */ /* * Copyright (c) 1983, 1988, 1993, 1994 @@ -64,7 +64,6 @@ #define TIMERINTVL 30 /* interval for checking flush, mark */ #define TTYMSGTIME 1 /* timeout passed to ttymsg */ -#include <sys/param.h> #include <sys/ioctl.h> #include <sys/stat.h> #include <sys/wait.h> @@ -93,9 +92,12 @@ #include <stdlib.h> #include <string.h> #include <unistd.h> +#include <limits.h> #include <utmp.h> #include <vis.h> +#define MAXIMUM(a, b) (((a) > (b)) ? (a) : (b)) + #define SYSLOG_NAMES #include <sys/syslog.h> @@ -131,13 +133,13 @@ struct filed { union { char f_uname[MAXUNAMES][UT_NAMESIZE+1]; struct { - char f_loghost[1+4+3+1+MAXHOSTNAMELEN+1+NI_MAXSERV]; + char f_loghost[1+4+3+1+HOST_NAME_MAX+1+1+NI_MAXSERV]; /* @proto46://[hostname]:servname\0 */ struct sockaddr_storage f_addr; struct bufferevent *f_bufev; int f_reconnectwait; } f_forw; /* forwarding address */ - char f_fname[MAXPATHLEN]; + char f_fname[PATH_MAX]; struct { char f_mname[MAX_MEMBUF_NAME]; struct ringbuf *f_rb; @@ -148,7 +150,7 @@ struct filed { } f_un; char f_prevline[MAXSVLINE]; /* last message logged */ char f_lasttime[16]; /* time of last occurrence */ - char f_prevhost[MAXHOSTNAMELEN]; /* host from which recd. */ + char f_prevhost[HOST_NAME_MAX+1]; /* host from which recd. */ int f_prevpri; /* pri of f_prevline */ int f_prevlen; /* length of f_prevline */ int f_prevcount; /* repetition cnt of prevline */ @@ -194,7 +196,7 @@ int nunix = 1; /* Number of Unix domain sockets requested */ char *path_unix[MAXUNIX] = { _PATH_LOG }; /* Paths to Unix domain sockets */ int Debug; /* debug flag */ int Startup = 1; /* startup flag */ -char LocalHostName[MAXHOSTNAMELEN]; /* our hostname */ +char LocalHostName[HOST_NAME_MAX+1]; /* our hostname */ char *LocalDomain; /* our local domain name */ int Initialized = 0; /* set when we have initialized ourselves */ @@ -645,7 +647,7 @@ udp_readcb(int fd, short event, void *arg) salen = sizeof(sa); n = recvfrom(fd, linebuf, MAXLINE, 0, (struct sockaddr *)&sa, &salen); if (n > 0) { - char resolve[MAXHOSTNAMELEN]; + char resolve[HOST_NAME_MAX+1]; linebuf[n] = '\0'; cvthname((struct sockaddr *)&sa, resolve, sizeof(resolve)); @@ -1740,7 +1742,7 @@ cfline(char *line, char *prog) logerror(ebuf); break; } - if (strlen(host) >= MAXHOSTNAMELEN) { + if (strlen(host) >= HOST_NAME_MAX+1) { snprintf(ebuf, sizeof(ebuf), "host too long \"%s\"", f->f_un.f_forw.f_loghost); logerror(ebuf); @@ -1864,7 +1866,7 @@ cfline(char *line, char *prog) } /* Set buffer length */ - rb_len = MAX(rb_len, MIN_MEMBUF); + rb_len = MAXIMUM(rb_len, MIN_MEMBUF); f->f_un.f_mb.f_len = rb_len; f->f_un.f_mb.f_overflow = 0; f->f_un.f_mb.f_attached = 0; diff --git a/usr.sbin/syslogd/ttymsg.c b/usr.sbin/syslogd/ttymsg.c index 25313f3e08a..a611218cedd 100644 --- a/usr.sbin/syslogd/ttymsg.c +++ b/usr.sbin/syslogd/ttymsg.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ttymsg.c,v 1.5 2014/08/25 18:05:30 bluhm Exp $ */ +/* $OpenBSD: ttymsg.c,v 1.6 2015/01/16 06:40:21 deraadt Exp $ */ /* $NetBSD: ttymsg.c,v 1.3 1994/11/17 07:17:55 jtc Exp $ */ /* @@ -30,7 +30,7 @@ * SUCH DAMAGE. */ -#include <sys/param.h> +#include <sys/param.h> /* nitems */ #include <sys/stat.h> #include <sys/types.h> #include <sys/uio.h> diff --git a/usr.sbin/tcpdrop/tcpdrop.c b/usr.sbin/tcpdrop/tcpdrop.c index 0520ea34d62..4f41dd9a61b 100644 --- a/usr.sbin/tcpdrop/tcpdrop.c +++ b/usr.sbin/tcpdrop/tcpdrop.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tcpdrop.c,v 1.16 2015/01/13 03:43:18 lteo Exp $ */ +/* $OpenBSD: tcpdrop.c,v 1.17 2015/01/16 06:40:21 deraadt Exp $ */ /* * Copyright (c) 2004 Markus Friedl <markus@openbsd.org> @@ -16,7 +16,6 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#include <sys/param.h> #include <sys/socket.h> #include <sys/sysctl.h> #include <sys/queue.h> diff --git a/usr.sbin/tcpdump/addrtoname.c b/usr.sbin/tcpdump/addrtoname.c index 72f44e640d3..fb87a9fc9f3 100644 --- a/usr.sbin/tcpdump/addrtoname.c +++ b/usr.sbin/tcpdump/addrtoname.c @@ -1,4 +1,4 @@ -/* $OpenBSD: addrtoname.c,v 1.32 2014/10/08 04:58:50 deraadt Exp $ */ +/* $OpenBSD: addrtoname.c,v 1.33 2015/01/16 06:40:21 deraadt Exp $ */ /* * Copyright (c) 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997 @@ -24,7 +24,6 @@ * and address to string conversion routines */ -#include <sys/param.h> #include <sys/socket.h> #include <sys/time.h> #include <sys/types.h> @@ -55,6 +54,7 @@ struct rtentry; #include <string.h> #include <stdlib.h> #include <unistd.h> +#include <limits.h> #include "interface.h" #include "addrtoname.h" @@ -159,7 +159,7 @@ static u_int32_t netmask; char * getname(const u_char *ap) { - char host[MAXHOSTNAMELEN]; + char host[HOST_NAME_MAX+1]; u_int32_t addr; struct hnamemem *p; @@ -245,7 +245,7 @@ getname(const u_char *ap) char * getname6(const u_char *ap) { - char host[MAXHOSTNAMELEN]; + char host[HOST_NAME_MAX+1]; struct in6_addr addr; struct h6namemem *p; register char *cp; @@ -460,7 +460,7 @@ etheraddr_string(register const u_char *ep) return (tp->e_name); #ifdef HAVE_ETHER_NTOHOST if (!nflag) { - char buf[MAXHOSTNAMELEN + 1]; + char buf[HOST_NAME_MAX+1 + 1]; if (priv_ether_ntohost(buf, sizeof(buf), (struct ether_addr *)ep) > 0) { tp->e_name = savestr(buf); @@ -770,7 +770,7 @@ init_etherarray(void) register struct etherlist *el; register struct enamemem *tp; #ifdef HAVE_ETHER_NTOHOST - char name[MAXHOSTNAMELEN + 1]; + char name[HOST_NAME_MAX+1 + 1]; #else register struct pcap_etherent *ep; register FILE *fp; diff --git a/usr.sbin/tcpdump/print-802_11.c b/usr.sbin/tcpdump/print-802_11.c index e7a73af1b91..5f81f45ebca 100644 --- a/usr.sbin/tcpdump/print-802_11.c +++ b/usr.sbin/tcpdump/print-802_11.c @@ -1,4 +1,4 @@ -/* $OpenBSD: print-802_11.c,v 1.15 2014/08/14 12:44:44 mpi Exp $ */ +/* $OpenBSD: print-802_11.c,v 1.16 2015/01/16 06:40:21 deraadt Exp $ */ /* * Copyright (c) 2005 Reyk Floeter <reyk@openbsd.org> @@ -16,7 +16,6 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#include <sys/param.h> #include <sys/time.h> #include <sys/socket.h> #include <sys/file.h> diff --git a/usr.sbin/tcpdump/print-arp.c b/usr.sbin/tcpdump/print-arp.c index 1f1c5123dce..4d4b97ffeea 100644 --- a/usr.sbin/tcpdump/print-arp.c +++ b/usr.sbin/tcpdump/print-arp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: print-arp.c,v 1.12 2009/10/27 23:59:55 deraadt Exp $ */ +/* $OpenBSD: print-arp.c,v 1.13 2015/01/16 06:40:21 deraadt Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997 @@ -21,7 +21,6 @@ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ -#include <sys/param.h> #include <sys/time.h> #include <sys/socket.h> diff --git a/usr.sbin/tcpdump/print-atalk.c b/usr.sbin/tcpdump/print-atalk.c index d8639b57ba4..513267660be 100644 --- a/usr.sbin/tcpdump/print-atalk.c +++ b/usr.sbin/tcpdump/print-atalk.c @@ -1,4 +1,4 @@ -/* $OpenBSD: print-atalk.c,v 1.27 2014/08/14 12:44:44 mpi Exp $ */ +/* $OpenBSD: print-atalk.c,v 1.28 2015/01/16 06:40:21 deraadt Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997 @@ -23,7 +23,6 @@ * Format and print AppleTalk packets. */ -#include <sys/param.h> #include <sys/time.h> #include <sys/socket.h> @@ -43,6 +42,7 @@ struct rtentry; #include <stdio.h> #include <stdlib.h> #include <string.h> +#include <limits.h> #include "interface.h" #include "addrtoname.h" @@ -556,7 +556,7 @@ static void init_atalk(void) { struct hnamemem *tp; - char nambuf[MAXHOSTNAMELEN + 20]; + char nambuf[HOST_NAME_MAX+1 + 20]; char line[BUFSIZ]; int i1, i2, i3; @@ -587,7 +587,7 @@ ataddr_string(u_short atnet, u_char athost) { register struct hnamemem *tp, *tp2; register int i = (atnet << 8) | athost; - char nambuf[MAXHOSTNAMELEN + 20]; + char nambuf[HOST_NAME_MAX+1 + 20]; static int first = 1; if (first) { diff --git a/usr.sbin/tcpdump/print-atm.c b/usr.sbin/tcpdump/print-atm.c index 469cf7a2692..f9b1fdb94e8 100644 --- a/usr.sbin/tcpdump/print-atm.c +++ b/usr.sbin/tcpdump/print-atm.c @@ -1,4 +1,4 @@ -/* $OpenBSD: print-atm.c,v 1.11 2014/11/20 04:11:33 jsg Exp $ */ +/* $OpenBSD: print-atm.c,v 1.12 2015/01/16 06:40:21 deraadt Exp $ */ /* * Copyright (c) 1994, 1995, 1996, 1997 @@ -21,7 +21,6 @@ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ -#include <sys/param.h> #include <sys/time.h> #include <sys/socket.h> diff --git a/usr.sbin/tcpdump/print-bgp.c b/usr.sbin/tcpdump/print-bgp.c index 61b86c8ebc0..6d8ffa9ea6c 100644 --- a/usr.sbin/tcpdump/print-bgp.c +++ b/usr.sbin/tcpdump/print-bgp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: print-bgp.c,v 1.16 2014/01/12 11:26:48 deraadt Exp $ */ +/* $OpenBSD: print-bgp.c,v 1.17 2015/01/16 06:40:21 deraadt Exp $ */ /* * Copyright (C) 1999 WIDE Project. @@ -29,7 +29,6 @@ * SUCH DAMAGE. */ -#include <sys/param.h> #include <sys/time.h> #include <sys/types.h> #include <sys/socket.h> @@ -40,6 +39,7 @@ #include <stdio.h> #include <string.h> #include <netdb.h> +#include <limits.h> #include "interface.h" #include "addrtoname.h" @@ -409,7 +409,7 @@ bgp_attr_print(const struct bgp_attr *attr, const u_char *dat, int len) int advance; int tlen, asn_bytes; const u_char *p; - char buf[MAXHOSTNAMELEN + 100]; + char buf[HOST_NAME_MAX+1 + 100]; p = dat; tlen = len; @@ -868,7 +868,7 @@ bgp_update_print(const u_char *dat, int length) #ifdef INET6 printf(" (Withdrawn routes: %d bytes)", len); #else - char buf[MAXHOSTNAMELEN + 100]; + char buf[HOST_NAME_MAX+1 + 100]; int wpfx; TCHECK2(p[2], len); @@ -949,7 +949,7 @@ bgp_update_print(const u_char *dat, int length) if (dat + length > p) { printf("(NLRI:"); /* ) */ while (dat + length > p) { - char buf[MAXHOSTNAMELEN + 100]; + char buf[HOST_NAME_MAX+1 + 100]; i = decode_prefix4(p, buf, sizeof(buf)); if (i == -1) { printf(" (illegal prefix length)"); diff --git a/usr.sbin/tcpdump/print-bootp.c b/usr.sbin/tcpdump/print-bootp.c index f7fdfd73ddc..a130b0e3b79 100644 --- a/usr.sbin/tcpdump/print-bootp.c +++ b/usr.sbin/tcpdump/print-bootp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: print-bootp.c,v 1.18 2013/10/27 18:49:25 guenther Exp $ */ +/* $OpenBSD: print-bootp.c,v 1.19 2015/01/16 06:40:21 deraadt Exp $ */ /* * Copyright (c) 1990, 1991, 1993, 1994, 1995, 1996, 1997 @@ -22,7 +22,6 @@ * * Format and print bootp packets. */ -#include <sys/param.h> #include <sys/time.h> #include <sys/socket.h> diff --git a/usr.sbin/tcpdump/print-cdp.c b/usr.sbin/tcpdump/print-cdp.c index bfb20b0db6c..9af884697b0 100644 --- a/usr.sbin/tcpdump/print-cdp.c +++ b/usr.sbin/tcpdump/print-cdp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: print-cdp.c,v 1.4 2009/10/27 23:59:55 deraadt Exp $ */ +/* $OpenBSD: print-cdp.c,v 1.5 2015/01/16 06:40:21 deraadt Exp $ */ /* * Copyright (c) 1992, 1993, 1994, 1995, 1996, 1997 @@ -26,7 +26,6 @@ * http://www.cisco.com/univercd/cc/td/doc/product/lan/trsrb/frames.htm */ -#include <sys/param.h> #include <sys/time.h> #include <netinet/in.h> diff --git a/usr.sbin/tcpdump/print-decnet.c b/usr.sbin/tcpdump/print-decnet.c index 8615abff887..6e47c8d7508 100644 --- a/usr.sbin/tcpdump/print-decnet.c +++ b/usr.sbin/tcpdump/print-decnet.c @@ -1,4 +1,4 @@ -/* $OpenBSD: print-decnet.c,v 1.12 2009/10/27 23:59:55 deraadt Exp $ */ +/* $OpenBSD: print-decnet.c,v 1.13 2015/01/16 06:40:21 deraadt Exp $ */ /* * Copyright (c) 1992, 1993, 1994, 1995, 1996, 1997 @@ -21,7 +21,6 @@ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ -#include <sys/param.h> #include <sys/time.h> #include <sys/socket.h> diff --git a/usr.sbin/tcpdump/print-dhcp6.c b/usr.sbin/tcpdump/print-dhcp6.c index 3546b6c9ac5..fd111244c17 100644 --- a/usr.sbin/tcpdump/print-dhcp6.c +++ b/usr.sbin/tcpdump/print-dhcp6.c @@ -1,4 +1,4 @@ -/* $OpenBSD: print-dhcp6.c,v 1.7 2009/10/27 23:59:55 deraadt Exp $ */ +/* $OpenBSD: print-dhcp6.c,v 1.8 2015/01/16 06:40:21 deraadt Exp $ */ /* * Copyright (C) 1998 and 1999 WIDE Project. @@ -31,7 +31,6 @@ #ifdef INET6 -#include <sys/param.h> #include <sys/time.h> #include <sys/socket.h> diff --git a/usr.sbin/tcpdump/print-domain.c b/usr.sbin/tcpdump/print-domain.c index 8516e8f7fbe..211fc3a2b31 100644 --- a/usr.sbin/tcpdump/print-domain.c +++ b/usr.sbin/tcpdump/print-domain.c @@ -1,4 +1,4 @@ -/* $OpenBSD: print-domain.c,v 1.20 2014/08/14 12:44:44 mpi Exp $ */ +/* $OpenBSD: print-domain.c,v 1.21 2015/01/16 06:40:21 deraadt Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997 @@ -21,7 +21,6 @@ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ -#include <sys/param.h> #include <sys/time.h> #include <sys/socket.h> diff --git a/usr.sbin/tcpdump/print-dvmrp.c b/usr.sbin/tcpdump/print-dvmrp.c index 9ea358486c6..4d841278831 100644 --- a/usr.sbin/tcpdump/print-dvmrp.c +++ b/usr.sbin/tcpdump/print-dvmrp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: print-dvmrp.c,v 1.7 2014/08/14 12:44:44 mpi Exp $ */ +/* $OpenBSD: print-dvmrp.c,v 1.8 2015/01/16 06:40:21 deraadt Exp $ */ /* * Copyright (c) 1995, 1996 @@ -21,7 +21,6 @@ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ -#include <sys/param.h> #include <sys/time.h> #include <sys/socket.h> diff --git a/usr.sbin/tcpdump/print-enc.c b/usr.sbin/tcpdump/print-enc.c index 774857a0288..d2b64e26fe5 100644 --- a/usr.sbin/tcpdump/print-enc.c +++ b/usr.sbin/tcpdump/print-enc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: print-enc.c,v 1.12 2014/08/14 12:44:44 mpi Exp $ */ +/* $OpenBSD: print-enc.c,v 1.13 2015/01/16 06:40:21 deraadt Exp $ */ /* * Copyright (c) 1990, 1991, 1993, 1994, 1995, 1996 @@ -21,7 +21,7 @@ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ -#include <sys/param.h> +#include <sys/param.h> /* MSIZE */ #include <sys/time.h> #include <sys/socket.h> #include <sys/file.h> diff --git a/usr.sbin/tcpdump/print-ether.c b/usr.sbin/tcpdump/print-ether.c index 3dea6e7f810..cffb77562b7 100644 --- a/usr.sbin/tcpdump/print-ether.c +++ b/usr.sbin/tcpdump/print-ether.c @@ -1,4 +1,4 @@ -/* $OpenBSD: print-ether.c,v 1.28 2014/08/14 12:44:44 mpi Exp $ */ +/* $OpenBSD: print-ether.c,v 1.29 2015/01/16 06:40:21 deraadt Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997 @@ -21,7 +21,6 @@ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ -#include <sys/param.h> #include <sys/time.h> #include <sys/socket.h> diff --git a/usr.sbin/tcpdump/print-etherip.c b/usr.sbin/tcpdump/print-etherip.c index 79327d637b7..640bdebac8e 100644 --- a/usr.sbin/tcpdump/print-etherip.c +++ b/usr.sbin/tcpdump/print-etherip.c @@ -1,4 +1,4 @@ -/* $OpenBSD: print-etherip.c,v 1.7 2014/08/14 12:44:44 mpi Exp $ */ +/* $OpenBSD: print-etherip.c,v 1.8 2015/01/16 06:40:21 deraadt Exp $ */ /* * Copyright (c) 2001 Jason L. Wright (jason@thought.net) @@ -30,7 +30,6 @@ * Format and print etherip packets */ -#include <sys/param.h> #include <sys/time.h> #include <sys/socket.h> diff --git a/usr.sbin/tcpdump/print-fddi.c b/usr.sbin/tcpdump/print-fddi.c index df80e6e1bbf..baa1597107a 100644 --- a/usr.sbin/tcpdump/print-fddi.c +++ b/usr.sbin/tcpdump/print-fddi.c @@ -1,4 +1,4 @@ -/* $OpenBSD: print-fddi.c,v 1.15 2014/08/14 12:44:44 mpi Exp $ */ +/* $OpenBSD: print-fddi.c,v 1.16 2015/01/16 06:40:21 deraadt Exp $ */ /* * Copyright (c) 1991, 1992, 1993, 1994, 1995, 1996, 1997 @@ -22,7 +22,6 @@ */ #ifdef HAVE_FDDI -#include <sys/param.h> #include <sys/time.h> #include <sys/socket.h> #include <sys/file.h> diff --git a/usr.sbin/tcpdump/print-frag6.c b/usr.sbin/tcpdump/print-frag6.c index 074999fc8c2..be4c4a464d1 100644 --- a/usr.sbin/tcpdump/print-frag6.c +++ b/usr.sbin/tcpdump/print-frag6.c @@ -1,4 +1,4 @@ -/* $OpenBSD: print-frag6.c,v 1.6 2014/08/14 12:44:44 mpi Exp $ */ +/* $OpenBSD: print-frag6.c,v 1.7 2015/01/16 06:40:21 deraadt Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1991, 1993, 1994 @@ -23,7 +23,6 @@ #ifdef INET6 -#include <sys/param.h> #include <sys/time.h> #include <sys/types.h> #include <sys/socket.h> diff --git a/usr.sbin/tcpdump/print-gre.c b/usr.sbin/tcpdump/print-gre.c index b89d5baaa3b..d88822bbefb 100644 --- a/usr.sbin/tcpdump/print-gre.c +++ b/usr.sbin/tcpdump/print-gre.c @@ -1,4 +1,4 @@ -/* $OpenBSD: print-gre.c,v 1.8 2014/08/14 12:44:44 mpi Exp $ */ +/* $OpenBSD: print-gre.c,v 1.9 2015/01/16 06:40:21 deraadt Exp $ */ /* * Copyright (c) 2002 Jason L. Wright (jason@thought.net) @@ -31,7 +31,6 @@ * RFC1701 (GRE), RFC1702 (GRE IPv4), and RFC2637 (Enhanced GRE) */ -#include <sys/param.h> #include <sys/time.h> #include <sys/uio.h> #include <sys/socket.h> diff --git a/usr.sbin/tcpdump/print-gtp.c b/usr.sbin/tcpdump/print-gtp.c index 55882d4c439..e977719b849 100644 --- a/usr.sbin/tcpdump/print-gtp.c +++ b/usr.sbin/tcpdump/print-gtp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: print-gtp.c,v 1.6 2014/08/14 12:44:44 mpi Exp $ */ +/* $OpenBSD: print-gtp.c,v 1.7 2015/01/16 06:40:21 deraadt Exp $ */ /* * Copyright (c) 2009, 2010 Joel Sing <jsing@openbsd.org> * @@ -40,7 +40,6 @@ * 3GPP TS 32.295 - Charging Data Record (CDR) transfer (GTPv1') */ -#include <sys/param.h> #include <sys/time.h> #include <sys/socket.h> #include <sys/types.h> diff --git a/usr.sbin/tcpdump/print-iapp.c b/usr.sbin/tcpdump/print-iapp.c index 7bafd9d990f..614a917c4ce 100644 --- a/usr.sbin/tcpdump/print-iapp.c +++ b/usr.sbin/tcpdump/print-iapp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: print-iapp.c,v 1.4 2014/08/14 12:44:44 mpi Exp $ */ +/* $OpenBSD: print-iapp.c,v 1.5 2015/01/16 06:40:21 deraadt Exp $ */ /* * Copyright (c) 2005 Reyk Floeter <reyk@openbsd.org> @@ -16,7 +16,6 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#include <sys/param.h> #include <sys/time.h> #include <sys/socket.h> #include <sys/file.h> diff --git a/usr.sbin/tcpdump/print-icmp.c b/usr.sbin/tcpdump/print-icmp.c index a693aea3c42..fe967c5088b 100644 --- a/usr.sbin/tcpdump/print-icmp.c +++ b/usr.sbin/tcpdump/print-icmp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: print-icmp.c,v 1.24 2014/08/14 12:44:44 mpi Exp $ */ +/* $OpenBSD: print-icmp.c,v 1.25 2015/01/16 06:40:21 deraadt Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1991, 1993, 1994, 1995, 1996 @@ -21,7 +21,6 @@ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ -#include <sys/param.h> #include <sys/time.h> #include <sys/socket.h> @@ -40,6 +39,7 @@ struct rtentry; #include <stdio.h> #include <string.h> +#include <limits.h> #include "interface.h" #include "addrtoname.h" @@ -171,8 +171,8 @@ icmp_print(const u_char *bp, u_int length, const u_char *bp2) const struct ip *oip; const struct udphdr *ouh; u_int hlen, dport, mtu; - char buf[MAXHOSTNAMELEN+256]; - char buf2[MAXHOSTNAMELEN+256]; + char buf[HOST_NAME_MAX+1+256]; + char buf2[HOST_NAME_MAX+1+256]; dp = (struct icmp *)bp; ip = (struct ip *)bp2; diff --git a/usr.sbin/tcpdump/print-icmp6.c b/usr.sbin/tcpdump/print-icmp6.c index 7ac3e4a3aab..e80a4af6171 100644 --- a/usr.sbin/tcpdump/print-icmp6.c +++ b/usr.sbin/tcpdump/print-icmp6.c @@ -1,4 +1,4 @@ -/* $OpenBSD: print-icmp6.c,v 1.14 2014/08/14 12:44:44 mpi Exp $ */ +/* $OpenBSD: print-icmp6.c,v 1.15 2015/01/16 06:40:21 deraadt Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1991, 1993, 1994 @@ -25,7 +25,6 @@ #include <ctype.h> -#include <sys/param.h> #include <sys/time.h> #include <sys/types.h> #include <sys/socket.h> diff --git a/usr.sbin/tcpdump/print-igrp.c b/usr.sbin/tcpdump/print-igrp.c index c463bfbcb8c..636e3dafcd8 100644 --- a/usr.sbin/tcpdump/print-igrp.c +++ b/usr.sbin/tcpdump/print-igrp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: print-igrp.c,v 1.6 2014/08/14 12:44:44 mpi Exp $ */ +/* $OpenBSD: print-igrp.c,v 1.7 2015/01/16 06:40:21 deraadt Exp $ */ /* * Copyright (c) 1996, 1997 @@ -23,7 +23,6 @@ * Initial contribution from Francis Dupont (francis.dupont@inria.fr) */ -#include <sys/param.h> #include <sys/types.h> /* concession to AIX */ #include <sys/socket.h> diff --git a/usr.sbin/tcpdump/print-ike.c b/usr.sbin/tcpdump/print-ike.c index 6490c06b952..94175355906 100644 --- a/usr.sbin/tcpdump/print-ike.c +++ b/usr.sbin/tcpdump/print-ike.c @@ -1,4 +1,4 @@ -/* $OpenBSD: print-ike.c,v 1.36 2012/01/28 13:47:55 sthen Exp $ */ +/* $OpenBSD: print-ike.c,v 1.37 2015/01/16 06:40:21 deraadt Exp $ */ /* * Copyright (c) 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999 @@ -27,7 +27,6 @@ * in co-operation with SSH Communications Security, Espoo, Finland */ -#include <sys/param.h> #include <sys/time.h> #include <sys/socket.h> diff --git a/usr.sbin/tcpdump/print-ip.c b/usr.sbin/tcpdump/print-ip.c index 604f45aa652..d6940d7d1a2 100644 --- a/usr.sbin/tcpdump/print-ip.c +++ b/usr.sbin/tcpdump/print-ip.c @@ -1,4 +1,4 @@ -/* $OpenBSD: print-ip.c,v 1.42 2014/12/09 17:03:19 mikeb Exp $ */ +/* $OpenBSD: print-ip.c,v 1.43 2015/01/16 06:40:21 deraadt Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997 @@ -21,7 +21,6 @@ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ -#include <sys/param.h> #include <sys/time.h> #include <sys/socket.h> diff --git a/usr.sbin/tcpdump/print-ip6.c b/usr.sbin/tcpdump/print-ip6.c index f9c851a2c23..269c522cdc5 100644 --- a/usr.sbin/tcpdump/print-ip6.c +++ b/usr.sbin/tcpdump/print-ip6.c @@ -1,4 +1,4 @@ -/* $OpenBSD: print-ip6.c,v 1.20 2014/12/09 17:03:19 mikeb Exp $ */ +/* $OpenBSD: print-ip6.c,v 1.21 2015/01/16 06:40:21 deraadt Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994 @@ -23,7 +23,6 @@ #ifdef INET6 -#include <sys/param.h> #include <sys/time.h> #include <sys/types.h> #include <sys/socket.h> diff --git a/usr.sbin/tcpdump/print-ip6opts.c b/usr.sbin/tcpdump/print-ip6opts.c index cdee34df886..9e7acf829a1 100644 --- a/usr.sbin/tcpdump/print-ip6opts.c +++ b/usr.sbin/tcpdump/print-ip6opts.c @@ -1,4 +1,4 @@ -/* $OpenBSD: print-ip6opts.c,v 1.3 2006/12/09 01:12:28 itojun Exp $ */ +/* $OpenBSD: print-ip6opts.c,v 1.4 2015/01/16 06:40:21 deraadt Exp $ */ /* * Copyright (C) 1998 WIDE Project. @@ -30,7 +30,6 @@ */ #ifdef INET6 -#include <sys/param.h> #include <sys/time.h> #include <sys/types.h> #include <sys/socket.h> diff --git a/usr.sbin/tcpdump/print-ipsec.c b/usr.sbin/tcpdump/print-ipsec.c index 51d2470638a..c04cb2da75d 100644 --- a/usr.sbin/tcpdump/print-ipsec.c +++ b/usr.sbin/tcpdump/print-ipsec.c @@ -1,4 +1,4 @@ -/* $OpenBSD: print-ipsec.c,v 1.19 2014/08/14 12:44:44 mpi Exp $ */ +/* $OpenBSD: print-ipsec.c,v 1.20 2015/01/16 06:40:21 deraadt Exp $ */ /* * Copyright (c) 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999 @@ -26,7 +26,6 @@ * in co-operation with SSH Communications Security, Espoo, Finland */ -#include <sys/param.h> #include <sys/time.h> #include <sys/socket.h> diff --git a/usr.sbin/tcpdump/print-ipx.c b/usr.sbin/tcpdump/print-ipx.c index 6728c1ac2ed..b72f5367cad 100644 --- a/usr.sbin/tcpdump/print-ipx.c +++ b/usr.sbin/tcpdump/print-ipx.c @@ -1,4 +1,4 @@ -/* $OpenBSD: print-ipx.c,v 1.13 2014/08/14 12:44:44 mpi Exp $ */ +/* $OpenBSD: print-ipx.c,v 1.14 2015/01/16 06:40:21 deraadt Exp $ */ /* * Copyright (c) 1994, 1995, 1996 @@ -24,7 +24,6 @@ * Contributed by Brad Parker (brad@fcr.com). */ -#include <sys/param.h> #include <sys/time.h> #include <sys/socket.h> diff --git a/usr.sbin/tcpdump/print-krb.c b/usr.sbin/tcpdump/print-krb.c index 5f777834921..7a27cba9702 100644 --- a/usr.sbin/tcpdump/print-krb.c +++ b/usr.sbin/tcpdump/print-krb.c @@ -1,4 +1,4 @@ -/* $OpenBSD: print-krb.c,v 1.9 2014/08/14 12:44:44 mpi Exp $ */ +/* $OpenBSD: print-krb.c,v 1.10 2015/01/16 06:40:21 deraadt Exp $ */ /* * Copyright (c) 1995, 1996, 1997 @@ -23,7 +23,6 @@ * Initial contribution from John Hawkinson (jhawk@mit.edu). */ -#include <sys/param.h> #include <sys/time.h> #include <sys/socket.h> diff --git a/usr.sbin/tcpdump/print-l2tp.c b/usr.sbin/tcpdump/print-l2tp.c index f8808442145..857bac9ab25 100644 --- a/usr.sbin/tcpdump/print-l2tp.c +++ b/usr.sbin/tcpdump/print-l2tp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: print-l2tp.c,v 1.7 2011/09/18 14:04:36 naddy Exp $ */ +/* $OpenBSD: print-l2tp.c,v 1.8 2015/01/16 06:40:21 deraadt Exp $ */ /* * Copyright (c) 1991, 1993, 1994, 1995, 1996, 1997 @@ -24,7 +24,6 @@ */ #include <sys/types.h> -#include <sys/param.h> #include <stdio.h> #include <strings.h> diff --git a/usr.sbin/tcpdump/print-llc.c b/usr.sbin/tcpdump/print-llc.c index 2f78c6809db..28eda54c6e7 100644 --- a/usr.sbin/tcpdump/print-llc.c +++ b/usr.sbin/tcpdump/print-llc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: print-llc.c,v 1.18 2009/10/27 23:59:55 deraadt Exp $ */ +/* $OpenBSD: print-llc.c,v 1.19 2015/01/16 06:40:21 deraadt Exp $ */ /* * Copyright (c) 1992, 1993, 1994, 1995, 1996, 1997 @@ -24,7 +24,6 @@ * with an awful lot of hacking by Jeffrey Mogul, DECWRL */ -#include <sys/param.h> #include <sys/time.h> #include <netinet/in.h> diff --git a/usr.sbin/tcpdump/print-lldp.c b/usr.sbin/tcpdump/print-lldp.c index 18e6c8e28df..98da2cbaad5 100644 --- a/usr.sbin/tcpdump/print-lldp.c +++ b/usr.sbin/tcpdump/print-lldp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: print-lldp.c,v 1.7 2014/08/14 12:44:44 mpi Exp $ */ +/* $OpenBSD: print-lldp.c,v 1.8 2015/01/16 06:40:21 deraadt Exp $ */ /* * Copyright (c) 2006 Reyk Floeter <reyk@openbsd.org> @@ -16,7 +16,6 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#include <sys/param.h> #include <sys/time.h> #include <sys/socket.h> diff --git a/usr.sbin/tcpdump/print-lwres.c b/usr.sbin/tcpdump/print-lwres.c index b6113d3c688..5f91bcc8396 100644 --- a/usr.sbin/tcpdump/print-lwres.c +++ b/usr.sbin/tcpdump/print-lwres.c @@ -31,7 +31,6 @@ #include "config.h" #endif -#include <sys/param.h> #include <sys/time.h> #include <netinet/in.h> diff --git a/usr.sbin/tcpdump/print-mobile.c b/usr.sbin/tcpdump/print-mobile.c index cbfbaf99701..867b737f324 100644 --- a/usr.sbin/tcpdump/print-mobile.c +++ b/usr.sbin/tcpdump/print-mobile.c @@ -1,4 +1,4 @@ -/* $OpenBSD: print-mobile.c,v 1.4 2014/08/14 12:44:44 mpi Exp $ */ +/* $OpenBSD: print-mobile.c,v 1.5 2015/01/16 06:40:21 deraadt Exp $ */ /* $NetBSD: print-mobile.c,v 1.3 1999/07/26 06:11:57 itojun Exp $ */ /* @@ -30,7 +30,6 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include <sys/param.h> #include <sys/time.h> #include <sys/uio.h> #include <sys/socket.h> diff --git a/usr.sbin/tcpdump/print-netbios.c b/usr.sbin/tcpdump/print-netbios.c index 1c1f8d8b338..730db213e54 100644 --- a/usr.sbin/tcpdump/print-netbios.c +++ b/usr.sbin/tcpdump/print-netbios.c @@ -1,4 +1,4 @@ -/* $OpenBSD: print-netbios.c,v 1.9 2014/08/14 12:44:44 mpi Exp $ */ +/* $OpenBSD: print-netbios.c,v 1.10 2015/01/16 06:40:21 deraadt Exp $ */ /* * Copyright (c) 1994, 1995, 1996 @@ -24,7 +24,6 @@ * Contributed by Brad Parker (brad@fcr.com). */ -#include <sys/param.h> #include <sys/socket.h> #include <netinet/in.h> diff --git a/usr.sbin/tcpdump/print-nfs.c b/usr.sbin/tcpdump/print-nfs.c index 2edef633d33..daf3a0f86f3 100644 --- a/usr.sbin/tcpdump/print-nfs.c +++ b/usr.sbin/tcpdump/print-nfs.c @@ -1,4 +1,4 @@ -/* $OpenBSD: print-nfs.c,v 1.18 2014/08/14 12:44:44 mpi Exp $ */ +/* $OpenBSD: print-nfs.c,v 1.19 2015/01/16 06:40:21 deraadt Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997 @@ -21,7 +21,6 @@ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ -#include <sys/param.h> #include <sys/time.h> #include <sys/socket.h> diff --git a/usr.sbin/tcpdump/print-ntp.c b/usr.sbin/tcpdump/print-ntp.c index f3ea0df5092..b67116183e5 100644 --- a/usr.sbin/tcpdump/print-ntp.c +++ b/usr.sbin/tcpdump/print-ntp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: print-ntp.c,v 1.15 2009/10/27 23:59:55 deraadt Exp $ */ +/* $OpenBSD: print-ntp.c,v 1.16 2015/01/16 06:40:21 deraadt Exp $ */ /* * Copyright (c) 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997 @@ -25,7 +25,6 @@ * loosely based on print-bootp.c */ -#include <sys/param.h> #include <sys/time.h> #include <sys/socket.h> diff --git a/usr.sbin/tcpdump/print-null.c b/usr.sbin/tcpdump/print-null.c index 95b91ef47d3..f3187edd9c6 100644 --- a/usr.sbin/tcpdump/print-null.c +++ b/usr.sbin/tcpdump/print-null.c @@ -1,4 +1,4 @@ -/* $OpenBSD: print-null.c,v 1.20 2014/08/14 12:44:44 mpi Exp $ */ +/* $OpenBSD: print-null.c,v 1.21 2015/01/16 06:40:21 deraadt Exp $ */ /* * Copyright (c) 1991, 1993, 1994, 1995, 1996, 1997 @@ -21,7 +21,6 @@ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ -#include <sys/param.h> #include <sys/time.h> #include <sys/socket.h> #include <sys/file.h> diff --git a/usr.sbin/tcpdump/print-ospf.c b/usr.sbin/tcpdump/print-ospf.c index 81e83e332f5..0730171314a 100644 --- a/usr.sbin/tcpdump/print-ospf.c +++ b/usr.sbin/tcpdump/print-ospf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: print-ospf.c,v 1.18 2014/08/14 12:44:44 mpi Exp $ */ +/* $OpenBSD: print-ospf.c,v 1.19 2015/01/16 06:40:21 deraadt Exp $ */ /* * Copyright (c) 1992, 1993, 1994, 1995, 1996, 1997 @@ -23,7 +23,6 @@ * OSPF support contributed by Jeffrey Honig (jch@mitchell.cit.cornell.edu) */ -#include <sys/param.h> #include <sys/time.h> #include <sys/socket.h> diff --git a/usr.sbin/tcpdump/print-ospf6.c b/usr.sbin/tcpdump/print-ospf6.c index 98e759dcd95..fa60d90285b 100644 --- a/usr.sbin/tcpdump/print-ospf6.c +++ b/usr.sbin/tcpdump/print-ospf6.c @@ -1,4 +1,4 @@ -/* $OpenBSD: print-ospf6.c,v 1.7 2014/08/14 12:44:44 mpi Exp $ */ +/* $OpenBSD: print-ospf6.c,v 1.8 2015/01/16 06:40:21 deraadt Exp $ */ /* @@ -26,7 +26,6 @@ #ifdef INET6 -#include <sys/param.h> #include <sys/time.h> #include <sys/socket.h> diff --git a/usr.sbin/tcpdump/print-pflog.c b/usr.sbin/tcpdump/print-pflog.c index 2df0e7d5f29..df7c3d2dc7e 100644 --- a/usr.sbin/tcpdump/print-pflog.c +++ b/usr.sbin/tcpdump/print-pflog.c @@ -1,4 +1,4 @@ -/* $OpenBSD: print-pflog.c,v 1.25 2014/08/14 12:44:44 mpi Exp $ */ +/* $OpenBSD: print-pflog.c,v 1.26 2015/01/16 06:40:21 deraadt Exp $ */ /* * Copyright (c) 1990, 1991, 1993, 1994, 1995, 1996 @@ -21,8 +21,7 @@ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ -#include <sys/types.h> -#include <sys/param.h> +#include <sys/param.h> /* MSIZE MAXCOMLEN */ #include <sys/time.h> #include <sys/socket.h> #include <sys/file.h> diff --git a/usr.sbin/tcpdump/print-pfsync.c b/usr.sbin/tcpdump/print-pfsync.c index 0475fc05084..a418b98d967 100644 --- a/usr.sbin/tcpdump/print-pfsync.c +++ b/usr.sbin/tcpdump/print-pfsync.c @@ -1,4 +1,4 @@ -/* $OpenBSD: print-pfsync.c,v 1.39 2014/08/14 12:44:44 mpi Exp $ */ +/* $OpenBSD: print-pfsync.c,v 1.40 2015/01/16 06:40:21 deraadt Exp $ */ /* * Copyright (c) 2002 Michael Shalayeff @@ -26,12 +26,10 @@ * THE POSSIBILITY OF SUCH DAMAGE. */ -#include <sys/param.h> #include <sys/time.h> #include <sys/socket.h> #include <sys/file.h> #include <sys/ioctl.h> -#include <sys/mbuf.h> #ifdef __STDC__ struct rtentry; diff --git a/usr.sbin/tcpdump/print-pim.c b/usr.sbin/tcpdump/print-pim.c index d0684327ca3..cb73669a82b 100644 --- a/usr.sbin/tcpdump/print-pim.c +++ b/usr.sbin/tcpdump/print-pim.c @@ -1,4 +1,4 @@ -/* $OpenBSD: print-pim.c,v 1.6 2014/08/14 12:44:44 mpi Exp $ */ +/* $OpenBSD: print-pim.c,v 1.7 2015/01/16 06:40:21 deraadt Exp $ */ /* * Copyright (c) 1995, 1996 @@ -21,7 +21,6 @@ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ -#include <sys/param.h> #include <sys/time.h> #include <sys/socket.h> diff --git a/usr.sbin/tcpdump/print-ppp.c b/usr.sbin/tcpdump/print-ppp.c index 34f66e4505f..63c57f3ffdd 100644 --- a/usr.sbin/tcpdump/print-ppp.c +++ b/usr.sbin/tcpdump/print-ppp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: print-ppp.c,v 1.27 2014/08/14 12:44:44 mpi Exp $ */ +/* $OpenBSD: print-ppp.c,v 1.28 2015/01/16 06:40:21 deraadt Exp $ */ /* * Copyright (c) 1990, 1991, 1993, 1994, 1995, 1996, 1997 @@ -22,7 +22,6 @@ */ #ifdef PPP -#include <sys/param.h> #include <sys/time.h> #include <sys/socket.h> #include <sys/file.h> diff --git a/usr.sbin/tcpdump/print-raw.c b/usr.sbin/tcpdump/print-raw.c index 53bd247e32c..233293d198a 100644 --- a/usr.sbin/tcpdump/print-raw.c +++ b/usr.sbin/tcpdump/print-raw.c @@ -1,4 +1,4 @@ -/* $OpenBSD: print-raw.c,v 1.7 2014/08/14 12:44:44 mpi Exp $ */ +/* $OpenBSD: print-raw.c,v 1.8 2015/01/16 06:40:21 deraadt Exp $ */ /* * Copyright (c) 1996 @@ -21,7 +21,6 @@ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ -#include <sys/param.h> #include <sys/time.h> #include <sys/socket.h> #include <sys/file.h> diff --git a/usr.sbin/tcpdump/print-rip.c b/usr.sbin/tcpdump/print-rip.c index 6957fe95128..f4973c14c4b 100644 --- a/usr.sbin/tcpdump/print-rip.c +++ b/usr.sbin/tcpdump/print-rip.c @@ -1,4 +1,4 @@ -/* $OpenBSD: print-rip.c,v 1.13 2014/08/14 12:44:44 mpi Exp $ */ +/* $OpenBSD: print-rip.c,v 1.14 2015/01/16 06:40:21 deraadt Exp $ */ /* * Copyright (c) 1989, 1990, 1991, 1993, 1994, 1996 @@ -21,7 +21,6 @@ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ -#include <sys/param.h> #include <sys/time.h> #include <sys/socket.h> diff --git a/usr.sbin/tcpdump/print-ripng.c b/usr.sbin/tcpdump/print-ripng.c index 3b845866618..9337cd9f61b 100644 --- a/usr.sbin/tcpdump/print-ripng.c +++ b/usr.sbin/tcpdump/print-ripng.c @@ -1,4 +1,4 @@ -/* $OpenBSD: print-ripng.c,v 1.3 2014/08/14 12:44:44 mpi Exp $ */ +/* $OpenBSD: print-ripng.c,v 1.4 2015/01/16 06:40:21 deraadt Exp $ */ /* * Copyright (c) 1989, 1990, 1991, 1993, 1994 @@ -23,7 +23,6 @@ #ifdef INET6 -#include <sys/param.h> #include <sys/time.h> #include <sys/types.h> #include <sys/socket.h> diff --git a/usr.sbin/tcpdump/print-rt6.c b/usr.sbin/tcpdump/print-rt6.c index cad4329ba5a..27e741284f1 100644 --- a/usr.sbin/tcpdump/print-rt6.c +++ b/usr.sbin/tcpdump/print-rt6.c @@ -1,4 +1,4 @@ -/* $OpenBSD: print-rt6.c,v 1.4 2014/08/14 12:44:44 mpi Exp $ */ +/* $OpenBSD: print-rt6.c,v 1.5 2015/01/16 06:40:21 deraadt Exp $ */ /* @@ -24,7 +24,6 @@ #ifdef INET6 -#include <sys/param.h> #include <sys/time.h> #include <sys/types.h> #include <sys/socket.h> diff --git a/usr.sbin/tcpdump/print-skip.c b/usr.sbin/tcpdump/print-skip.c index 10ecd658ed9..8c123dd729d 100644 --- a/usr.sbin/tcpdump/print-skip.c +++ b/usr.sbin/tcpdump/print-skip.c @@ -1,4 +1,4 @@ -/* $OpenBSD: print-skip.c,v 1.4 2014/08/14 12:44:44 mpi Exp $ */ +/* $OpenBSD: print-skip.c,v 1.5 2015/01/16 06:40:21 deraadt Exp $ */ /* * Copyright (c) 1995 Sun Microsystems, Inc. @@ -24,7 +24,6 @@ * UPDATES, ENHANCEMENTS, OR MODIFICATIONS. */ -#include <sys/param.h> #include <sys/time.h> #include <sys/types.h> diff --git a/usr.sbin/tcpdump/print-sl.c b/usr.sbin/tcpdump/print-sl.c index 3cd7f85a02c..a2a25298392 100644 --- a/usr.sbin/tcpdump/print-sl.c +++ b/usr.sbin/tcpdump/print-sl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: print-sl.c,v 1.17 2014/11/20 04:01:01 jsg Exp $ */ +/* $OpenBSD: print-sl.c,v 1.18 2015/01/16 06:40:21 deraadt Exp $ */ /* * Copyright (c) 1989, 1990, 1991, 1993, 1994, 1995, 1996, 1997 @@ -22,11 +22,9 @@ */ #ifdef HAVE_NET_SLIP_H -#include <sys/param.h> #include <sys/time.h> #include <sys/file.h> #include <sys/ioctl.h> -#include <sys/mbuf.h> #include <sys/socket.h> struct rtentry; @@ -45,6 +43,7 @@ struct rtentry; #include <netdb.h> #include <pcap.h> #include <stdio.h> +#include <limits.h> #include "interface.h" #include "addrtoname.h" diff --git a/usr.sbin/tcpdump/print-slow.c b/usr.sbin/tcpdump/print-slow.c index 70b729e871f..493927425ba 100644 --- a/usr.sbin/tcpdump/print-slow.c +++ b/usr.sbin/tcpdump/print-slow.c @@ -1,4 +1,4 @@ -/* $OpenBSD: print-slow.c,v 1.2 2014/08/14 12:44:44 mpi Exp $ */ +/* $OpenBSD: print-slow.c,v 1.3 2015/01/16 06:40:21 deraadt Exp $ */ /* * Copyright (c) 1998-2005 The TCPDUMP project @@ -19,7 +19,6 @@ * Original code by Hannes Gredler (hannes@juniper.net) */ -#include <sys/param.h> #include <sys/time.h> #include <sys/socket.h> #include <sys/file.h> diff --git a/usr.sbin/tcpdump/print-snmp.c b/usr.sbin/tcpdump/print-snmp.c index 0d80d15a6f8..d0bdb853f5d 100644 --- a/usr.sbin/tcpdump/print-snmp.c +++ b/usr.sbin/tcpdump/print-snmp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: print-snmp.c,v 1.17 2009/11/12 00:02:16 deraadt Exp $ */ +/* $OpenBSD: print-snmp.c,v 1.18 2015/01/16 06:40:21 deraadt Exp $ */ /* * Copyright (c) 1990, 1991, 1993, 1994, 1995, 1996, 1997 @@ -55,7 +55,6 @@ # @(#)snmp.awk.x 1.1 (LANL) 1/15/90 */ -#include <sys/param.h> #include <sys/time.h> #include <ctype.h> diff --git a/usr.sbin/tcpdump/print-stp.c b/usr.sbin/tcpdump/print-stp.c index 958e558466f..fbeea005ca6 100644 --- a/usr.sbin/tcpdump/print-stp.c +++ b/usr.sbin/tcpdump/print-stp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: print-stp.c,v 1.8 2014/08/14 12:44:44 mpi Exp $ */ +/* $OpenBSD: print-stp.c,v 1.9 2015/01/16 06:40:21 deraadt Exp $ */ /* * Copyright (c) 2000 Jason L. Wright (jason@thought.net) @@ -30,7 +30,6 @@ * Pretty print 802.1D Bridge Protocol Data Units */ -#include <sys/param.h> #include <sys/time.h> #include <sys/socket.h> #include <sys/file.h> diff --git a/usr.sbin/tcpdump/print-sunrpc.c b/usr.sbin/tcpdump/print-sunrpc.c index 73eefbd8163..d1be6d540f6 100644 --- a/usr.sbin/tcpdump/print-sunrpc.c +++ b/usr.sbin/tcpdump/print-sunrpc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: print-sunrpc.c,v 1.18 2014/08/14 12:44:44 mpi Exp $ */ +/* $OpenBSD: print-sunrpc.c,v 1.19 2015/01/16 06:40:21 deraadt Exp $ */ /* * Copyright (c) 1992, 1993, 1994, 1995, 1996 @@ -21,7 +21,6 @@ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ -#include <sys/param.h> #include <sys/time.h> #include <sys/socket.h> diff --git a/usr.sbin/tcpdump/print-tcp.c b/usr.sbin/tcpdump/print-tcp.c index 487241f5875..96730025ad7 100644 --- a/usr.sbin/tcpdump/print-tcp.c +++ b/usr.sbin/tcpdump/print-tcp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: print-tcp.c,v 1.31 2014/08/14 12:44:44 mpi Exp $ */ +/* $OpenBSD: print-tcp.c,v 1.32 2015/01/16 06:40:21 deraadt Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997 @@ -21,7 +21,6 @@ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ -#include <sys/param.h> #include <sys/time.h> #include <sys/socket.h> diff --git a/usr.sbin/tcpdump/print-tftp.c b/usr.sbin/tcpdump/print-tftp.c index 2d23e71bc93..3e189a3058a 100644 --- a/usr.sbin/tcpdump/print-tftp.c +++ b/usr.sbin/tcpdump/print-tftp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: print-tftp.c,v 1.10 2009/10/27 23:59:57 deraadt Exp $ */ +/* $OpenBSD: print-tftp.c,v 1.11 2015/01/16 06:40:22 deraadt Exp $ */ /* * Copyright (c) 1990, 1991, 1993, 1994, 1995, 1996, 1997 @@ -23,7 +23,6 @@ * Format and print trivial file transfer protocol packets. */ -#include <sys/param.h> #include <sys/time.h> #include <netinet/in.h> diff --git a/usr.sbin/tcpdump/print-timed.c b/usr.sbin/tcpdump/print-timed.c index fa0713e9770..3542e96239e 100644 --- a/usr.sbin/tcpdump/print-timed.c +++ b/usr.sbin/tcpdump/print-timed.c @@ -1,4 +1,4 @@ -/* $OpenBSD: print-timed.c,v 1.5 2009/10/27 23:59:57 deraadt Exp $ */ +/* $OpenBSD: print-timed.c,v 1.6 2015/01/16 06:40:22 deraadt Exp $ */ /* * Copyright (c) 2000 Ben Smithurst <ben@scientia.demon.co.uk> @@ -29,7 +29,6 @@ #include "config.h" #endif -#include <sys/param.h> #include <sys/time.h> #include <netinet/in.h> diff --git a/usr.sbin/tcpdump/print-udp.c b/usr.sbin/tcpdump/print-udp.c index 70283cf7626..d179b3e04a6 100644 --- a/usr.sbin/tcpdump/print-udp.c +++ b/usr.sbin/tcpdump/print-udp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: print-udp.c,v 1.37 2014/08/14 12:44:44 mpi Exp $ */ +/* $OpenBSD: print-udp.c,v 1.38 2015/01/16 06:40:22 deraadt Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996 @@ -21,7 +21,6 @@ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ -#include <sys/param.h> #include <sys/time.h> #include <sys/socket.h> diff --git a/usr.sbin/tcpdump/privsep.c b/usr.sbin/tcpdump/privsep.c index e584e57c4aa..237af086a13 100644 --- a/usr.sbin/tcpdump/privsep.c +++ b/usr.sbin/tcpdump/privsep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: privsep.c,v 1.30 2011/09/22 09:12:30 stsp Exp $ */ +/* $OpenBSD: privsep.c,v 1.31 2015/01/16 06:40:22 deraadt Exp $ */ /* * Copyright (c) 2003 Can Erkin Acar @@ -411,7 +411,7 @@ impl_init_done(int fd, int *bpfd) static void impl_gethostbyaddr(int fd) { - char hostname[MAXHOSTNAMELEN]; + char hostname[HOST_NAME_MAX+1]; size_t hostname_len; int addr_af; struct hostent *hp; @@ -434,7 +434,7 @@ static void impl_ether_ntohost(int fd) { struct ether_addr ether; - char hostname[MAXHOSTNAMELEN]; + char hostname[HOST_NAME_MAX+1]; logmsg(LOG_DEBUG, "[priv]: msg PRIV_ETHER_NTOHOST received"); diff --git a/usr.sbin/tcpdump/smbutil.c b/usr.sbin/tcpdump/smbutil.c index a87def67f25..7e4a01255e3 100644 --- a/usr.sbin/tcpdump/smbutil.c +++ b/usr.sbin/tcpdump/smbutil.c @@ -1,4 +1,4 @@ -/* $OpenBSD: smbutil.c,v 1.8 2013/04/16 18:10:24 deraadt Exp $ */ +/* $OpenBSD: smbutil.c,v 1.9 2015/01/16 06:40:22 deraadt Exp $ */ /* Copyright (C) Andrew Tridgell 1995-1999 @@ -11,7 +11,6 @@ #include "config.h" #endif -#include <sys/param.h> #include <sys/time.h> #include <sys/types.h> #include <sys/socket.h> diff --git a/usr.sbin/tftp-proxy/tftp-proxy.c b/usr.sbin/tftp-proxy/tftp-proxy.c index 2d216be7370..95ab0badefa 100644 --- a/usr.sbin/tftp-proxy/tftp-proxy.c +++ b/usr.sbin/tftp-proxy/tftp-proxy.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tftp-proxy.c,v 1.10 2013/12/23 13:08:25 florian Exp $ +/* $OpenBSD: tftp-proxy.c,v 1.11 2015/01/16 06:40:22 deraadt Exp $ * * Copyright (c) 2005 DLS Internet Services * Copyright (c) 2004, 2005 Camiel Dobbelaar, <cd@sentia.nl> @@ -27,9 +27,8 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include <sys/ioctl.h> -#include <sys/param.h> #include <sys/types.h> +#include <sys/ioctl.h> #include <sys/socket.h> #include <sys/uio.h> diff --git a/usr.sbin/tftpd/tftpd.c b/usr.sbin/tftpd/tftpd.c index a579b7bf260..d502d6d1d9a 100644 --- a/usr.sbin/tftpd/tftpd.c +++ b/usr.sbin/tftpd/tftpd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tftpd.c,v 1.25 2014/12/17 22:23:33 tedu Exp $ */ +/* $OpenBSD: tftpd.c,v 1.26 2015/01/16 06:40:22 deraadt Exp $ */ /* * Copyright (c) 2012 David Gwynne <dlg@uq.edu.au> @@ -58,8 +58,6 @@ */ #include <sys/ioctl.h> -#include <sys/param.h> -#include <sys/types.h> #include <sys/queue.h> #include <sys/socket.h> #include <sys/stat.h> @@ -84,6 +82,7 @@ #include <stdarg.h> #include <syslog.h> #include <unistd.h> +#include <limits.h> #include <vis.h> #define TIMEOUT 5 /* packet rexmt timeout */ @@ -475,7 +474,7 @@ rewrite_res(int fd, short events, void *arg) char *filename; size_t len; - switch (evbuffer_read(rwmap->rdbuf, fd, MAXPATHLEN)) { + switch (evbuffer_read(rwmap->rdbuf, fd, PATH_MAX)) { case -1: switch (errno) { case EINTR: @@ -794,7 +793,7 @@ tftp(struct tftp_client *client, struct tftphdr *tp, size_t size) int i, first = 1, ecode, to; struct formats *pf; char *mode = NULL; - char filename[MAXPATHLEN]; + char filename[PATH_MAX]; const char *errstr; if (size < 5) { @@ -873,9 +872,9 @@ again: } if (verbose) { - char nicebuf[MAXPATHLEN]; + char nicebuf[PATH_MAX]; - (void)strnvis(nicebuf, filename, MAXPATHLEN, + (void)strnvis(nicebuf, filename, PATH_MAX, VIS_SAFE|VIS_OCTAL); linfo("%s: %s request for '%s'", getip(&client->ss), diff --git a/usr.sbin/tokenadm/tokenadm.c b/usr.sbin/tokenadm/tokenadm.c index b8efbe3b30f..6bdde8f9bab 100644 --- a/usr.sbin/tokenadm/tokenadm.c +++ b/usr.sbin/tokenadm/tokenadm.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tokenadm.c,v 1.9 2007/03/15 22:31:14 jmc Exp $ */ +/* $OpenBSD: tokenadm.c,v 1.10 2015/01/16 06:40:22 deraadt Exp $ */ /*- * Copyright (c) 1995 Migration Associates Corp. All Rights Reserved @@ -34,7 +34,7 @@ * BSDI $From: tokenadm.c,v 1.2 1996/10/17 00:54:28 prb Exp $ */ -#include <sys/param.h> +#include <sys/signal.h> #include <sys/resource.h> #include <sys/time.h> @@ -44,6 +44,7 @@ #include <syslog.h> #include <stdlib.h> #include <unistd.h> +#include <limits.h> #include <string.h> #include "token.h" diff --git a/usr.sbin/tokeninit/tokeninit.c b/usr.sbin/tokeninit/tokeninit.c index 4d86c54df3b..c3fd879502f 100644 --- a/usr.sbin/tokeninit/tokeninit.c +++ b/usr.sbin/tokeninit/tokeninit.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tokeninit.c,v 1.7 2008/07/09 19:58:28 sobrado Exp $ */ +/* $OpenBSD: tokeninit.c,v 1.8 2015/01/16 06:40:22 deraadt Exp $ */ /*- * Copyright (c) 1995 Migration Associates Corp. All Rights Reserved @@ -34,7 +34,7 @@ * BSDI $From: tokeninit.c,v 1.1 1996/08/26 20:27:28 prb Exp */ -#include <sys/param.h> +#include <sys/signal.h> #include <sys/resource.h> #include <sys/time.h> @@ -43,6 +43,7 @@ #include <syslog.h> #include <stdlib.h> #include <unistd.h> +#include <limits.h> #include <string.h> #include <readpassphrase.h> diff --git a/usr.sbin/traceroute/traceroute.c b/usr.sbin/traceroute/traceroute.c index d6ae260c4ca..257cf69ff9d 100644 --- a/usr.sbin/traceroute/traceroute.c +++ b/usr.sbin/traceroute/traceroute.c @@ -1,4 +1,4 @@ -/* $OpenBSD: traceroute.c,v 1.134 2014/12/09 17:46:24 millert Exp $ */ +/* $OpenBSD: traceroute.c,v 1.135 2015/01/16 06:40:22 deraadt Exp $ */ /* $NetBSD: traceroute.c,v 1.10 1995/05/21 15:50:45 mycroft Exp $ */ /* @@ -233,7 +233,6 @@ * Tue Dec 20 03:50:13 PST 1988 */ -#include <sys/param.h> #include <sys/time.h> #include <sys/socket.h> #include <sys/uio.h> @@ -265,6 +264,7 @@ #include <stdlib.h> #include <string.h> #include <unistd.h> +#include <limits.h> #define MAX_LSRR ((MAX_IPOPTLEN - 4) / 4) @@ -1703,7 +1703,7 @@ in_cksum(u_short *addr, int len) const char * inetname(struct sockaddr *sa) { - static char line[NI_MAXHOST], domain[MAXHOSTNAMELEN + 1]; + static char line[NI_MAXHOST], domain[HOST_NAME_MAX+1 + 1]; static int first = 1; char *cp; diff --git a/usr.sbin/trpt/trpt.c b/usr.sbin/trpt/trpt.c index f8aa4deac02..179cc3467c5 100644 --- a/usr.sbin/trpt/trpt.c +++ b/usr.sbin/trpt/trpt.c @@ -1,4 +1,4 @@ -/* $OpenBSD: trpt.c,v 1.29 2014/11/26 18:34:52 millert Exp $ */ +/* $OpenBSD: trpt.c,v 1.30 2015/01/16 06:40:22 deraadt Exp $ */ /*- * Copyright (c) 1997 The NetBSD Foundation, Inc. @@ -59,7 +59,6 @@ * SUCH DAMAGE. */ -#include <sys/param.h> #include <sys/queue.h> #include <sys/socket.h> #define PRUREQUESTS diff --git a/usr.sbin/user/user.c b/usr.sbin/user/user.c index 394710bf079..6356a90fe36 100644 --- a/usr.sbin/user/user.c +++ b/usr.sbin/user/user.c @@ -1,4 +1,4 @@ -/* $OpenBSD: user.c,v 1.100 2014/08/27 06:51:35 sebastia Exp $ */ +/* $OpenBSD: user.c,v 1.101 2015/01/16 06:40:22 deraadt Exp $ */ /* $NetBSD: user.c,v 1.69 2003/04/14 17:40:07 agc Exp $ */ /* @@ -32,7 +32,7 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include <sys/param.h> +#include <sys/types.h> #include <sys/stat.h> #include <ctype.h> @@ -51,6 +51,7 @@ #include <syslog.h> #include <time.h> #include <unistd.h> +#include <limits.h> #include <util.h> #include "defs.h" @@ -159,7 +160,7 @@ enum { /* some useful constants */ enum { MaxShellNameLen = 256, - MaxFileNameLen = MAXPATHLEN, + MaxFileNameLen = PATH_MAX, MaxUserNameLen = _PW_NAME_LEN, MaxCommandLen = 2048, PasswordLength = _PASSWORD_LEN, diff --git a/usr.sbin/watchdogd/watchdogd.c b/usr.sbin/watchdogd/watchdogd.c index 2f7850d35d5..ee265aa1f58 100644 --- a/usr.sbin/watchdogd/watchdogd.c +++ b/usr.sbin/watchdogd/watchdogd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: watchdogd.c,v 1.14 2012/12/18 21:28:45 millert Exp $ */ +/* $OpenBSD: watchdogd.c,v 1.15 2015/01/16 06:40:22 deraadt Exp $ */ /* * Copyright (c) 2005 Marc Balmer <mbalmer@openbsd.org> @@ -16,8 +16,9 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#include <sys/param.h> +#include <sys/types.h> #include <sys/resource.h> +#include <sys/signal.h> #include <sys/sysctl.h> #include <sys/mman.h> diff --git a/usr.sbin/ypbind/ypbind.c b/usr.sbin/ypbind/ypbind.c index 439daa2cc9b..fb06598411b 100644 --- a/usr.sbin/ypbind/ypbind.c +++ b/usr.sbin/ypbind/ypbind.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ypbind.c,v 1.62 2014/01/21 23:05:09 jsg Exp $ */ +/* $OpenBSD: ypbind.c,v 1.63 2015/01/16 06:40:22 deraadt Exp $ */ /* * Copyright (c) 1992, 1993, 1996, 1997, 1998 Theo de Raadt <deraadt@openbsd.org> @@ -36,6 +36,7 @@ #include <net/if.h> #include <stdio.h> #include <stdlib.h> +#include <limits.h> #include <errno.h> #include <ctype.h> #include <netdb.h> @@ -70,7 +71,7 @@ struct _dom_binding { int dom_lockfd; int dom_alive; u_int32_t dom_xid; - char dom_servlist[MAXPATHLEN]; + char dom_servlist[PATH_MAX]; FILE *dom_servlistfp; }; @@ -132,7 +133,7 @@ ypbindproc_domain_2x(SVCXPRT *transp, domainname *argp, CLIENT *clnt) { static struct ypbind_resp res; struct _dom_binding *ypdb; - char path[MAXPATHLEN]; + char path[PATH_MAX]; time_t now; int count = 0; @@ -333,7 +334,7 @@ usage(void) int main(int argc, char *argv[]) { - char path[MAXPATHLEN]; + char path[PATH_MAX]; struct sockaddr_in sin; struct timeval tv; fd_set *fdsrp = NULL; @@ -679,7 +680,7 @@ pings(struct _dom_binding *ypdb) struct rpc_msg msg; struct sockaddr_in bindsin; char buf[1400]; - char path[MAXPATHLEN]; + char path[PATH_MAX]; enum clnt_stat st; int outlen; AUTH *rpcua; @@ -969,7 +970,7 @@ rpc_received(char *dom, struct sockaddr_in *raddrp, int force) struct _dom_binding *ypdb; struct iovec iov[2]; struct ypbind_resp ybr; - char path[MAXPATHLEN]; + char path[PATH_MAX]; int fd; if (strchr(dom, '/')) diff --git a/usr.sbin/ypldap/ber.c b/usr.sbin/ypldap/ber.c index 5c8688e10bc..5f8cb774526 100644 --- a/usr.sbin/ypldap/ber.c +++ b/usr.sbin/ypldap/ber.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ber.c,v 1.7 2010/06/14 13:46:08 martinh Exp $ */ +/* $OpenBSD: ber.c,v 1.8 2015/01/16 06:40:22 deraadt Exp $ */ /* * Copyright (c) 2007 Reyk Floeter <reyk@vantronix.net> @@ -19,7 +19,6 @@ */ #include <sys/types.h> -#include <sys/param.h> #include <errno.h> #include <limits.h> @@ -32,6 +31,7 @@ #include "ber.h" +#define MINIMUM(a, b) (((a) < (b)) ? (a) : (b)) #define BER_TYPE_CONSTRUCTED 0x20 /* otherwise primitive */ #define BER_TYPE_SINGLE_MAX 30 @@ -1163,7 +1163,7 @@ ber_readbuf(struct ber *b, void *buf, size_t nbytes) return -1; sz = b->br_rend - b->br_rptr; - len = MIN(nbytes, sz); + len = MINIMUM(nbytes, sz); if (len == 0) { errno = ECANCELED; return (-1); /* end of buffer and parser wants more data */ diff --git a/usr.sbin/ypldap/entries.c b/usr.sbin/ypldap/entries.c index 7bcb2bf501b..84fa48120fa 100644 --- a/usr.sbin/ypldap/entries.c +++ b/usr.sbin/ypldap/entries.c @@ -1,4 +1,4 @@ -/* $OpenBSD: entries.c,v 1.2 2011/08/28 11:53:16 aschrijver Exp $ */ +/* $OpenBSD: entries.c,v 1.3 2015/01/16 06:40:22 deraadt Exp $ */ /* * Copyright (c) 2008 Pierre-Yves Ritschard <pyr@openbsd.org> * @@ -16,7 +16,6 @@ */ #include <sys/types.h> -#include <sys/param.h> #include <sys/queue.h> #include <sys/socket.h> #include <sys/tree.h> @@ -32,6 +31,7 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> +#include <limits.h> #include "ypldap.h" diff --git a/usr.sbin/ypldap/ldapclient.c b/usr.sbin/ypldap/ldapclient.c index 4cceabf722c..3cb1a0701f3 100644 --- a/usr.sbin/ypldap/ldapclient.c +++ b/usr.sbin/ypldap/ldapclient.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ldapclient.c,v 1.31 2014/11/16 23:24:44 tedu Exp $ */ +/* $OpenBSD: ldapclient.c,v 1.32 2015/01/16 06:40:22 deraadt Exp $ */ /* * Copyright (c) 2008 Alexander Schrijver <aschrijver@openbsd.org> @@ -18,9 +18,9 @@ */ #include <sys/types.h> -#include <sys/param.h> #include <sys/queue.h> #include <sys/socket.h> +#include <sys/signal.h> #include <sys/tree.h> #include <netinet/in.h> @@ -36,6 +36,7 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> +#include <limits.h> #include "aldap.h" #include "ypldap.h" diff --git a/usr.sbin/ypldap/parse.y b/usr.sbin/ypldap/parse.y index 1ca61fb1df4..39be6965362 100644 --- a/usr.sbin/ypldap/parse.y +++ b/usr.sbin/ypldap/parse.y @@ -1,4 +1,4 @@ -/* $OpenBSD: parse.y,v 1.17 2014/11/20 05:51:21 jsg Exp $ */ +/* $OpenBSD: parse.y,v 1.18 2015/01/16 06:40:22 deraadt Exp $ */ /* * Copyright (c) 2008 Pierre-Yves Ritschard <pyr@openbsd.org> @@ -28,7 +28,6 @@ #include <sys/time.h> #include <sys/queue.h> #include <sys/tree.h> -#include <sys/param.h> #include <sys/socket.h> #include <sys/stat.h> diff --git a/usr.sbin/ypldap/yp.c b/usr.sbin/ypldap/yp.c index c8e1a47442e..0a51affe712 100644 --- a/usr.sbin/ypldap/yp.c +++ b/usr.sbin/ypldap/yp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: yp.c,v 1.12 2013/10/01 12:00:34 deraadt Exp $ */ +/* $OpenBSD: yp.c,v 1.13 2015/01/16 06:40:22 deraadt Exp $ */ /* * Copyright (c) 2008 Pierre-Yves Ritschard <pyr@openbsd.org> * @@ -16,7 +16,6 @@ */ #include <sys/types.h> -#include <sys/param.h> #include <sys/queue.h> #include <sys/socket.h> #include <sys/select.h> @@ -33,6 +32,7 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> +#include <limits.h> #include <rpc/rpc.h> #include <rpc/xdr.h> diff --git a/usr.sbin/ypldap/ypldap.c b/usr.sbin/ypldap/ypldap.c index 5f7b479e0b9..f53e3775005 100644 --- a/usr.sbin/ypldap/ypldap.c +++ b/usr.sbin/ypldap/ypldap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ypldap.c,v 1.14 2014/07/13 15:38:09 krw Exp $ */ +/* $OpenBSD: ypldap.c,v 1.15 2015/01/16 06:40:22 deraadt Exp $ */ /* * Copyright (c) 2008 Pierre-Yves Ritschard <pyr@openbsd.org> @@ -17,9 +17,9 @@ */ #include <sys/types.h> -#include <sys/param.h> #include <sys/queue.h> #include <sys/socket.h> +#include <sys/signal.h> #include <sys/tree.h> #include <sys/wait.h> @@ -35,6 +35,7 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> +#include <limits.h> #include "ypldap.h" diff --git a/usr.sbin/ypldap/ypldap.h b/usr.sbin/ypldap/ypldap.h index 3a1bd17a776..177e8fda4f2 100644 --- a/usr.sbin/ypldap/ypldap.h +++ b/usr.sbin/ypldap/ypldap.h @@ -1,4 +1,4 @@ -/* $OpenBSD: ypldap.h,v 1.15 2014/11/03 20:15:31 bluhm Exp $ */ +/* $OpenBSD: ypldap.h,v 1.16 2015/01/16 06:40:22 deraadt Exp $ */ /* * Copyright (c) 2008 Pierre-Yves Ritschard <pyr@openbsd.org> @@ -81,7 +81,7 @@ enum client_state { struct idm { TAILQ_ENTRY(idm) idm_entry; u_int32_t idm_id; - char idm_name[MAXHOSTNAMELEN]; + char idm_name[HOST_NAME_MAX+1]; #define F_SSL 0x00100000 #define F_CONFIGURING 0x00200000 #define F_NEEDAUTH 0x00400000 @@ -155,7 +155,7 @@ struct env { u_int32_t sc_maxid; - char sc_domainname[MAXHOSTNAMELEN]; + char sc_domainname[HOST_NAME_MAX+1]; struct timeval sc_conf_tv; struct event sc_conf_ev; TAILQ_HEAD(idm_list, idm) sc_idms; diff --git a/usr.sbin/ypldap/ypldap_dns.c b/usr.sbin/ypldap/ypldap_dns.c index 1e4aa6bb4b1..24483861715 100644 --- a/usr.sbin/ypldap/ypldap_dns.c +++ b/usr.sbin/ypldap/ypldap_dns.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ypldap_dns.c,v 1.7 2014/07/13 15:38:09 krw Exp $ */ +/* $OpenBSD: ypldap_dns.c,v 1.8 2015/01/16 06:40:22 deraadt Exp $ */ /* * Copyright (c) 2003-2008 Henning Brauer <henning@openbsd.org> @@ -19,7 +19,6 @@ #include <sys/types.h> #include <sys/socket.h> #include <sys/stat.h> -#include <sys/param.h> #include <sys/time.h> #include <sys/tree.h> #include <sys/queue.h> @@ -37,6 +36,7 @@ #include <stdlib.h> #include <string.h> #include <unistd.h> +#include <limits.h> #include "ypldap.h" diff --git a/usr.sbin/yppoll/yppoll.c b/usr.sbin/yppoll/yppoll.c index 6cb4f4d4460..266f88b60cc 100644 --- a/usr.sbin/yppoll/yppoll.c +++ b/usr.sbin/yppoll/yppoll.c @@ -1,4 +1,4 @@ -/* $OpenBSD: yppoll.c,v 1.14 2013/04/16 19:24:55 deraadt Exp $ */ +/* $OpenBSD: yppoll.c,v 1.15 2015/01/16 06:40:22 deraadt Exp $ */ /* $NetBSD: yppoll.c,v 1.5 1996/05/13 02:46:36 thorpej Exp $ */ /* @@ -31,7 +31,6 @@ * SUCH DAMAGE. */ -#include <sys/param.h> #include <sys/types.h> #include <sys/socket.h> #include <stdio.h> diff --git a/usr.sbin/ypserv/common/ypdb.c b/usr.sbin/ypserv/common/ypdb.c index 3753cdcd9b8..c2e510b93d4 100644 --- a/usr.sbin/ypserv/common/ypdb.c +++ b/usr.sbin/ypserv/common/ypdb.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ypdb.c,v 1.11 2003/07/15 06:10:46 deraadt Exp $ */ +/* $OpenBSD: ypdb.c,v 1.12 2015/01/16 06:40:22 deraadt Exp $ */ /* * Copyright (c) 1990, 1993 @@ -36,7 +36,6 @@ * SUCH DAMAGE. */ -#include <sys/param.h> #include <sys/types.h> #include <stdio.h> #include <string.h> @@ -54,7 +53,7 @@ extern DBM * ypdb_open(const char *file, int flags, int mode) { BTREEINFO info; - char path[MAXPATHLEN]; + char path[PATH_MAX]; DBM *db; memset(&info, 0, sizeof info); diff --git a/usr.sbin/ypserv/common/yplib_host.c b/usr.sbin/ypserv/common/yplib_host.c index 1d1ed503c5e..ddd1b207622 100644 --- a/usr.sbin/ypserv/common/yplib_host.c +++ b/usr.sbin/ypserv/common/yplib_host.c @@ -1,4 +1,4 @@ -/* $OpenBSD: yplib_host.c,v 1.17 2014/11/18 20:54:29 krw Exp $ */ +/* $OpenBSD: yplib_host.c,v 1.18 2015/01/16 06:40:22 deraadt Exp $ */ /* * Copyright (c) 1992, 1993 Theo de Raadt <deraadt@theos.com> @@ -26,7 +26,6 @@ * SUCH DAMAGE. */ -#include <sys/param.h> #include <sys/types.h> #include <sys/socket.h> #include <sys/file.h> diff --git a/usr.sbin/ypserv/makedbm/db.c b/usr.sbin/ypserv/makedbm/db.c index b57399f8280..9e27569e356 100644 --- a/usr.sbin/ypserv/makedbm/db.c +++ b/usr.sbin/ypserv/makedbm/db.c @@ -1,4 +1,4 @@ -/* $OpenBSD: db.c,v 1.8 2009/10/27 23:59:57 deraadt Exp $ */ +/* $OpenBSD: db.c,v 1.9 2015/01/16 06:40:23 deraadt Exp $ */ /* * Copyright (c) 1997 Mats O Jansson <moj@stacken.kth.se> @@ -30,7 +30,6 @@ #include <db.h> #include <fcntl.h> #include <stdio.h> -#include <sys/param.h> #include "db.h" #include "ypdb.h" @@ -45,7 +44,7 @@ db_hash_list_database(char *database) DB *db; int status; DBT key, val; - char path[MAXPATHLEN]; + char path[PATH_MAX]; snprintf(path, sizeof(path), "%s%s", database, ".db"); diff --git a/usr.sbin/ypserv/makedbm/makedbm.c b/usr.sbin/ypserv/makedbm/makedbm.c index 98cfaf99997..5f373f5aad9 100644 --- a/usr.sbin/ypserv/makedbm/makedbm.c +++ b/usr.sbin/ypserv/makedbm/makedbm.c @@ -1,4 +1,4 @@ -/* $OpenBSD: makedbm.c,v 1.31 2013/12/04 02:18:05 deraadt Exp $ */ +/* $OpenBSD: makedbm.c,v 1.32 2015/01/16 06:40:23 deraadt Exp $ */ /* * Copyright (c) 1994-97 Mats O Jansson <moj@stacken.kth.se> @@ -31,7 +31,6 @@ #include <fcntl.h> #include <ctype.h> #include <sys/stat.h> -#include <sys/param.h> #include <unistd.h> #include <string.h> #include <errno.h> @@ -162,13 +161,13 @@ create_database(char *infile, char *database, char *yp_input_file, { FILE *data_file; char data_line[4096]; /* XXX: DB bsize = 4096 in ypdb.c */ - char myname[MAXHOSTNAMELEN]; + char myname[HOST_NAME_MAX+1]; int line_no = 0, len; char *p, *k, *v, *slash; DBM *new_db; static char mapname[] = "ypdbXXXXXXXXXX"; - char db_mapname[MAXPATHLEN], db_outfile[MAXPATHLEN]; - char db_tempname[MAXPATHLEN], empty_str[] = ""; + char db_mapname[PATH_MAX], db_outfile[PATH_MAX]; + char db_tempname[PATH_MAX], empty_str[] = ""; if (strcmp(infile,"-") == 0) { data_file = stdin; @@ -181,7 +180,7 @@ create_database(char *infile, char *database, char *yp_input_file, } } - if (strlen(database) + strlen(YPDB_SUFFIX) > MAXPATHLEN) { + if (strlen(database) + strlen(YPDB_SUFFIX) > PATH_MAX) { fprintf(stderr,"%s: %s: file name too long\n", __progname, database); exit(1); @@ -197,7 +196,7 @@ create_database(char *infile, char *database, char *yp_input_file, /* note: database is now directory where map goes ! */ if (strlen(database) + strlen(mapname) + - strlen(YPDB_SUFFIX) > MAXPATHLEN) { + strlen(YPDB_SUFFIX) > PATH_MAX) { fprintf(stderr,"%s: %s: directory name too long\n", __progname, database); exit(1); diff --git a/usr.sbin/ypserv/mkalias/mkalias.c b/usr.sbin/ypserv/mkalias/mkalias.c index 71e9470e2bb..e15b0388ae1 100644 --- a/usr.sbin/ypserv/mkalias/mkalias.c +++ b/usr.sbin/ypserv/mkalias/mkalias.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mkalias.c,v 1.26 2013/12/05 14:18:54 jca Exp $ */ +/* $OpenBSD: mkalias.c,v 1.27 2015/01/16 06:40:23 deraadt Exp $ */ /* * Copyright (c) 1997 Mats O Jansson <moj@stacken.kth.se> @@ -33,7 +33,6 @@ #include <stdlib.h> #include <string.h> #include <unistd.h> -#include <sys/param.h> #include <sys/types.h> #include <netinet/in.h> #include <arpa/nameser.h> @@ -146,10 +145,10 @@ main(int argc, char *argv[]) datum key, val; DBM *new_db = NULL; static char mapname[] = "ypdbXXXXXXXXXX"; - char db_mapname[MAXPATHLEN], db_outfile[MAXPATHLEN]; - char db_tempname[MAXPATHLEN]; + char db_mapname[PATH_MAX], db_outfile[PATH_MAX]; + char db_tempname[PATH_MAX]; char user[4096], host[4096]; /* XXX: DB bsize = 4096 in ypdb.c */ - char myname[MAXHOSTNAMELEN], datestr[11], *slash; + char myname[HOST_NAME_MAX+1], datestr[11], *slash; while ((ch = getopt(argc, argv, "Edensuv")) != -1) switch (ch) { @@ -196,7 +195,7 @@ main(int argc, char *argv[]) } if (output != NULL) { - if (strlen(output) + strlen(YPDB_SUFFIX) > MAXPATHLEN) { + if (strlen(output) + strlen(YPDB_SUFFIX) > PATH_MAX) { errx(1, "%s: file name too long", output); /* NOTREACHED */ } @@ -213,7 +212,7 @@ main(int argc, char *argv[]) /* note: output is now directory where map goes ! */ if (strlen(output) + strlen(mapname) + - strlen(YPDB_SUFFIX) > MAXPATHLEN) { + strlen(YPDB_SUFFIX) > PATH_MAX) { errx(1, "%s: directory name too long", output); /* NOTREACHED */ } diff --git a/usr.sbin/ypserv/mknetid/mknetid.c b/usr.sbin/ypserv/mknetid/mknetid.c index 60de4acf1f2..ec1b3b10af0 100644 --- a/usr.sbin/ypserv/mknetid/mknetid.c +++ b/usr.sbin/ypserv/mknetid/mknetid.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mknetid.c,v 1.20 2013/12/04 02:18:05 deraadt Exp $ */ +/* $OpenBSD: mknetid.c,v 1.21 2015/01/16 06:40:23 deraadt Exp $ */ /* * Copyright (c) 1996 Mats O Jansson <moj@stacken.kth.se> @@ -26,7 +26,6 @@ * SUCH DAMAGE. */ -#include <sys/param.h> #include <stdio.h> #include <unistd.h> #include <ctype.h> @@ -36,6 +35,7 @@ #include <grp.h> #include <err.h> #include <netdb.h> +#include <limits.h> #include <rpcsvc/ypclnt.h> @@ -44,7 +44,7 @@ struct user { int usr_uid; /* user uid */ int usr_gid; /* user gid */ int gid_count; /* number of gids */ - int gid[NGROUPS]; /* additional gids */ + int gid[NGROUPS_MAX]; /* additional gids */ struct user *prev, *next; /* links in read order */ struct user *hprev, *hnext; /* links in hash order */ }; @@ -155,7 +155,7 @@ add_group(char *username, char *gid) if (strcmp(username, u->usr_name) == 0) { if (g != u->usr_gid) { u->gid_count++; - if (u->gid_count < NGROUPS) + if (u->gid_count < NGROUPS_MAX) u->gid[u->gid_count] = atoi(gid); } u = htail[idx]; diff --git a/usr.sbin/ypserv/yppush/yppush.c b/usr.sbin/ypserv/yppush/yppush.c index f8fb6d38e11..c054a3bb9ac 100644 --- a/usr.sbin/ypserv/yppush/yppush.c +++ b/usr.sbin/ypserv/yppush/yppush.c @@ -1,4 +1,4 @@ -/* $OpenBSD: yppush.c,v 1.30 2014/11/04 16:16:03 deraadt Exp $ */ +/* $OpenBSD: yppush.c,v 1.31 2015/01/16 06:40:23 deraadt Exp $ */ /* * Copyright (c) 1995 Mats O Jansson <moj@stacken.kth.se> @@ -52,7 +52,7 @@ #include "ypdb.h" int Verbose = 0; -char Domain[MAXHOSTNAMELEN], Map[255]; +char Domain[HOST_NAME_MAX+1], Map[255]; u_int32_t OrderNum; char *master; @@ -141,7 +141,7 @@ req_xfr(pid_t pid, u_int prog, SVCXPRT *transp, char *host, CLIENT *client) static void push(int inlen, char *indata) { - char host[MAXHOSTNAMELEN]; + char host[HOST_NAME_MAX+1]; CLIENT *client; SVCXPRT *transp; int sock = RPC_ANYSOCK, status; @@ -222,7 +222,7 @@ main(int argc, char *argv[]) int c, r, i; char *ypmap = "ypservers"; CLIENT *client; - static char map_path[MAXPATHLEN]; + static char map_path[PATH_MAX]; struct stat finfo; DBM *yp_databas; char order_key[YP_LAST_LEN] = YP_LAST_KEY; diff --git a/usr.sbin/ypserv/ypserv/ypserv_db.c b/usr.sbin/ypserv/ypserv/ypserv_db.c index cbdf0f7125c..362816118d8 100644 --- a/usr.sbin/ypserv/ypserv/ypserv_db.c +++ b/usr.sbin/ypserv/ypserv/ypserv_db.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ypserv_db.c,v 1.28 2013/12/05 17:36:12 jca Exp $ */ +/* $OpenBSD: ypserv_db.c,v 1.29 2015/01/16 06:40:23 deraadt Exp $ */ /* * Copyright (c) 1994 Mats O Jansson <moj@stacken.kth.se> @@ -37,7 +37,6 @@ #include <rpcsvc/yp.h> #include <rpcsvc/ypclnt.h> #include <sys/stat.h> -#include <sys/param.h> #include <fcntl.h> #include <string.h> #include <stdio.h> @@ -197,7 +196,7 @@ DBM * ypdb_open_db(domainname domain, mapname map, ypstat *status, struct opt_map **map_info) { - char map_path[MAXPATHLEN]; + char map_path[PATH_MAX]; static char *domain_key = YP_INTERDOMAIN_KEY; static char *secure_key = YP_SECURE_KEY; DBM *db; @@ -369,8 +368,8 @@ lookup_host(int nametable, int host_lookup, DBM *db, char *keystr, struct in_addr *addr_name; struct in_addr addr_addr; static char val[BUFSIZ+1]; /* match libc */ - static char hostname[MAXHOSTNAMELEN]; - char tmpbuf[MAXHOSTNAMELEN + 20], *v, *ptr; + static char hostname[HOST_NAME_MAX+1]; + char tmpbuf[HOST_NAME_MAX+1 + 20], *v, *ptr; size_t len; int l; diff --git a/usr.sbin/ypserv/ypserv/ypserv_proc.c b/usr.sbin/ypserv/ypserv/ypserv_proc.c index de86b94d410..aa88455071d 100644 --- a/usr.sbin/ypserv/ypserv/ypserv_proc.c +++ b/usr.sbin/ypserv/ypserv/ypserv_proc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ypserv_proc.c,v 1.28 2014/02/24 06:45:56 jsg Exp $ */ +/* $OpenBSD: ypserv_proc.c,v 1.29 2015/01/16 06:40:23 deraadt Exp $ */ /* * Copyright (c) 1994 Mats O Jansson <moj@stacken.kth.se> @@ -32,7 +32,6 @@ #include <rpcsvc/ypclnt.h> #include <sys/stat.h> #include <sys/socket.h> -#include <sys/param.h> #include <netinet/in.h> #include <arpa/inet.h> #include "ypdb.h" @@ -82,7 +81,7 @@ ypproc_domain_2_svc(domainname *argp, struct svc_req *rqstp) { struct sockaddr_in *caller = svc_getcaller(rqstp->rq_xprt); int ok = acl_check_host(&caller->sin_addr); - static char domain_path[MAXPATHLEN]; + static char domain_path[PATH_MAX]; static bool_t result; struct stat finfo; @@ -110,7 +109,7 @@ ypproc_domain_nonack_2_svc(domainname *argp, struct svc_req *rqstp) static bool_t result; /* is domain served? */ struct sockaddr_in *caller = svc_getcaller(rqstp->rq_xprt); int ok = acl_check_host(&caller->sin_addr); - static char domain_path[MAXPATHLEN]; + static char domain_path[PATH_MAX]; struct stat finfo; if (strchr(*argp, '/')) @@ -440,7 +439,7 @@ ypproc_maplist_2_svc(domainname *argp, struct svc_req *rqstp) static ypresp_maplist res; struct sockaddr_in *caller = svc_getcaller(rqstp->rq_xprt); int ok = acl_check_host(&caller->sin_addr); - static char domain_path[MAXPATHLEN]; + static char domain_path[PATH_MAX]; struct stat finfo; DIR *dirp = NULL; struct dirent *dp; @@ -539,7 +538,7 @@ ypoldproc_domain_1_svc(domainname *argp, struct svc_req *rqstp) static bool_t result; /* is domain_served? */ struct sockaddr_in *caller = svc_getcaller(rqstp->rq_xprt); int ok = acl_check_host(&caller->sin_addr); - static char domain_path[MAXPATHLEN]; + static char domain_path[PATH_MAX]; struct stat finfo; if (strchr(*argp, '/')) @@ -567,7 +566,7 @@ ypoldproc_domain_nonack_1_svc(domainname *argp, struct svc_req *rqstp) static bool_t result; /* is domain served? */ struct sockaddr_in *caller = svc_getcaller(rqstp->rq_xprt); int ok = acl_check_host(&caller->sin_addr); - static char domain_path[MAXPATHLEN]; + static char domain_path[PATH_MAX]; struct stat finfo; if (strchr(*argp, '/')) diff --git a/usr.sbin/ypserv/ypxfr/ypxfr.c b/usr.sbin/ypserv/ypxfr/ypxfr.c index 6e2dc635679..61f208ed759 100644 --- a/usr.sbin/ypserv/ypxfr/ypxfr.c +++ b/usr.sbin/ypserv/ypxfr/ypxfr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ypxfr.c,v 1.37 2009/10/27 23:59:58 deraadt Exp $ */ +/* $OpenBSD: ypxfr.c,v 1.38 2015/01/16 06:40:23 deraadt Exp $ */ /* * Copyright (c) 1994 Mats O Jansson <moj@stacken.kth.se> @@ -77,7 +77,7 @@ ypxfr_foreach(u_long status, char *keystr, int keylen, char *valstr, int vallen, static int get_local_ordernum(char *domain, char *map, u_int32_t *lordernum) { - char map_path[MAXPATHLEN], order[MAX_LAST_LEN+1]; + char map_path[PATH_MAX], order[MAX_LAST_LEN+1]; char order_key[] = YP_LAST_KEY; struct stat finfo; datum k, v; @@ -173,7 +173,7 @@ create_db(char *domain, char *map, char *temp_map) static int install_db(char *domain, char *map, char *temp_map) { - char db_name[MAXPATHLEN]; + char db_name[PATH_MAX]; snprintf(db_name, sizeof db_name, "%s/%s/%s%s", YP_DB_PATH, domain, map, YPDB_SUFFIX); @@ -454,7 +454,7 @@ main(int argc, char *argv[]) } if (status == YPPUSH_SUCC) { - char tmpmapname[MAXPATHLEN]; + char tmpmapname[PATH_MAX]; int fd; /* Create temporary db */ diff --git a/usr.sbin/ypset/ypset.c b/usr.sbin/ypset/ypset.c index 59d9736659b..ebd86597fa1 100644 --- a/usr.sbin/ypset/ypset.c +++ b/usr.sbin/ypset/ypset.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ypset.c,v 1.19 2009/10/27 23:59:58 deraadt Exp $ */ +/* $OpenBSD: ypset.c,v 1.20 2015/01/16 06:40:23 deraadt Exp $ */ /* $NetBSD: ypset.c,v 1.8 1996/05/13 02:46:33 thorpej Exp $ */ /* @@ -27,7 +27,6 @@ * SUCH DAMAGE. */ -#include <sys/param.h> #include <sys/types.h> #include <sys/socket.h> #include <err.h> diff --git a/usr.sbin/ztsscale/ztsscale.c b/usr.sbin/ztsscale/ztsscale.c index 8b6a2e094f9..394a123279b 100644 --- a/usr.sbin/ztsscale/ztsscale.c +++ b/usr.sbin/ztsscale/ztsscale.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ztsscale.c,v 1.17 2014/09/27 06:28:45 doug Exp $ */ +/* $OpenBSD: ztsscale.c,v 1.18 2015/01/16 06:40:23 deraadt Exp $ */ /* * Copyright (c) 2005 Matthieu Herrb @@ -16,7 +16,7 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#include <sys/param.h> +#include <sys/types.h> #include <sys/mman.h> #include <sys/ioctl.h> #include <machine/cpu.h> |