From 24b22a50550128af6e6470ee4624ea7b1d51388b Mon Sep 17 00:00:00 2001 From: doug Date: Fri, 16 Jan 2015 08:24:04 +0000 Subject: [PATCH] Replace with This patch is from Theo. I helped verify that removing doesn't change anything. This produces the same binaries before and after with clang 3.5 and gcc 4.9.4 on amd64. There is a slight difference in the way it is generated by our old gcc 4.2.1 despite the fact that the preprocessed input is almost identical. ok deraadt@ --- usr.bin/file/apprentice.c | 12 ++++++------ usr.bin/file/file.c | 9 ++++----- usr.bin/file/magic.c | 3 +-- 3 files changed, 11 insertions(+), 13 deletions(-) diff --git a/usr.bin/file/apprentice.c b/usr.bin/file/apprentice.c index e19382a19a8..1c6a49e96e6 100644 --- a/usr.bin/file/apprentice.c +++ b/usr.bin/file/apprentice.c @@ -1,4 +1,4 @@ -/* $OpenBSD: apprentice.c,v 1.32 2014/10/26 04:10:26 brad Exp $ */ +/* $OpenBSD: apprentice.c,v 1.33 2015/01/16 08:24:04 doug Exp $ */ /* * Copyright (c) Ian F. Darwin 1986-1995. * Software written by Ian F. Darwin and others; @@ -30,7 +30,7 @@ * apprentice - make one pass through /etc/magic, learning its secrets. */ -#include + #include #include @@ -73,8 +73,8 @@ #define MAP_FILE 0 #endif -#ifndef MAXPATHLEN -#define MAXPATHLEN 1024 +#ifndef PATH_MAX +#define PATH_MAX 1024 #endif struct magic_entry { @@ -620,7 +620,7 @@ apprentice_load(struct magic_set *ms, struct magic **magicp, uint32_t *nmagicp, int errs = 0; struct magic_entry *marray; uint32_t marraycount, i, mentrycount = 0, starttest; - char subfn[MAXPATHLEN]; + char subfn[PATH_MAX]; struct stat st; DIR *dir; struct dirent *d; @@ -2034,7 +2034,7 @@ mkdbname(const char *fn, char **buf, int strip) } (void)asprintf(buf, "%s%s", fn, ext); - if (*buf && strlen(*buf) > MAXPATHLEN) { + if (*buf && strlen(*buf) > PATH_MAX) { free(*buf); *buf = NULL; } diff --git a/usr.bin/file/file.c b/usr.bin/file/file.c index 168583572a8..310bce7b15d 100644 --- a/usr.bin/file/file.c +++ b/usr.bin/file/file.c @@ -1,4 +1,4 @@ -/* $OpenBSD: file.c,v 1.24 2015/01/16 05:46:44 deraadt Exp $ */ +/* $OpenBSD: file.c,v 1.25 2015/01/16 08:24:04 doug Exp $ */ /* * Copyright (c) Ian F. Darwin 1986-1995. * Software written by Ian F. Darwin and others; @@ -31,7 +31,6 @@ */ #include -#include /* for MAXPATHLEN */ #include #include "file.h" @@ -81,8 +80,8 @@ int getopt_long(int argc, char * const *argv, const char *optstring, const struc # define USAGE "Usage: %s [-bcik" SYMLINKFLAG "nNprsvz0] [-e test] [-f namefile] [-F separator] [-m magicfiles] file...\n" \ " %s -C -m magicfiles\n" -#ifndef MAXPATHLEN -#define MAXPATHLEN 1024 +#ifndef PATH_MAX +#define PATH_MAX 1024 #endif private int /* Global command-line options */ @@ -355,7 +354,7 @@ load(const char *m, int flags) private void unwrap(char *fn) { - char buf[MAXPATHLEN]; + char buf[PATH_MAX]; FILE *f; int wid = 0, cwid; diff --git a/usr.bin/file/magic.c b/usr.bin/file/magic.c index eab02d13832..0e9fd1c66c6 100644 --- a/usr.bin/file/magic.c +++ b/usr.bin/file/magic.c @@ -1,4 +1,4 @@ -/* $OpenBSD: magic.c,v 1.9 2014/10/11 03:06:44 doug Exp $ */ +/* $OpenBSD: magic.c,v 1.10 2015/01/16 08:24:04 doug Exp $ */ /* * Copyright (c) Christos Zoulas 2003. * All Rights Reserved. @@ -27,7 +27,6 @@ */ #include -#include /* for MAXPATHLEN */ #include #include "file.h" -- 2.20.1