From: deraadt Date: Fri, 16 Jan 2015 00:19:12 +0000 (+0000) Subject: move to PATH_MAX, etc; normalize includes for life in the universe X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=311538d42d9e4df19614119ad00fe6284657708d;p=openbsd move to PATH_MAX, etc; normalize includes for life in the universe ok guenther millert --- diff --git a/bin/systrace/filter.c b/bin/systrace/filter.c index ba366946c38..d10299605ce 100644 --- a/bin/systrace/filter.c +++ b/bin/systrace/filter.c @@ -1,4 +1,4 @@ -/* $OpenBSD: filter.c,v 1.34 2012/12/04 02:24:47 deraadt Exp $ */ +/* $OpenBSD: filter.c,v 1.35 2015/01/16 00:19:12 deraadt Exp $ */ /* * Copyright 2002 Niels Provos * All rights reserved. @@ -502,8 +502,8 @@ filter_ask(int fd, struct intercept_tlq *tls, struct filterq *fls, int policynr, const char *emulation, const char *name, char *output, short *pfuture, struct intercept_pid *icpid) { - char line[2*MAXPATHLEN], *p; - char compose[2*MAXPATHLEN]; + char line[2*PATH_MAX], *p; + char compose[2*PATH_MAX]; struct filter *filter; struct policy *policy; short action; @@ -707,7 +707,7 @@ filter_replace(char *buf, size_t buflen, char *match, char *repl) char * filter_expand(char *data) { - static char expand[2*MAXPATHLEN]; + static char expand[2*PATH_MAX]; strlcpy(expand, data, sizeof(expand)); @@ -722,7 +722,7 @@ char * filter_dynamicexpand(struct intercept_pid *icpid, char *data) { extern char cwd[]; - static char expand[2*MAXPATHLEN]; + static char expand[2*PATH_MAX]; strlcpy(expand, data, sizeof(expand)); diff --git a/bin/systrace/intercept.c b/bin/systrace/intercept.c index 00618f7ce5b..a8d5620d65d 100644 --- a/bin/systrace/intercept.c +++ b/bin/systrace/intercept.c @@ -1,4 +1,4 @@ -/* $OpenBSD: intercept.c,v 1.62 2014/07/20 01:38:40 guenther Exp $ */ +/* $OpenBSD: intercept.c,v 1.63 2015/01/16 00:19:12 deraadt Exp $ */ /* * Copyright 2002 Niels Provos * All rights reserved. @@ -42,6 +42,7 @@ #include #include #include +#include #include #include #include @@ -611,7 +612,7 @@ intercept_filenameat(int fd, pid_t pid, int atfd, void *addr, int userp, char *b goto abort; if (before != NULL) - strlcpy(before, name, MAXPATHLEN); + strlcpy(before, name, PATH_MAX); if ((name = normalize_filenameat(fd, pid, atfd, name, userp)) == NULL) goto abort; @@ -637,7 +638,7 @@ normalize_filename(int fd, pid_t pid, char *name, int userp) char * normalize_filenameat(int fd, pid_t pid, int atfd, char *name, int userp) { - static char cwd[2*MAXPATHLEN]; + static char cwd[2*PATH_MAX]; int havecwd = 0; /* @@ -674,7 +675,7 @@ normalize_filenameat(int fd, pid_t pid, int atfd, char *name, int userp) } if (userp != ICLINK_NONE) { - static char rcwd[2*MAXPATHLEN]; + static char rcwd[2*PATH_MAX]; char *base = basename(cwd); int failed = 0; @@ -780,7 +781,7 @@ intercept_syscall(int fd, pid_t pid, u_int16_t seqnr, int policynr, /* Special handling for the exec call */ if (!strcmp(name, "execve")) { void *addr; - char *argname, before[MAXPATHLEN]; + char *argname, before[PATH_MAX]; icpid->execve_code = code; icpid->policynr = policynr; @@ -1044,7 +1045,7 @@ intercept_realpath(const char *path, char *resolved) struct stat sb; int idx = 0, n, nlnk = 0, serrno = errno; const char *q; - char *p, wbuf[2][MAXPATHLEN]; + char *p, wbuf[2][PATH_MAX]; size_t len; /* @@ -1066,7 +1067,7 @@ intercept_realpath(const char *path, char *resolved) /* If relative path, start from current working directory. */ if (*path != '/') { - if (getcwd(resolved, MAXPATHLEN) == NULL) { + if (getcwd(resolved, PATH_MAX) == NULL) { p[0] = '.'; p[1] = 0; return (NULL); @@ -1111,7 +1112,7 @@ loop: } /* Append this component. */ - if (p - resolved + 1 + q - path + 1 > MAXPATHLEN) { + if (p - resolved + 1 + q - path + 1 > PATH_MAX) { errno = ENAMETOOLONG; if (p == resolved) *p++ = '/'; @@ -1141,7 +1142,7 @@ loop: return (NULL); } if (S_ISLNK(sb.st_mode)) { - if (nlnk++ >= MAXSYMLINKS) { + if (nlnk++ >= SYMLOOP_MAX) { errno = ELOOP; return (NULL); } diff --git a/bin/systrace/intercept.h b/bin/systrace/intercept.h index 9ae38689f65..6d1715161be 100644 --- a/bin/systrace/intercept.h +++ b/bin/systrace/intercept.h @@ -1,4 +1,4 @@ -/* $OpenBSD: intercept.h,v 1.26 2012/08/23 00:08:36 guenther Exp $ */ +/* $OpenBSD: intercept.h,v 1.27 2015/01/16 00:19:12 deraadt Exp $ */ /* * Copyright 2002 Niels Provos * All rights reserved. @@ -31,7 +31,7 @@ #ifndef _INTERCEPT_H_ #define _INTERCEPT_H_ -#include +#include #include struct intercept_pid; @@ -102,7 +102,7 @@ struct intercept_pid { gid_t gid; /* current gid */ char username[LOGIN_NAME_MAX]; - char home[MAXPATHLEN]; /* current home dir for uid */ + char home[PATH_MAX]; /* current home dir for uid */ void *data; diff --git a/bin/systrace/lex.l b/bin/systrace/lex.l index 3d5511d2dcf..87ab4ecddfd 100644 --- a/bin/systrace/lex.l +++ b/bin/systrace/lex.l @@ -1,4 +1,4 @@ -/* $OpenBSD: lex.l,v 1.18 2006/07/02 12:34:15 sturm Exp $ */ +/* $OpenBSD: lex.l,v 1.19 2015/01/16 00:19:12 deraadt Exp $ */ /* * Copyright 2002 Niels Provos @@ -39,6 +39,7 @@ #include #include +#include #include #include #include diff --git a/bin/systrace/openbsd-syscalls.c b/bin/systrace/openbsd-syscalls.c index fac673c99a7..c0151c41bb0 100644 --- a/bin/systrace/openbsd-syscalls.c +++ b/bin/systrace/openbsd-syscalls.c @@ -1,4 +1,4 @@ -/* $OpenBSD: openbsd-syscalls.c,v 1.44 2013/10/17 10:21:58 deraadt Exp $ */ +/* $OpenBSD: openbsd-syscalls.c,v 1.45 2015/01/16 00:19:12 deraadt Exp $ */ /* * Copyright 2002 Niels Provos * All rights reserved. @@ -29,7 +29,6 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include -#include #include @@ -53,6 +52,8 @@ #undef SYSVMSG #undef SYSVSHM +#include + #include #include #include diff --git a/bin/systrace/parse.y b/bin/systrace/parse.y index 567c4fc74fe..bc8cad56df2 100644 --- a/bin/systrace/parse.y +++ b/bin/systrace/parse.y @@ -1,4 +1,4 @@ -/* $OpenBSD: parse.y,v 1.18 2009/11/12 20:07:46 millert Exp $ */ +/* $OpenBSD: parse.y,v 1.19 2015/01/16 00:19:12 deraadt Exp $ */ /* * Copyright 2002 Niels Provos @@ -41,6 +41,7 @@ #include #include #include +#include #include #include #include diff --git a/bin/systrace/policy.c b/bin/systrace/policy.c index 28743812967..f76f114253c 100644 --- a/bin/systrace/policy.c +++ b/bin/systrace/policy.c @@ -1,4 +1,4 @@ -/* $OpenBSD: policy.c,v 1.34 2013/11/21 15:54:46 deraadt Exp $ */ +/* $OpenBSD: policy.c,v 1.35 2015/01/16 00:19:12 deraadt Exp $ */ /* * Copyright 2002 Niels Provos * All rights reserved. @@ -100,7 +100,7 @@ SPLAY_GENERATE(polnrtree, policy, nrnode, polnrcompare) extern int userpolicy; -static char policydir[MAXPATHLEN]; +static char policydir[PATH_MAX]; struct tmplqueue templates; @@ -163,7 +163,7 @@ struct policy * systrace_findpolicy_wildcard(const char *name) { struct policy tmp, *res; - static char path[MAXPATHLEN], lookup[MAXPATHLEN]; + static char path[PATH_MAX], lookup[PATH_MAX]; if (strlcpy(path, name, sizeof(path)) >= sizeof(path)) errx(1, "%s: path name overflow", __func__); @@ -348,7 +348,7 @@ systrace_modifypolicy(int fd, int policynr, const char *name, short action) char * systrace_policyfilename(char *dirname, const char *name) { - static char file[2*MAXPATHLEN]; + static char file[2*PATH_MAX]; const char *p; int i, plen; @@ -419,7 +419,7 @@ systrace_addpolicy(const char *name) int systrace_templatedir(void) { - char filename[MAXPATHLEN]; + char filename[PATH_MAX]; DIR *dir = NULL; struct stat sb; struct dirent *dp; @@ -818,8 +818,8 @@ systrace_writepolicy(struct policy *policy) FILE *fp; int fd; char *p; - char tmpname[2*MAXPATHLEN]; - char finalname[2*MAXPATHLEN]; + char tmpname[2*PATH_MAX]; + char finalname[2*PATH_MAX]; struct filter *filter; struct timeval now; diff --git a/bin/systrace/register.c b/bin/systrace/register.c index 6f8d0cc640a..183ec90582d 100644 --- a/bin/systrace/register.c +++ b/bin/systrace/register.c @@ -1,4 +1,4 @@ -/* $OpenBSD: register.c,v 1.24 2012/12/04 02:24:47 deraadt Exp $ */ +/* $OpenBSD: register.c,v 1.25 2015/01/16 00:19:12 deraadt Exp $ */ /* * Copyright 2002 Niels Provos * All rights reserved. @@ -33,6 +33,7 @@ #include #include #include +#include #include #include diff --git a/bin/systrace/systrace-error.c b/bin/systrace/systrace-error.c index 90ef58c9c52..8992d01b9df 100644 --- a/bin/systrace/systrace-error.c +++ b/bin/systrace/systrace-error.c @@ -1,4 +1,4 @@ -/* $OpenBSD: systrace-error.c,v 1.3 2014/08/10 00:20:55 guenther Exp $ */ +/* $OpenBSD: systrace-error.c,v 1.4 2015/01/16 00:19:12 deraadt Exp $ */ /* * Copyright 2002 Niels Provos * All rights reserved. @@ -34,6 +34,7 @@ #include #include #include +#include #include #include diff --git a/bin/systrace/systrace-translate.c b/bin/systrace/systrace-translate.c index d679031ffd6..d381a30a539 100644 --- a/bin/systrace/systrace-translate.c +++ b/bin/systrace/systrace-translate.c @@ -1,4 +1,4 @@ -/* $OpenBSD: systrace-translate.c,v 1.24 2014/08/10 04:57:33 guenther Exp $ */ +/* $OpenBSD: systrace-translate.c,v 1.25 2015/01/16 00:19:12 deraadt Exp $ */ /* * Copyright 2002 Niels Provos * All rights reserved. @@ -35,6 +35,7 @@ #include #include #include +#include #include #include #include diff --git a/bin/systrace/systrace.c b/bin/systrace/systrace.c index 4b03999c544..2b701d9aa34 100644 --- a/bin/systrace/systrace.c +++ b/bin/systrace/systrace.c @@ -1,4 +1,4 @@ -/* $OpenBSD: systrace.c,v 1.61 2014/11/26 18:34:51 millert Exp $ */ +/* $OpenBSD: systrace.c,v 1.62 2015/01/16 00:19:12 deraadt Exp $ */ /* * Copyright 2002 Niels Provos * All rights reserved. @@ -70,11 +70,11 @@ int iamroot = 0; /* Set if we are running as root */ int cradle = 0; /* Set if we are running in cradle mode */ int logtofile = 0; /* Log to file instead of syslog */ FILE *logfile; /* default logfile to send to if enabled */ -char cwd[MAXPATHLEN]; /* Current working directory */ -char home[MAXPATHLEN]; /* Home directory of user */ +char cwd[PATH_MAX]; /* Current working directory */ +char home[PATH_MAX]; /* Home directory of user */ char username[LOGIN_NAME_MAX]; /* Username: predicate match and expansion */ char *guipath = _PATH_XSYSTRACE; /* Path to GUI executable */ -char dirpath[MAXPATHLEN]; +char dirpath[PATH_MAX]; static struct event ev_read; static struct event ev_timeout; @@ -537,7 +537,7 @@ static void cradle_setup(char *pathtogui) { struct stat sb; - char cradlepath[MAXPATHLEN], cradleuipath[MAXPATHLEN]; + char cradlepath[PATH_MAX], cradleuipath[PATH_MAX]; snprintf(dirpath, sizeof(dirpath), "/tmp/systrace-%d", getuid());