diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 2015-01-16 06:40:24 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 2015-01-16 06:40:24 +0000 |
commit | 315054f4737a39489e0a14f3a92bff61f1592832 (patch) | |
tree | 62bf010653374ce09b6beb4dfa0414a91457233b /usr.sbin/ypserv | |
parent | 79e3d817585ca08a91e30ad14abe43e2ab70295f (diff) |
Replace <sys/param.h> with <limits.h> and other less dirty headers where
possible. Annotate <sys/param.h> lines with their current reasons. Switch
to PATH_MAX, NGROUPS_MAX, HOST_NAME_MAX+1, LOGIN_NAME_MAX, etc. Change
MIN() and MAX() to local definitions of MINIMUM() and MAXIMUM() where
sensible to avoid pulling in the pollution. These are the files confirmed
through binary verification.
ok guenther, millert, doug (helped with the verification protocol)
Diffstat (limited to 'usr.sbin/ypserv')
-rw-r--r-- | usr.sbin/ypserv/common/ypdb.c | 5 | ||||
-rw-r--r-- | usr.sbin/ypserv/common/yplib_host.c | 3 | ||||
-rw-r--r-- | usr.sbin/ypserv/makedbm/db.c | 5 | ||||
-rw-r--r-- | usr.sbin/ypserv/makedbm/makedbm.c | 13 | ||||
-rw-r--r-- | usr.sbin/ypserv/mkalias/mkalias.c | 13 | ||||
-rw-r--r-- | usr.sbin/ypserv/mknetid/mknetid.c | 8 | ||||
-rw-r--r-- | usr.sbin/ypserv/yppush/yppush.c | 8 | ||||
-rw-r--r-- | usr.sbin/ypserv/ypserv/ypserv_db.c | 9 | ||||
-rw-r--r-- | usr.sbin/ypserv/ypserv/ypserv_proc.c | 13 | ||||
-rw-r--r-- | usr.sbin/ypserv/ypxfr/ypxfr.c | 8 |
10 files changed, 39 insertions, 46 deletions
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 */ |