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 /sbin/restore | |
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 'sbin/restore')
-rw-r--r-- | sbin/restore/dirs.c | 13 | ||||
-rw-r--r-- | sbin/restore/interactive.c | 19 | ||||
-rw-r--r-- | sbin/restore/main.c | 7 | ||||
-rw-r--r-- | sbin/restore/symtab.c | 10 | ||||
-rw-r--r-- | sbin/restore/tape.c | 9 | ||||
-rw-r--r-- | sbin/restore/utilities.c | 8 |
6 files changed, 35 insertions, 31 deletions
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; |