From bf0193d8cd0ca4e683146c29a671bf62f193ec92 Mon Sep 17 00:00:00 2001 From: deraadt Date: Thu, 21 Oct 2021 10:55:56 +0000 Subject: [PATCH] Avoid sys/param.h, or annotate reasons for including where required. This includes using HOST_NAME_MAX and PATH_MAX in snaps for around 3 weeks, noone noticed a change in behaviour. --- usr.sbin/amd/amd/afs_ops.c | 6 +++--- usr.sbin/amd/amd/amd.c | 8 ++++---- usr.sbin/amd/amd/get_args.c | 6 +++--- usr.sbin/amd/amd/host_ops.c | 6 +++--- usr.sbin/amd/amd/info_passwd.c | 4 ++-- usr.sbin/amd/amd/mapc.c | 8 ++++---- usr.sbin/amd/amd/nfs_ops.c | 4 ++-- usr.sbin/amd/amd/opts.c | 4 ++-- usr.sbin/amd/include/am.h | 4 ++-- 9 files changed, 25 insertions(+), 25 deletions(-) diff --git a/usr.sbin/amd/amd/afs_ops.c b/usr.sbin/amd/amd/afs_ops.c index 120e1af41f7..a2c02509263 100644 --- a/usr.sbin/amd/amd/afs_ops.c +++ b/usr.sbin/amd/amd/afs_ops.c @@ -1,4 +1,4 @@ -/* $OpenBSD: afs_ops.c,v 1.19 2014/10/26 03:28:41 guenther Exp $ */ +/* $OpenBSD: afs_ops.c,v 1.20 2021/10/21 10:55:56 deraadt Exp $ */ /* * Copyright (c) 1990 Jan-Simon Pendry @@ -103,7 +103,7 @@ mount_toplvl(char *dir, char *opts) unsigned short port; int flags; nfs_fh *fhp; - char fs_hostname[MAXHOSTNAMELEN+MAXPATHLEN+1]; + char fs_hostname[HOST_NAME_MAX+1 + PATH_MAX+1]; const char *type = MOUNT_NFS; @@ -1128,7 +1128,7 @@ afs_lookuppn(am_node *mp, char *fname, int *error_return, int op) char **ivec, **xivec; /* Split version of info */ char *auto_opts; /* Automount options */ int error = 0; /* Error so far */ - char path_name[MAXPATHLEN]; /* General path name buffer */ + char path_name[PATH_MAX]; /* General path name buffer */ char *pfname; /* Path for database lookup */ struct continuation *cp; /* Continuation structure if we need to mount */ int in_progress = 0; /* # of (un)mount in progress */ diff --git a/usr.sbin/amd/amd/amd.c b/usr.sbin/amd/amd/amd.c index b41ee0be9ee..03163b129d1 100644 --- a/usr.sbin/amd/amd/amd.c +++ b/usr.sbin/amd/amd/amd.c @@ -32,7 +32,7 @@ * SUCH DAMAGE. * * from: @(#)amd.c 8.1 (Berkeley) 6/6/93 - * $Id: amd.c,v 1.23 2019/06/28 13:32:46 deraadt Exp $ + * $Id: amd.c,v 1.24 2021/10/21 10:55:56 deraadt Exp $ */ /* @@ -60,7 +60,7 @@ #error "unknown endian" #endif -char pid_fsname[16 + MAXHOSTNAMELEN]; /* "kiska.southseas.nz:(pid%d)" */ +char pid_fsname[16 + HOST_NAME_MAX+1]; /* "kiska.southseas.nz:(pid%d)" */ #ifdef HAS_HOST #ifdef HOST_EXEC char *host_helper; @@ -68,8 +68,8 @@ char *host_helper; #endif /* HAS_HOST */ char *auto_dir = "/tmp_mnt"; char *hostdomain = "unknown.domain"; -char hostname[MAXHOSTNAMELEN] = "localhost"; /* Hostname */ -char hostd[2*MAXHOSTNAMELEN]; /* Host+domain */ +char hostname[HOST_NAME_MAX+1] = "localhost"; /* Hostname */ +char hostd[2*(HOST_NAME_MAX+1)]; /* Host+domain */ char *op_sys = "bsd44"; /* Name of current op_sys */ char *arch = ARCH_REP; /* Name of current architecture */ char *endian = ARCH_ENDIAN; /* Big or Little endian */ diff --git a/usr.sbin/amd/amd/get_args.c b/usr.sbin/amd/amd/get_args.c index 5e930bcc173..3a7bb68fb47 100644 --- a/usr.sbin/amd/amd/get_args.c +++ b/usr.sbin/amd/amd/get_args.c @@ -32,7 +32,7 @@ * SUCH DAMAGE. * * from: @(#)get_args.c 8.1 (Berkeley) 6/6/93 - * $Id: get_args.c,v 1.14 2014/10/20 02:33:42 guenther Exp $ + * $Id: get_args.c,v 1.15 2021/10/21 10:55:56 deraadt Exp $ */ /* @@ -245,8 +245,8 @@ get_args(int c, char *v[]) hostdomain = sub_domain; if (*hostdomain == '.') hostdomain++; - strlcat(hostd, ".", 2 * MAXHOSTNAMELEN); - strlcat(hostd, hostdomain, 2 * MAXHOSTNAMELEN); + strlcat(hostd, ".", 2 * (HOST_NAME_MAX+1)); + strlcat(hostd, hostdomain, 2 * (HOST_NAME_MAX+1)); #ifdef DEBUG { if (debug_flags & D_MTAB) { diff --git a/usr.sbin/amd/amd/host_ops.c b/usr.sbin/amd/amd/host_ops.c index 0045265b04d..33774db477e 100644 --- a/usr.sbin/amd/amd/host_ops.c +++ b/usr.sbin/amd/amd/host_ops.c @@ -1,4 +1,4 @@ -/* $OpenBSD: host_ops.c,v 1.19 2015/12/05 21:15:01 mmcc Exp $ */ +/* $OpenBSD: host_ops.c,v 1.20 2021/10/21 10:55:56 deraadt Exp $ */ /* * Copyright (c) 1990 Jan-Simon Pendry @@ -226,8 +226,8 @@ host_fmount(mntfs *mf) int sock = RPC_ANYSOCK; int ok = FALSE; mntlist *mlist; - char fs_name[MAXPATHLEN], *rfs_dir; - char mntpt[MAXPATHLEN]; + char fs_name[PATH_MAX], *rfs_dir; + char mntpt[PATH_MAX]; struct timeval tv; tv.tv_sec = 10; tv.tv_usec = 0; diff --git a/usr.sbin/amd/amd/info_passwd.c b/usr.sbin/amd/amd/info_passwd.c index 2a70c22a2bd..336dc887898 100644 --- a/usr.sbin/amd/amd/info_passwd.c +++ b/usr.sbin/amd/amd/info_passwd.c @@ -32,7 +32,7 @@ * SUCH DAMAGE. * * from: @(#)info_passwd.c 8.1 (Berkeley) 6/6/93 - * $Id: info_passwd.c,v 1.10 2015/12/05 21:15:01 mmcc Exp $ + * $Id: info_passwd.c,v 1.11 2021/10/21 10:55:56 deraadt Exp $ */ /* @@ -86,7 +86,7 @@ passwd_search(mnt_map *m, char *map, char *key, char **pval, time_t *tp) * This allows cross-domain entries in your passwd file. * ... but forget about security! */ - char val[MAXPATHLEN], rhost[MAXHOSTNAMELEN]; + char val[PATH_MAX], rhost[HOST_NAME_MAX+1]; char *user, *p, *q; dir = strdup(pw->pw_dir); diff --git a/usr.sbin/amd/amd/mapc.c b/usr.sbin/amd/amd/mapc.c index 9e546de92c4..04d594e9cc5 100644 --- a/usr.sbin/amd/amd/mapc.c +++ b/usr.sbin/amd/amd/mapc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mapc.c,v 1.23 2015/12/05 21:15:01 mmcc Exp $ */ +/* $OpenBSD: mapc.c,v 1.24 2021/10/21 10:55:56 deraadt Exp $ */ /*- * Copyright (c) 1989 Jan-Simon Pendry @@ -246,7 +246,7 @@ mapc_add_kv(mnt_map *m, char *key, char *val) #endif if (MAPC_ISRE(m)) { - char keyb[MAXPATHLEN]; + char keyb[PATH_MAX]; regex_t *re; int err; @@ -621,7 +621,7 @@ mapc_meta_search(mnt_map *m, char *key, char **pval, int recurse) */ if (error > 0) { if (recurse == MREC_FULL && !MAPC_ISRE(m)) { - char wildname[MAXPATHLEN]; + char wildname[PATH_MAX]; char *subp; if (*key == '/') return error; @@ -721,7 +721,7 @@ root_init(char *map, time_t *tp) void root_newmap(char *dir, char *opts, char *map) { - char str[MAXPATHLEN]; + char str[PATH_MAX]; /* * First make sure we have a root map to talk about... diff --git a/usr.sbin/amd/amd/nfs_ops.c b/usr.sbin/amd/amd/nfs_ops.c index 6e7d8ee3a03..7c2e01e6a16 100644 --- a/usr.sbin/amd/amd/nfs_ops.c +++ b/usr.sbin/amd/amd/nfs_ops.c @@ -1,4 +1,4 @@ -/* $OpenBSD: nfs_ops.c,v 1.26 2014/10/26 03:28:41 guenther Exp $ */ +/* $OpenBSD: nfs_ops.c,v 1.27 2021/10/21 10:55:56 deraadt Exp $ */ /*- * Copyright (c) 1990 Jan-Simon Pendry @@ -453,7 +453,7 @@ mount_nfs_fh(fhstatus *fhp, char *dir, char *fs_name, char *opts, int retry; char *colon; /*char *path;*/ - char host[MAXHOSTNAMELEN + MAXPATHLEN + 2]; + char host[HOST_NAME_MAX+1 + PATH_MAX+2]; fserver *fs = mf->mf_server; int flags; char *xopts; diff --git a/usr.sbin/amd/amd/opts.c b/usr.sbin/amd/amd/opts.c index e94a1704aa6..8bce2a93df4 100644 --- a/usr.sbin/amd/amd/opts.c +++ b/usr.sbin/amd/amd/opts.c @@ -375,10 +375,10 @@ expand_op(opt_apply *p, int sel_p) * give up completely. This is done to avoid crashing the * automounter itself (which would be a bad thing to do). */ -#define BUFSPACE(ep, len) (((ep) + (len)) < expbuf+MAXPATHLEN) +#define BUFSPACE(ep, len) (((ep) + (len)) < expbuf+PATH_MAX) static char expand_error[] = "No space to expand \"%s\""; - char expbuf[MAXPATHLEN+1]; + char expbuf[PATH_MAX+1]; char nbuf[NLEN+1]; char *ep = expbuf; char *cp = *p->opt; diff --git a/usr.sbin/amd/include/am.h b/usr.sbin/amd/include/am.h index 1f4da931405..377c0d52539 100644 --- a/usr.sbin/amd/include/am.h +++ b/usr.sbin/amd/include/am.h @@ -1,4 +1,4 @@ -/* $OpenBSD: am.h,v 1.19 2015/09/11 19:03:31 millert Exp $ */ +/* $OpenBSD: am.h,v 1.20 2021/10/21 10:55:56 deraadt Exp $ */ /* * Copyright (c) 1990 Jan-Simon Pendry @@ -41,7 +41,7 @@ /* * Global declarations */ -#include +#include #include #include #include -- 2.20.1