summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>2015-01-16 06:40:24 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>2015-01-16 06:40:24 +0000
commit315054f4737a39489e0a14f3a92bff61f1592832 (patch)
tree62bf010653374ce09b6beb4dfa0414a91457233b /usr.bin
parent79e3d817585ca08a91e30ad14abe43e2ab70295f (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.bin')
-rw-r--r--usr.bin/arch/arch.c2
-rw-r--r--usr.bin/aucat/aparams.c4
-rw-r--r--usr.bin/aucat/aparams.h4
-rw-r--r--usr.bin/aucat/aucat.c4
-rw-r--r--usr.bin/aucat/headers.c4
-rw-r--r--usr.bin/bgplg/bgplg.c8
-rw-r--r--usr.bin/bgplg/bgplgsh.c8
-rw-r--r--usr.bin/calendar/io.c4
-rw-r--r--usr.bin/cap_mkdb/cap_mkdb.c12
-rw-r--r--usr.bin/cdio/cddb.c6
-rw-r--r--usr.bin/cdio/cdio.c7
-rw-r--r--usr.bin/cdio/mmc.c4
-rw-r--r--usr.bin/chpass/chpass.c3
-rw-r--r--usr.bin/chpass/edit.c4
-rw-r--r--usr.bin/chpass/field.c5
-rw-r--r--usr.bin/cmp/regular.c7
-rw-r--r--usr.bin/compress/gzopen.c6
-rw-r--r--usr.bin/compress/main.c12
-rw-r--r--usr.bin/compress/zopen.c7
-rw-r--r--usr.bin/cu/cu.c6
-rw-r--r--usr.bin/cvs/add.c32
-rw-r--r--usr.bin/cvs/admin.c12
-rw-r--r--usr.bin/cvs/annotate.c4
-rw-r--r--usr.bin/cvs/atomicio.c4
-rw-r--r--usr.bin/cvs/checkout.c12
-rw-r--r--usr.bin/cvs/client.c44
-rw-r--r--usr.bin/cvs/cmd.c4
-rw-r--r--usr.bin/cvs/commit.c26
-rw-r--r--usr.bin/cvs/config.c6
-rw-r--r--usr.bin/cvs/cvs.c10
-rw-r--r--usr.bin/cvs/diff3.c4
-rw-r--r--usr.bin/cvs/diff_internals.c25
-rw-r--r--usr.bin/cvs/edit.c16
-rw-r--r--usr.bin/cvs/entries.c16
-rw-r--r--usr.bin/cvs/file.c42
-rw-r--r--usr.bin/cvs/hash.c4
-rw-r--r--usr.bin/cvs/history.c4
-rw-r--r--usr.bin/cvs/import.c8
-rw-r--r--usr.bin/cvs/init.c12
-rw-r--r--usr.bin/cvs/logmsg.c4
-rw-r--r--usr.bin/cvs/modules.c6
-rw-r--r--usr.bin/cvs/rcs.c8
-rw-r--r--usr.bin/cvs/rcsnum.c8
-rw-r--r--usr.bin/cvs/release.c4
-rw-r--r--usr.bin/cvs/remote.c7
-rw-r--r--usr.bin/cvs/remove.c4
-rw-r--r--usr.bin/cvs/repository.c12
-rw-r--r--usr.bin/cvs/root.c6
-rw-r--r--usr.bin/cvs/server.c40
-rw-r--r--usr.bin/cvs/status.c4
-rw-r--r--usr.bin/cvs/tag.c6
-rw-r--r--usr.bin/cvs/trigger.c10
-rw-r--r--usr.bin/cvs/update.c12
-rw-r--r--usr.bin/cvs/util.c14
-rw-r--r--usr.bin/cvs/worklist.h7
-rw-r--r--usr.bin/diff/diff.c4
-rw-r--r--usr.bin/diff/diffdir.c10
-rw-r--r--usr.bin/diff/diffreg.c27
-rw-r--r--usr.bin/find/function.c14
-rw-r--r--usr.bin/find/ls.c6
-rw-r--r--usr.bin/finger/finger.c6
-rw-r--r--usr.bin/finger/net.c3
-rw-r--r--usr.bin/finger/util.c3
-rw-r--r--usr.bin/from/from.c6
-rw-r--r--usr.bin/fstat/fstat.c8
-rw-r--r--usr.bin/fstat/fuser.c3
-rw-r--r--usr.bin/ftp/cmds.c16
-rw-r--r--usr.bin/ftp/complete.c10
-rw-r--r--usr.bin/ftp/fetch.c6
-rw-r--r--usr.bin/ftp/ftp.c12
-rw-r--r--usr.bin/ftp/ftp_var.h11
-rw-r--r--usr.bin/ftp/main.c5
-rw-r--r--usr.bin/ftp/ruserpass.c6
-rw-r--r--usr.bin/ftp/small.c10
-rw-r--r--usr.bin/ftp/util.c23
-rw-r--r--usr.bin/getent/getent.c4
-rw-r--r--usr.bin/gprof/hertz.c3
-rw-r--r--usr.bin/grep/file.c7
-rw-r--r--usr.bin/grep/mmfile.c3
-rw-r--r--usr.bin/grep/queue.c4
-rw-r--r--usr.bin/hexdump/display.c7
-rw-r--r--usr.bin/hexdump/hexdump.c7
-rw-r--r--usr.bin/id/id.c19
-rw-r--r--usr.bin/indent/indent.c8
-rw-r--r--usr.bin/ipcs/ipcs.c4
-rw-r--r--usr.bin/join/join.c8
-rw-r--r--usr.bin/kdump/kdump.c5
-rw-r--r--usr.bin/ktrace/ktrace.c5
-rw-r--r--usr.bin/ktrace/subr.c4
-rw-r--r--usr.bin/lam/lam.c4
-rw-r--r--usr.bin/last/last.c6
-rw-r--r--usr.bin/lastcomm/lastcomm.c4
-rw-r--r--usr.bin/leave/leave.c3
-rw-r--r--usr.bin/lndir/lndir.c8
-rw-r--r--usr.bin/locate/bigram/locate.bigram.c10
-rw-r--r--usr.bin/locate/code/locate.code.c11
-rw-r--r--usr.bin/locate/locate/fastfind.c8
-rw-r--r--usr.bin/locate/locate/locate.c8
-rw-r--r--usr.bin/locate/locate/util.c22
-rw-r--r--usr.bin/lock/lock.c6
-rw-r--r--usr.bin/login/failedlogin.c3
-rw-r--r--usr.bin/login/login.c10
-rw-r--r--usr.bin/m4/gnum4.c6
-rw-r--r--usr.bin/mail/aux.c6
-rw-r--r--usr.bin/mail/def.h8
-rw-r--r--usr.bin/mail/main.c4
-rw-r--r--usr.bin/mail/popen.c4
-rw-r--r--usr.bin/man/man.c3
-rw-r--r--usr.bin/netstat/if.c4
-rw-r--r--usr.bin/netstat/inet.c5
-rw-r--r--usr.bin/netstat/inet6.c7
-rw-r--r--usr.bin/netstat/main.c4
-rw-r--r--usr.bin/netstat/mbuf.c4
-rw-r--r--usr.bin/netstat/mroute.c4
-rw-r--r--usr.bin/netstat/mroute6.c4
-rw-r--r--usr.bin/netstat/net80211.c4
-rw-r--r--usr.bin/netstat/route.c4
-rw-r--r--usr.bin/netstat/show.c8
-rw-r--r--usr.bin/netstat/unix.c4
-rw-r--r--usr.bin/newsyslog/newsyslog.c24
-rw-r--r--usr.bin/nfsstat/nfsstat.c4
-rw-r--r--usr.bin/nm/elf.c4
-rw-r--r--usr.bin/nm/nm.c4
-rw-r--r--usr.bin/nohup/nohup.c6
-rw-r--r--usr.bin/passwd/yp_passwd.c3
-rw-r--r--usr.bin/patch/util.c7
-rw-r--r--usr.bin/pctr/pctr.c3
-rw-r--r--usr.bin/pkill/pkill.c6
-rw-r--r--usr.bin/quota/quota.c6
-rw-r--r--usr.bin/rcs/ci.c4
-rw-r--r--usr.bin/rcs/co.c4
-rw-r--r--usr.bin/rcs/diff.c26
-rw-r--r--usr.bin/rcs/diff3.c4
-rw-r--r--usr.bin/rcs/rcs.c9
-rw-r--r--usr.bin/rcs/rcsclean.c4
-rw-r--r--usr.bin/rcs/rcsdiff.c4
-rw-r--r--usr.bin/rcs/rcsmerge.c4
-rw-r--r--usr.bin/rcs/rcsnum.c9
-rw-r--r--usr.bin/rcs/rcsprog.c6
-rw-r--r--usr.bin/rcs/rcsutil.c8
-rw-r--r--usr.bin/rcs/rlog.c4
-rw-r--r--usr.bin/rcs/worklist.h7
-rw-r--r--usr.bin/rdist/client.c26
-rw-r--r--usr.bin/rdist/common.c4
-rw-r--r--usr.bin/rdist/defs.h4
-rw-r--r--usr.bin/rdist/message.c4
-rw-r--r--usr.bin/rdistd/filesys-os.c6
-rw-r--r--usr.bin/rdistd/filesys.c8
-rw-r--r--usr.bin/rdistd/server.c24
-rw-r--r--usr.bin/rpcgen/rpc_main.c6
-rw-r--r--usr.bin/rup/rup.c3
-rw-r--r--usr.bin/rusers/rusers.c20
-rw-r--r--usr.bin/rwall/rwall.c6
-rw-r--r--usr.bin/sdiff/sdiff.c3
-rw-r--r--usr.bin/sendbug/sendbug.c3
-rw-r--r--usr.bin/skeyaudit/skeyaudit.c5
-rw-r--r--usr.bin/skeyinit/skeyinit.c6
-rw-r--r--usr.bin/sndiod/sndiod.c3
-rw-r--r--usr.bin/sort/msort.c4
-rw-r--r--usr.bin/sort/sort.h4
-rw-r--r--usr.bin/sort/tmp.c4
-rw-r--r--usr.bin/spell/spellprog.c3
-rw-r--r--usr.bin/split/split.c6
-rw-r--r--usr.bin/ssh/atomicio.c4
-rw-r--r--usr.bin/ssh/misc.c6
-rw-r--r--usr.bin/ssh/readconf.c3
-rw-r--r--usr.bin/ssh/scp.c9
-rw-r--r--usr.bin/ssh/servconf.c5
-rw-r--r--usr.bin/ssh/session.c6
-rw-r--r--usr.bin/ssh/ssh-add.c6
-rw-r--r--usr.bin/ssh/ssh-agent.c9
-rw-r--r--usr.bin/ssh/ssh-keygen.c12
-rw-r--r--usr.bin/ssh/sshkey.c5
-rw-r--r--usr.bin/ssh/sshlogin.c4
-rw-r--r--usr.bin/ssh/uidswap.c4
-rw-r--r--usr.bin/ssh/xmalloc.c4
-rw-r--r--usr.bin/su/su.c8
-rw-r--r--usr.bin/talk/get_names.c6
-rw-r--r--usr.bin/telnet/commands.c7
-rw-r--r--usr.bin/tftp/main.c6
-rw-r--r--usr.bin/tic/progs.priv.h6
-rw-r--r--usr.bin/time/time.c3
-rw-r--r--usr.bin/tmux/procname.c5
-rw-r--r--usr.bin/top/machine.c5
-rw-r--r--usr.bin/top/utils.c5
-rw-r--r--usr.bin/tput/tput.c9
-rw-r--r--usr.bin/uname/uname.c4
-rw-r--r--usr.bin/uudecode/uudecode.c12
-rw-r--r--usr.bin/uuencode/uuencode.c3
-rw-r--r--usr.bin/vacation/vacation.c3
-rw-r--r--usr.bin/vi/common/exf.c9
-rw-r--r--usr.bin/vi/common/key.c9
-rw-r--r--usr.bin/vi/common/msg.c5
-rw-r--r--usr.bin/vi/common/recover.c15
-rw-r--r--usr.bin/vi/common/seq.c9
-rw-r--r--usr.bin/vi/common/util.c7
-rw-r--r--usr.bin/vi/ex/ex_cd.c5
-rw-r--r--usr.bin/vi/ex/ex_cscope.c11
-rw-r--r--usr.bin/vi/ex/ex_filter.c5
-rw-r--r--usr.bin/vi/ex/ex_init.c7
-rw-r--r--usr.bin/vi/ex/ex_shell.c11
-rw-r--r--usr.bin/vi/ex/ex_subst.c9
-rw-r--r--usr.bin/vi/ex/ex_tag.c5
-rw-r--r--usr.bin/vi/vi/v_scroll.c9
-rw-r--r--usr.bin/vi/vi/v_txt.c7
-rw-r--r--usr.bin/vmstat/dkstats.c3
-rw-r--r--usr.bin/vmstat/vmstat.c4
-rw-r--r--usr.bin/w/proc_compare.c4
-rw-r--r--usr.bin/w/w.c9
-rw-r--r--usr.bin/wall/wall.c6
-rw-r--r--usr.bin/wc/wc.c8
-rw-r--r--usr.bin/which/which.c6
-rw-r--r--usr.bin/write/write.c10
-rw-r--r--usr.bin/x99token/x99token.c7
-rw-r--r--usr.bin/xargs/xargs.c3
-rw-r--r--usr.bin/xinstall/xinstall.c21
-rw-r--r--usr.bin/ypcat/ypcat.c3
-rw-r--r--usr.bin/ypmatch/ypmatch.c3
-rw-r--r--usr.bin/ypwhich/ypwhich.c3
219 files changed, 859 insertions, 842 deletions
diff --git a/usr.bin/arch/arch.c b/usr.bin/arch/arch.c
index e0e5ad13784..2b5a3fe584e 100644
--- a/usr.bin/arch/arch.c
+++ b/usr.bin/arch/arch.c
@@ -23,7 +23,7 @@
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include <sys/param.h>
+#include <sys/param.h> /* MACHINE MACHINE_ARCH */
#include <err.h>
#include <locale.h>
diff --git a/usr.bin/aucat/aparams.c b/usr.bin/aucat/aparams.c
index 8202aacde1c..7fe727ec9ac 100644
--- a/usr.bin/aucat/aparams.c
+++ b/usr.bin/aucat/aparams.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: aparams.c,v 1.14 2012/04/11 06:05:43 ratchov Exp $ */
+/* $OpenBSD: aparams.c,v 1.15 2015/01/16 06:40:05 deraadt Exp $ */
/*
* Copyright (c) 2008 Alexandre Ratchov <alex@caoua.org>
*
@@ -15,6 +15,8 @@
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
+#include <endian.h>
+
#include "aparams.h"
#ifdef DEBUG
#include "dbg.h"
diff --git a/usr.bin/aucat/aparams.h b/usr.bin/aucat/aparams.h
index 3cbaf1a383b..c9c59b81862 100644
--- a/usr.bin/aucat/aparams.h
+++ b/usr.bin/aucat/aparams.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: aparams.h,v 1.12 2012/04/11 06:05:43 ratchov Exp $ */
+/* $OpenBSD: aparams.h,v 1.13 2015/01/16 06:40:05 deraadt Exp $ */
/*
* Copyright (c) 2008 Alexandre Ratchov <alex@caoua.org>
*
@@ -17,8 +17,6 @@
#ifndef APARAMS_H
#define APARAMS_H
-#include <sys/param.h>
-
#define NCHAN_MAX 16 /* max channel in a stream */
#define RATE_MIN 4000 /* min sample rate */
#define RATE_MAX 192000 /* max sample rate */
diff --git a/usr.bin/aucat/aucat.c b/usr.bin/aucat/aucat.c
index df6ee65b2be..ea3a78816b3 100644
--- a/usr.bin/aucat/aucat.c
+++ b/usr.bin/aucat/aucat.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: aucat.c,v 1.144 2013/11/18 17:51:59 ratchov Exp $ */
+/* $OpenBSD: aucat.c,v 1.145 2015/01/16 06:40:05 deraadt Exp $ */
/*
* Copyright (c) 2008 Alexandre Ratchov <alex@caoua.org>
*
@@ -14,7 +14,7 @@
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
-#include <sys/param.h>
+
#include <sys/queue.h>
#include <sys/stat.h>
#include <sys/types.h>
diff --git a/usr.bin/aucat/headers.c b/usr.bin/aucat/headers.c
index 5a338a87b6b..b69e1c539a1 100644
--- a/usr.bin/aucat/headers.c
+++ b/usr.bin/aucat/headers.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: headers.c,v 1.23 2013/11/18 17:37:45 ratchov Exp $ */
+/* $OpenBSD: headers.c,v 1.24 2015/01/16 06:40:05 deraadt Exp $ */
/*
* Copyright (c) 2008 Alexandre Ratchov <alex@caoua.org>
*
@@ -15,8 +15,6 @@
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
-#include <sys/param.h>
-
#include <err.h>
#include <stdio.h>
#include <stdint.h>
diff --git a/usr.bin/bgplg/bgplg.c b/usr.bin/bgplg/bgplg.c
index 5b92bdd6b17..89536ce66fa 100644
--- a/usr.bin/bgplg/bgplg.c
+++ b/usr.bin/bgplg/bgplg.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: bgplg.c,v 1.12 2013/11/25 18:02:50 deraadt Exp $ */
+/* $OpenBSD: bgplg.c,v 1.13 2015/01/16 06:40:06 deraadt Exp $ */
/*
* Copyright (c) 2005, 2006 Reyk Floeter <reyk@openbsd.org>
@@ -16,15 +16,15 @@
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
-#include <sys/stat.h>
#include <sys/types.h>
-#include <sys/param.h>
+#include <sys/stat.h>
#include <stdio.h>
#include <stdlib.h>
#include <signal.h>
#include <string.h>
#include <unistd.h>
+#include <limits.h>
#include <ctype.h>
#include <errno.h>
#include <fcntl.h>
@@ -247,7 +247,7 @@ main(void)
{
char *query, *self, *cmd = NULL, *req;
char **argv = NULL;
- char myname[MAXHOSTNAMELEN];
+ char myname[HOST_NAME_MAX+1];
int ret = 1, argc = 0, query_length = 0;
struct stat st;
u_int i;
diff --git a/usr.bin/bgplg/bgplgsh.c b/usr.bin/bgplg/bgplgsh.c
index 85f27fbe552..22b34e9cb9a 100644
--- a/usr.bin/bgplg/bgplgsh.c
+++ b/usr.bin/bgplg/bgplgsh.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: bgplgsh.c,v 1.6 2013/11/25 18:02:50 deraadt Exp $ */
+/* $OpenBSD: bgplgsh.c,v 1.7 2015/01/16 06:40:06 deraadt Exp $ */
/*
* Copyright (c) 2005, 2006 Reyk Floeter <reyk@openbsd.org>
@@ -16,15 +16,15 @@
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
-#include <sys/stat.h>
#include <sys/types.h>
-#include <sys/param.h>
+#include <sys/stat.h>
#include <stdio.h>
#include <stdlib.h>
#include <signal.h>
#include <string.h>
#include <unistd.h>
+#include <limits.h>
#include <ctype.h>
#include <errno.h>
#include <fcntl.h>
@@ -215,7 +215,7 @@ int
main(void)
{
struct cmd *cmd = NULL;
- char prompt[MAXHOSTNAMELEN], *line, **argp = NULL;
+ char prompt[HOST_NAME_MAX+1], *line, **argp = NULL;
int ncmd, ret, v = -1;
u_int i;
diff --git a/usr.bin/calendar/io.c b/usr.bin/calendar/io.c
index 1d6ef58c8cf..31c413bb7db 100644
--- a/usr.bin/calendar/io.c
+++ b/usr.bin/calendar/io.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: io.c,v 1.36 2013/11/26 13:18:53 deraadt Exp $ */
+/* $OpenBSD: io.c,v 1.37 2015/01/16 06:40:06 deraadt Exp $ */
/*
* Copyright (c) 1989, 1993, 1994
@@ -29,7 +29,6 @@
* SUCH DAMAGE.
*/
-#include <sys/param.h>
#include <sys/stat.h>
#include <sys/time.h>
#include <sys/types.h>
@@ -47,6 +46,7 @@
#include <string.h>
#include <tzfile.h>
#include <unistd.h>
+#include <limits.h>
#include "pathnames.h"
#include "calendar.h"
diff --git a/usr.bin/cap_mkdb/cap_mkdb.c b/usr.bin/cap_mkdb/cap_mkdb.c
index 1450a36ba17..7e9535ba1e3 100644
--- a/usr.bin/cap_mkdb/cap_mkdb.c
+++ b/usr.bin/cap_mkdb/cap_mkdb.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cap_mkdb.c,v 1.18 2011/07/04 21:34:54 nicm Exp $ */
+/* $OpenBSD: cap_mkdb.c,v 1.19 2015/01/16 06:40:06 deraadt Exp $ */
/* $NetBSD: cap_mkdb.c,v 1.5 1995/09/02 05:47:12 jtc Exp $ */
/*-
@@ -30,7 +30,6 @@
* SUCH DAMAGE.
*/
-#include <sys/param.h>
#include <sys/stat.h>
#include <db.h>
@@ -44,6 +43,9 @@
#include <ctype.h>
#include <unistd.h>
+#define MINIMUM(a, b) (((a) < (b)) ? (a) : (b))
+#define MAXIMUM(a, b) (((a) > (b)) ? (a) : (b))
+
void db_build(char **);
void dounlink(void);
void usage(void);
@@ -162,7 +164,7 @@ db_build(char **ifiles)
*/
len = strlen(bp);
if (bplen <= 4 * len + 2) {
- int newbplen = bplen + MAX(256, 4 * len + 2);
+ int newbplen = bplen + MAXIMUM(256, 4 * len + 2);
void *newdata;
if ((newdata = realloc(data.data, newbplen)) == NULL)
@@ -173,7 +175,7 @@ db_build(char **ifiles)
/* Find the end of the name field. */
if ((p = strchr(bp, info ? ',' : ':')) == NULL) {
- warnx("no name field: %.*s", (int)MIN(len, 20), bp);
+ warnx("no name field: %.*s", (int)MINIMUM(len, 20), bp);
continue;
}
@@ -221,7 +223,7 @@ db_build(char **ifiles)
}
*out++ = '\0';
if (memchr((char *)data.data + 1, '\0', data.size - 2)) {
- warnx("NUL in entry: %.*s", (int)MIN(len, 20), bp);
+ warnx("NUL in entry: %.*s", (int)MINIMUM(len, 20), bp);
continue;
}
} else {
diff --git a/usr.bin/cdio/cddb.c b/usr.bin/cdio/cddb.c
index bc3e010aab7..c5ae468db5a 100644
--- a/usr.bin/cdio/cddb.c
+++ b/usr.bin/cdio/cddb.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cddb.c,v 1.19 2014/01/06 12:38:10 espie Exp $ */
+/* $OpenBSD: cddb.c,v 1.20 2015/01/16 06:40:06 deraadt Exp $ */
/*
* Copyright (c) 2002 Marc Espie.
*
@@ -24,7 +24,6 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include <sys/param.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <sys/cdio.h>
@@ -34,6 +33,7 @@
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
+#include <limits.h>
#include <vis.h>
#include "extern.h"
@@ -76,7 +76,7 @@ cddb_discid(int n, struct cd_toc_entry *e)
void
send_hello(FILE *cout)
{
- char hostname[MAXHOSTNAMELEN];
+ char hostname[HOST_NAME_MAX+1];
if (gethostname(hostname, sizeof(hostname)) == -1)
strlcpy(hostname, "unknown", sizeof hostname);
diff --git a/usr.bin/cdio/cdio.c b/usr.bin/cdio/cdio.c
index 4be37621b16..0177630da6e 100644
--- a/usr.bin/cdio/cdio.c
+++ b/usr.bin/cdio/cdio.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cdio.c,v 1.73 2013/11/20 20:54:34 deraadt Exp $ */
+/* $OpenBSD: cdio.c,v 1.74 2015/01/16 06:40:06 deraadt Exp $ */
/* Copyright (c) 1995 Serge V. Vakulenko
* All rights reserved.
@@ -52,7 +52,7 @@
* $FreeBSD: cdcontrol.c,v 1.13 1996/06/25 21:01:27 ache Exp $
*/
-#include <sys/param.h>
+#include <sys/param.h> /* isset */
#include <sys/file.h>
#include <sys/cdio.h>
#include <sys/ioctl.h>
@@ -67,6 +67,7 @@
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
+#include <limits.h>
#include <histedit.h>
#include <util.h>
#include <vis.h>
@@ -319,7 +320,7 @@ int
run(int cmd, char *arg)
{
int l, r, rc;
- static char newcdname[MAXPATHLEN];
+ static char newcdname[PATH_MAX];
switch (cmd) {
diff --git a/usr.bin/cdio/mmc.c b/usr.bin/cdio/mmc.c
index d34f86f44f7..2866d805064 100644
--- a/usr.bin/cdio/mmc.c
+++ b/usr.bin/cdio/mmc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mmc.c,v 1.29 2013/11/12 17:57:34 deraadt Exp $ */
+/* $OpenBSD: mmc.c,v 1.30 2015/01/16 06:40:06 deraadt Exp $ */
/*
* Copyright (c) 2006 Michael Coulter <mjc@openbsd.org>
*
@@ -18,7 +18,7 @@
#include <sys/limits.h>
#include <sys/types.h>
#include <sys/scsiio.h>
-#include <sys/param.h>
+#include <sys/param.h> /* setbit, isset */
#include <scsi/cd.h>
#include <scsi/scsi_all.h>
#include <scsi/scsi_disk.h>
diff --git a/usr.bin/chpass/chpass.c b/usr.bin/chpass/chpass.c
index 8fed8c4190a..f506ed59e5d 100644
--- a/usr.bin/chpass/chpass.c
+++ b/usr.bin/chpass/chpass.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: chpass.c,v 1.40 2014/10/26 20:38:13 guenther Exp $ */
+/* $OpenBSD: chpass.c,v 1.41 2015/01/16 06:40:06 deraadt Exp $ */
/* $NetBSD: chpass.c,v 1.8 1996/05/15 21:50:43 jtc Exp $ */
/*-
@@ -30,7 +30,6 @@
* SUCH DAMAGE.
*/
-#include <sys/param.h>
#include <sys/resource.h>
#include <sys/stat.h>
#include <sys/time.h>
diff --git a/usr.bin/chpass/edit.c b/usr.bin/chpass/edit.c
index 2590d4c42d1..b75a47efa8a 100644
--- a/usr.bin/chpass/edit.c
+++ b/usr.bin/chpass/edit.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: edit.c,v 1.34 2013/11/26 13:18:55 deraadt Exp $ */
+/* $OpenBSD: edit.c,v 1.35 2015/01/16 06:40:06 deraadt Exp $ */
/* $NetBSD: edit.c,v 1.6 1996/05/15 21:50:45 jtc Exp $ */
/*-
@@ -30,7 +30,6 @@
* SUCH DAMAGE.
*/
-#include <sys/param.h>
#include <sys/stat.h>
#include <ctype.h>
@@ -43,6 +42,7 @@
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
+#include <limits.h>
#include <util.h>
#include "chpass.h"
diff --git a/usr.bin/chpass/field.c b/usr.bin/chpass/field.c
index b48c7951e5a..90d98032e5e 100644
--- a/usr.bin/chpass/field.c
+++ b/usr.bin/chpass/field.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: field.c,v 1.13 2013/11/26 13:18:55 deraadt Exp $ */
+/* $OpenBSD: field.c,v 1.14 2015/01/16 06:40:06 deraadt Exp $ */
/* $NetBSD: field.c,v 1.3 1995/03/26 04:55:28 glass Exp $ */
/*
@@ -30,8 +30,6 @@
* SUCH DAMAGE.
*/
-#include <sys/param.h>
-
#include <ctype.h>
#include <err.h>
#include <errno.h>
@@ -42,6 +40,7 @@
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
+#include <limits.h>
#include "chpass.h"
diff --git a/usr.bin/cmp/regular.c b/usr.bin/cmp/regular.c
index 95ebc1bbbe0..f95f64e1e2b 100644
--- a/usr.bin/cmp/regular.c
+++ b/usr.bin/cmp/regular.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: regular.c,v 1.10 2011/01/19 13:01:25 okan Exp $ */
+/* $OpenBSD: regular.c,v 1.11 2015/01/16 06:40:06 deraadt Exp $ */
/* $NetBSD: regular.c,v 1.2 1995/09/08 03:22:59 tls Exp $ */
/*-
@@ -30,7 +30,6 @@
* SUCH DAMAGE.
*/
-#include <sys/param.h>
#include <sys/mman.h>
#include <sys/stat.h>
@@ -42,6 +41,8 @@
#include "extern.h"
+#define MINIMUM(a, b) (((a) < (b)) ? (a) : (b))
+
void
c_regular(int fd1, char *file1, off_t skip1, off_t len1,
int fd2, char *file2, off_t skip2, off_t len2)
@@ -60,7 +61,7 @@ c_regular(int fd1, char *file1, off_t skip1, off_t len1,
eofmsg(file2);
len2 -= skip2;
- length = MIN(len1, len2);
+ length = MINIMUM(len1, len2);
if (length > SIZE_T_MAX) {
mmap_failed:
c_special(fd1, file1, skip1, fd2, file2, skip2);
diff --git a/usr.bin/compress/gzopen.c b/usr.bin/compress/gzopen.c
index 2fe33b55db3..dd239534a5c 100644
--- a/usr.bin/compress/gzopen.c
+++ b/usr.bin/compress/gzopen.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: gzopen.c,v 1.27 2011/09/22 10:41:04 deraadt Exp $ */
+/* $OpenBSD: gzopen.c,v 1.28 2015/01/16 06:40:06 deraadt Exp $ */
/*
* Copyright (c) 1997 Michael Shalayeff
@@ -58,7 +58,6 @@
(zlib format), rfc1951.txt (deflate format) and rfc1952.txt (gzip format).
*/
-#include <sys/param.h>
#include <sys/stat.h>
#include <sys/uio.h>
#include <stdio.h>
@@ -66,6 +65,7 @@
#include <string.h>
#include <errno.h>
#include <unistd.h>
+#include <limits.h>
#include <zlib.h>
#include "compress.h"
@@ -348,7 +348,7 @@ get_header(gz_stream *s, char *name, int gotmagic)
if ((flags & ORIG_NAME) != 0) { /* read/save the original file name */
if ((ep = name) != NULL)
- ep += MAXPATHLEN - 1;
+ ep += PATH_MAX - 1;
while ((c = get_byte(s)) != EOF) {
s->z_hlen++;
if (c == '\0')
diff --git a/usr.bin/compress/main.c b/usr.bin/compress/main.c
index 493b62c31ba..c9e302598ff 100644
--- a/usr.bin/compress/main.c
+++ b/usr.bin/compress/main.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: main.c,v 1.82 2014/10/08 03:59:11 doug Exp $ */
+/* $OpenBSD: main.c,v 1.83 2015/01/16 06:40:06 deraadt Exp $ */
/*
* Copyright (c) 1992, 1993
@@ -30,7 +30,6 @@
* THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include <sys/param.h>
#include <sys/time.h>
#include <sys/stat.h>
@@ -44,6 +43,7 @@
#include <stdbool.h>
#include <string.h>
#include <unistd.h>
+#include <limits.h>
#include <fcntl.h>
#include <paths.h>
#include "compress.h"
@@ -164,7 +164,7 @@ main(int argc, char *argv[])
const struct compressor *method;
const char *optstr, *s;
char *p, *infile;
- char outfile[MAXPATHLEN], _infile[MAXPATHLEN], suffix[16];
+ char outfile[PATH_MAX], _infile[PATH_MAX], suffix[16];
int bits, ch, error, rc, cflag, oflag;
bits = cflag = oflag = 0;
@@ -613,7 +613,7 @@ dodecompress(const char *in, char *out, const struct compressor *method,
int bits, struct stat *sb)
{
u_char buf[Z_BUFSIZE];
- char oldname[MAXPATHLEN];
+ char oldname[PATH_MAX];
int error, oreg, ifd, ofd;
void *cookie;
ssize_t nr;
@@ -661,9 +661,9 @@ dodecompress(const char *in, char *out, const struct compressor *method,
char *cp = strrchr(out, '/');
if (cp != NULL) {
*(cp + 1) = '\0';
- strlcat(out, oldname, MAXPATHLEN);
+ strlcat(out, oldname, PATH_MAX);
} else
- strlcpy(out, oldname, MAXPATHLEN);
+ strlcpy(out, oldname, PATH_MAX);
cat = 0; /* XXX should -c override? */
}
diff --git a/usr.bin/compress/zopen.c b/usr.bin/compress/zopen.c
index 12de049e712..919cc77eb0c 100644
--- a/usr.bin/compress/zopen.c
+++ b/usr.bin/compress/zopen.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: zopen.c,v 1.18 2011/09/22 10:41:04 deraadt Exp $ */
+/* $OpenBSD: zopen.c,v 1.19 2015/01/16 06:40:06 deraadt Exp $ */
/* $NetBSD: zopen.c,v 1.5 1995/03/26 09:44:53 glass Exp $ */
/*-
@@ -58,7 +58,6 @@
* Any file produced by compress(1) can be read.
*/
-#include <sys/param.h>
#include <sys/stat.h>
#include <ctype.h>
@@ -71,6 +70,8 @@
#include <fcntl.h>
#include "compress.h"
+#define MINIMUM(a, b) (((a) < (b)) ? (a) : (b))
+
#define BITS 16 /* Default bits. */
#define HSIZE 69001 /* 95% occupancy */
#define ZBUFSIZ 8192 /* I/O buffer size */
@@ -636,7 +637,7 @@ getcode(struct s_zstate *zs)
zs->zs_ebp = bp + bits;
}
zs->zs_offset = 0;
- zs->zs_size = MIN(zs->zs_n_bits, zs->zs_ebp - zs->zs_bp);
+ zs->zs_size = MINIMUM(zs->zs_n_bits, zs->zs_ebp - zs->zs_bp);
if (zs->zs_size == 0)
return -1;
/* Round size down to integral number of codes. */
diff --git a/usr.bin/cu/cu.c b/usr.bin/cu/cu.c
index 146025181f5..99a9b057430 100644
--- a/usr.bin/cu/cu.c
+++ b/usr.bin/cu/cu.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cu.c,v 1.19 2014/04/12 12:47:43 nicm Exp $ */
+/* $OpenBSD: cu.c,v 1.20 2015/01/16 06:40:06 deraadt Exp $ */
/*
* Copyright (c) 2012 Nicholas Marriott <nicm@openbsd.org>
@@ -16,7 +16,6 @@
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
-#include <sys/param.h>
#include <sys/ioctl.h>
#include <ctype.h>
@@ -32,6 +31,7 @@
#include <string.h>
#include <termios.h>
#include <unistd.h>
+#include <limits.h>
#include "cu.h"
@@ -391,7 +391,7 @@ tilde_expand(const char *filename1)
if ((rv = asprintf(&out, "%s%s%s", pw->pw_dir, sep, filename)) == -1)
cu_err(1, "asprintf");
- if (rv >= MAXPATHLEN) {
+ if (rv >= PATH_MAX) {
free(out);
goto no_change;
}
diff --git a/usr.bin/cvs/add.c b/usr.bin/cvs/add.c
index 46cde4557dc..e744b05f797 100644
--- a/usr.bin/cvs/add.c
+++ b/usr.bin/cvs/add.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: add.c,v 1.110 2010/11/11 21:00:59 nicm Exp $ */
+/* $OpenBSD: add.c,v 1.111 2015/01/16 06:40:06 deraadt Exp $ */
/*
* Copyright (c) 2006 Joris Vink <joris@openbsd.org>
* Copyright (c) 2005, 2006 Xavier Santolaria <xsa@openbsd.org>
@@ -180,14 +180,14 @@ cvs_add_local(struct cvs_file *cf)
void
cvs_add_remote(struct cvs_file *cf)
{
- char path[MAXPATHLEN];
+ char path[PATH_MAX];
cvs_log(LP_TRACE, "cvs_add_remote(%s)", cf->file_path);
cvs_file_classify(cf, cvs_directory_tag);
if (cf->file_type == CVS_DIR) {
- cvs_get_repository_path(cf->file_wd, path, MAXPATHLEN);
+ cvs_get_repository_path(cf->file_wd, path, PATH_MAX);
if (strlcat(path, "/", sizeof(path)) >= sizeof(path))
fatal("cvs_add_remote: truncation");
if (strlcat(path, cf->file_path, sizeof(path)) >= sizeof(path))
@@ -205,7 +205,7 @@ void
cvs_add_loginfo(char *repo)
{
BUF *buf;
- char pwd[MAXPATHLEN];
+ char pwd[PATH_MAX];
if (getcwd(pwd, sizeof(pwd)) == NULL)
fatal("Can't get working directory");
@@ -229,7 +229,7 @@ void
cvs_add_tobranch(struct cvs_file *cf, char *tag)
{
BUF *bp;
- char attic[MAXPATHLEN], repo[MAXPATHLEN];
+ char attic[PATH_MAX], repo[PATH_MAX];
char *msg;
struct stat st;
RCSNUM *branch;
@@ -242,14 +242,14 @@ cvs_add_tobranch(struct cvs_file *cf, char *tag)
if (fstat(cf->fd, &st) == -1)
fatal("cvs_add_tobranch: %s", strerror(errno));
- cvs_get_repository_path(cf->file_wd, repo, MAXPATHLEN);
- (void)xsnprintf(attic, MAXPATHLEN, "%s/%s",
+ cvs_get_repository_path(cf->file_wd, repo, PATH_MAX);
+ (void)xsnprintf(attic, PATH_MAX, "%s/%s",
repo, CVS_PATH_ATTIC);
if (mkdir(attic, 0755) == -1 && errno != EEXIST)
fatal("cvs_add_tobranch: failed to create Attic");
- (void)xsnprintf(attic, MAXPATHLEN, "%s/%s/%s%s", repo,
+ (void)xsnprintf(attic, PATH_MAX, "%s/%s/%s%s", repo,
CVS_PATH_ATTIC, cf->file_name, RCS_FILE_EXT);
xfree(cf->file_rpath);
@@ -301,14 +301,14 @@ add_directory(struct cvs_file *cf)
int added, nb;
struct stat st;
CVSENTRIES *entlist;
- char *date, entry[MAXPATHLEN], msg[1024], repo[MAXPATHLEN], *tag, *p;
+ char *date, entry[PATH_MAX], msg[1024], repo[PATH_MAX], *tag, *p;
struct file_info_list files_info;
struct file_info *fi;
struct trigger_list *line_list;
cvs_log(LP_TRACE, "add_directory(%s)", cf->file_path);
- (void)xsnprintf(entry, MAXPATHLEN, "%s%s",
+ (void)xsnprintf(entry, PATH_MAX, "%s%s",
cf->file_rpath, RCS_FILE_EXT);
added = 1;
@@ -321,7 +321,7 @@ add_directory(struct cvs_file *cf)
/* Let's see if we have any per-directory tags first. */
cvs_parse_tagfile(cf->file_wd, &tag, &date, &nb);
- (void)xsnprintf(entry, MAXPATHLEN, "%s/%s",
+ (void)xsnprintf(entry, PATH_MAX, "%s/%s",
cf->file_path, CVS_PATH_CVSDIR);
if (cvs_server_active) {
@@ -345,9 +345,9 @@ add_directory(struct cvs_file *cf)
strerror(errno));
cvs_get_repository_name(cf->file_wd, repo,
- MAXPATHLEN);
+ PATH_MAX);
- (void)xsnprintf(entry, MAXPATHLEN, "%s/%s",
+ (void)xsnprintf(entry, PATH_MAX, "%s/%s",
repo, cf->file_name);
cvs_mkadmin(cf->file_path, current_cvsroot->cr_dir,
@@ -386,7 +386,7 @@ add_directory(struct cvs_file *cf)
if (date != NULL)
xfree(date);
- cvs_get_repository_name(cf->file_path, repo, MAXPATHLEN);
+ cvs_get_repository_name(cf->file_path, repo, PATH_MAX);
line_list = cvs_trigger_getlines(CVS_PATH_LOGINFO, repo);
if (line_list != NULL) {
TAILQ_INIT(&files_info);
@@ -500,7 +500,7 @@ static void
add_entry(struct cvs_file *cf)
{
FILE *fp;
- char *entry, path[MAXPATHLEN];
+ char *entry, path[PATH_MAX];
char revbuf[CVS_REV_BUFSZ], tbuf[CVS_TIME_BUFSZ];
char sticky[CVS_ENT_MAXLINELEN];
CVSENTRIES *entlist;
@@ -527,7 +527,7 @@ add_entry(struct cvs_file *cf)
0, 0, entry, CVS_ENT_MAXLINELEN);
} else {
if (logmsg != NULL) {
- (void)xsnprintf(path, MAXPATHLEN, "%s/%s/%s%s",
+ (void)xsnprintf(path, PATH_MAX, "%s/%s/%s%s",
cf->file_wd, CVS_PATH_CVSDIR, cf->file_name,
CVS_DESCR_FILE_EXT);
diff --git a/usr.bin/cvs/admin.c b/usr.bin/cvs/admin.c
index 97269b52b19..6a3120df20b 100644
--- a/usr.bin/cvs/admin.c
+++ b/usr.bin/cvs/admin.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: admin.c,v 1.64 2008/09/12 13:20:36 tobias Exp $ */
+/* $OpenBSD: admin.c,v 1.65 2015/01/16 06:40:06 deraadt Exp $ */
/*
* Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org>
* Copyright (c) 2005 Joris Vink <joris@openbsd.org>
@@ -17,7 +17,7 @@
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
-#include <sys/param.h>
+#include <sys/types.h>
#include <sys/dirent.h>
#include <errno.h>
@@ -245,7 +245,7 @@ cvs_admin_local(struct cvs_file *cf)
struct cvs_file *ocf;
struct rcs_access *acp;
int ofd;
- char *d, *f, fpath[MAXPATHLEN], repo[MAXPATHLEN];
+ char *d, *f, fpath[PATH_MAX], repo[PATH_MAX];
if ((f = basename(oldfilename)) == NULL)
@@ -253,11 +253,11 @@ cvs_admin_local(struct cvs_file *cf)
if ((d = dirname(oldfilename)) == NULL)
fatal("cvs_admin_local: dirname failed");
- cvs_get_repository_path(d, repo, MAXPATHLEN);
+ cvs_get_repository_path(d, repo, PATH_MAX);
- (void)xsnprintf(fpath, MAXPATHLEN, "%s/%s", repo, f);
+ (void)xsnprintf(fpath, PATH_MAX, "%s/%s", repo, f);
- if (strlcat(fpath, RCS_FILE_EXT, MAXPATHLEN) >= MAXPATHLEN)
+ if (strlcat(fpath, RCS_FILE_EXT, PATH_MAX) >= PATH_MAX)
fatal("cvs_admin_local: truncation");
if ((ofd = open(fpath, O_RDONLY)) == -1)
diff --git a/usr.bin/cvs/annotate.c b/usr.bin/cvs/annotate.c
index f00ecc1fb12..8aaa8b3a3e5 100644
--- a/usr.bin/cvs/annotate.c
+++ b/usr.bin/cvs/annotate.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: annotate.c,v 1.63 2011/12/27 13:59:01 nicm Exp $ */
+/* $OpenBSD: annotate.c,v 1.64 2015/01/16 06:40:06 deraadt Exp $ */
/*
* Copyright (c) 2007 Tobias Stoeckmann <tobias@openbsd.org>
* Copyright (c) 2006 Xavier Santolaria <xsa@openbsd.org>
@@ -16,7 +16,7 @@
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
-#include <sys/param.h>
+#include <sys/types.h>
#include <sys/dirent.h>
#include <errno.h>
diff --git a/usr.bin/cvs/atomicio.c b/usr.bin/cvs/atomicio.c
index d872cbf4711..f05bfdb4d18 100644
--- a/usr.bin/cvs/atomicio.c
+++ b/usr.bin/cvs/atomicio.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: atomicio.c,v 1.1 2007/09/17 10:07:21 tobias Exp $ */
+/* $OpenBSD: atomicio.c,v 1.2 2015/01/16 06:40:06 deraadt Exp $ */
/*
* Copyright (c) 2006 Damien Miller. All rights reserved.
* Copyright (c) 2005 Anil Madhavapeddy. All rights reserved.
@@ -26,7 +26,7 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include <sys/param.h>
+#include <sys/types.h>
#include <errno.h>
#include <poll.h>
diff --git a/usr.bin/cvs/checkout.c b/usr.bin/cvs/checkout.c
index 24c922ede54..ea1a0ddd0d3 100644
--- a/usr.bin/cvs/checkout.c
+++ b/usr.bin/cvs/checkout.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: checkout.c,v 1.168 2011/12/27 13:59:01 nicm Exp $ */
+/* $OpenBSD: checkout.c,v 1.169 2015/01/16 06:40:06 deraadt Exp $ */
/*
* Copyright (c) 2006 Joris Vink <joris@openbsd.org>
*
@@ -15,7 +15,7 @@
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
-#include <sys/param.h>
+#include <sys/types.h>
#include <sys/dirent.h>
#include <sys/stat.h>
#include <sys/time.h>
@@ -239,7 +239,7 @@ checkout_check_repository(int argc, char **argv)
struct module_checkout *mc;
struct cvs_ignpat *ip;
struct cvs_filelist *fl, *nxt;
- char repo[MAXPATHLEN], fpath[MAXPATHLEN], *f[1];
+ char repo[PATH_MAX], fpath[PATH_MAX], *f[1];
build_dirs = print_stdout ? 0 : 1;
@@ -388,7 +388,7 @@ checkout_check_repository(int argc, char **argv)
static int
checkout_classify(const char *repo, const char *arg)
{
- char *d, *f, fpath[MAXPATHLEN];
+ char *d, *f, fpath[PATH_MAX];
struct stat sb;
if (stat(repo, &sb) == 0) {
@@ -477,7 +477,7 @@ cvs_checkout_file(struct cvs_file *cf, RCSNUM *rnum, char *tag, int co_flags)
char *entry, *tosend;
char kbuf[8], sticky[CVS_REV_BUFSZ], rev[CVS_REV_BUFSZ];
char timebuf[CVS_TIME_BUFSZ], tbuf[CVS_TIME_BUFSZ];
- static char lastwd[MAXPATHLEN];
+ static char lastwd[PATH_MAX];
exists = 0;
tosend = NULL;
@@ -606,7 +606,7 @@ cvs_checkout_file(struct cvs_file *cf, RCSNUM *rnum, char *tag, int co_flags)
*/
if (tag != NULL && strcmp(cf->file_wd, lastwd) &&
!(cf->file_flags & FILE_USER_SUPPLIED)) {
- strlcpy(lastwd, cf->file_wd, MAXPATHLEN);
+ strlcpy(lastwd, cf->file_wd, PATH_MAX);
cvs_server_set_sticky(cf->file_wd, sticky);
}
diff --git a/usr.bin/cvs/client.c b/usr.bin/cvs/client.c
index ba9184b5816..ca137abcff9 100644
--- a/usr.bin/cvs/client.c
+++ b/usr.bin/cvs/client.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: client.c,v 1.123 2010/09/29 18:14:52 nicm Exp $ */
+/* $OpenBSD: client.c,v 1.124 2015/01/16 06:40:06 deraadt Exp $ */
/*
* Copyright (c) 2006 Joris Vink <joris@openbsd.org>
*
@@ -15,7 +15,7 @@
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
-#include <sys/param.h>
+#include <sys/types.h>
#include <sys/dirent.h>
#include <sys/stat.h>
#include <sys/time.h>
@@ -399,19 +399,19 @@ cvs_client_senddir(const char *dir)
{
struct stat st;
int nb;
- char *d, *date, fpath[MAXPATHLEN], repo[MAXPATHLEN], *tag;
+ char *d, *date, fpath[PATH_MAX], repo[PATH_MAX], *tag;
d = NULL;
if (lastdir != NULL && !strcmp(dir, lastdir))
return;
- cvs_get_repository_path(dir, repo, MAXPATHLEN);
+ cvs_get_repository_path(dir, repo, PATH_MAX);
if (cvs_cmdop != CVS_OP_RLOG)
cvs_client_send_request("Directory %s\n%s", dir, repo);
- (void)xsnprintf(fpath, MAXPATHLEN, "%s/%s",
+ (void)xsnprintf(fpath, PATH_MAX, "%s/%s",
dir, CVS_PATH_STATICENTRIES);
if (stat(fpath, &st) == 0 && (st.st_mode & (S_IRUSR|S_IRGRP|S_IROTH)))
@@ -700,10 +700,10 @@ cvs_client_updated(char *data)
const char *errstr;
struct tm datetm;
struct timeval tv[2];
- char repo[MAXPATHLEN], *entry;
+ char repo[PATH_MAX], *entry;
char timebuf[CVS_TIME_BUFSZ], revbuf[CVS_REV_BUFSZ];
char *en, *mode, *len, *rpath, *p;
- char sticky[CVS_ENT_MAXLINELEN], fpath[MAXPATHLEN];
+ char sticky[CVS_ENT_MAXLINELEN], fpath[PATH_MAX];
if (data == NULL)
fatal("Missing argument for Updated");
@@ -714,7 +714,7 @@ cvs_client_updated(char *data)
len = cvs_remote_input();
client_check_directory(data, rpath);
- cvs_get_repository_path(".", repo, MAXPATHLEN);
+ cvs_get_repository_path(".", repo, PATH_MAX);
STRIP_SLASH(repo);
@@ -815,8 +815,8 @@ cvs_client_merged(char *data)
client_check_directory(data, rpath);
- repo = xmalloc(MAXPATHLEN);
- cvs_get_repository_path(".", repo, MAXPATHLEN);
+ repo = xmalloc(PATH_MAX);
+ cvs_get_repository_path(".", repo, PATH_MAX);
STRIP_SLASH(repo);
@@ -872,7 +872,7 @@ void
cvs_client_removed(char *data)
{
CVSENTRIES *entlist;
- char *rpath, *filename, fpath[MAXPATHLEN];
+ char *rpath, *filename, fpath[PATH_MAX];
if (data == NULL)
fatal("Missing argument for Removed");
@@ -885,7 +885,7 @@ cvs_client_removed(char *data)
entlist = cvs_ent_open(data);
cvs_ent_remove(entlist, filename);
- (void)xsnprintf(fpath, MAXPATHLEN, "%s/%s", data, filename);
+ (void)xsnprintf(fpath, PATH_MAX, "%s/%s", data, filename);
(void)unlink(fpath);
xfree(rpath);
@@ -915,7 +915,7 @@ void
cvs_client_set_static_directory(char *data)
{
FILE *fp;
- char *dir, fpath[MAXPATHLEN];
+ char *dir, fpath[PATH_MAX];
if (data == NULL)
fatal("Missing argument for Set-static-directory");
@@ -928,7 +928,7 @@ cvs_client_set_static_directory(char *data)
if (cvs_cmdop == CVS_OP_EXPORT)
return;
- (void)xsnprintf(fpath, MAXPATHLEN, "%s/%s",
+ (void)xsnprintf(fpath, PATH_MAX, "%s/%s",
data, CVS_PATH_STATICENTRIES);
if ((fp = fopen(fpath, "w+")) == NULL) {
@@ -941,7 +941,7 @@ cvs_client_set_static_directory(char *data)
void
cvs_client_clear_static_directory(char *data)
{
- char *dir, fpath[MAXPATHLEN];
+ char *dir, fpath[PATH_MAX];
if (data == NULL)
fatal("Missing argument for Clear-static-directory");
@@ -954,7 +954,7 @@ cvs_client_clear_static_directory(char *data)
if (cvs_cmdop == CVS_OP_EXPORT)
return;
- (void)xsnprintf(fpath, MAXPATHLEN, "%s/%s",
+ (void)xsnprintf(fpath, PATH_MAX, "%s/%s",
data, CVS_PATH_STATICENTRIES);
(void)cvs_unlink(fpath);
@@ -964,7 +964,7 @@ void
cvs_client_set_sticky(char *data)
{
FILE *fp;
- char *dir, *tag, tagpath[MAXPATHLEN];
+ char *dir, *tag, tagpath[PATH_MAX];
if (data == NULL)
fatal("Missing argument for Set-sticky");
@@ -979,7 +979,7 @@ cvs_client_set_sticky(char *data)
client_check_directory(data, dir);
- (void)xsnprintf(tagpath, MAXPATHLEN, "%s/%s", data, CVS_PATH_TAG);
+ (void)xsnprintf(tagpath, PATH_MAX, "%s/%s", data, CVS_PATH_TAG);
if ((fp = fopen(tagpath, "w+")) == NULL) {
cvs_log(LP_ERRNO, "%s", tagpath);
@@ -996,7 +996,7 @@ out:
void
cvs_client_clear_sticky(char *data)
{
- char *dir, tagpath[MAXPATHLEN];
+ char *dir, tagpath[PATH_MAX];
if (data == NULL)
fatal("Missing argument for Clear-sticky");
@@ -1012,7 +1012,7 @@ cvs_client_clear_sticky(char *data)
client_check_directory(data, dir);
- (void)xsnprintf(tagpath, MAXPATHLEN, "%s/%s", data, CVS_PATH_TAG);
+ (void)xsnprintf(tagpath, PATH_MAX, "%s/%s", data, CVS_PATH_TAG);
(void)unlink(tagpath);
xfree(dir);
@@ -1031,8 +1031,8 @@ static void
cvs_client_initlog(void)
{
u_int i;
- char *env, *envdup, buf[MAXPATHLEN], fpath[MAXPATHLEN];
- char rpath[MAXPATHLEN], timebuf[CVS_TIME_BUFSZ], *s;
+ char *env, *envdup, buf[PATH_MAX], fpath[PATH_MAX];
+ char rpath[PATH_MAX], timebuf[CVS_TIME_BUFSZ], *s;
struct stat st;
time_t now;
struct passwd *pwd;
diff --git a/usr.bin/cvs/cmd.c b/usr.bin/cvs/cmd.c
index 94bf0b3950d..c4c5837fee2 100644
--- a/usr.bin/cvs/cmd.c
+++ b/usr.bin/cvs/cmd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cmd.c,v 1.68 2008/02/03 18:18:44 tobias Exp $ */
+/* $OpenBSD: cmd.c,v 1.69 2015/01/16 06:40:07 deraadt Exp $ */
/*
* Copyright (c) 2005 Joris Vink <joris@openbsd.org>
* All rights reserved.
@@ -23,7 +23,7 @@
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include <sys/param.h>
+#include <sys/types.h>
#include <sys/dirent.h>
#include <string.h>
diff --git a/usr.bin/cvs/commit.c b/usr.bin/cvs/commit.c
index a1520984789..fe8d554f6f8 100644
--- a/usr.bin/cvs/commit.c
+++ b/usr.bin/cvs/commit.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: commit.c,v 1.152 2011/12/27 13:59:01 nicm Exp $ */
+/* $OpenBSD: commit.c,v 1.153 2015/01/16 06:40:07 deraadt Exp $ */
/*
* Copyright (c) 2006 Joris Vink <joris@openbsd.org>
* Copyright (c) 2006 Xavier Santolaria <xsa@openbsd.org>
@@ -68,7 +68,7 @@ cvs_commit(int argc, char **argv)
struct cvs_recursion cr;
struct cvs_filelist *l;
struct file_info *fi;
- char *arg = ".", repo[MAXPATHLEN];
+ char *arg = ".", repo[PATH_MAX];
flags = CR_RECURSE_DIRS;
Fflag = mflag = 0;
@@ -160,7 +160,7 @@ cvs_commit(int argc, char **argv)
cvs_client_send_request("ci");
cvs_client_get_responses();
} else {
- cvs_get_repository_name(".", repo, MAXPATHLEN);
+ cvs_get_repository_name(".", repo, PATH_MAX);
line_list = cvs_trigger_getlines(CVS_PATH_COMMITINFO, repo);
if (line_list != NULL) {
@@ -232,7 +232,7 @@ void
cvs_commit_loginfo(char *repo)
{
BUF *buf;
- char pwd[MAXPATHLEN];
+ char pwd[PATH_MAX];
struct cvs_filelist *cf;
if (getcwd(pwd, sizeof(pwd)) == NULL)
@@ -291,7 +291,7 @@ cvs_commit_loginfo(char *repo)
void
cvs_commit_lock_dirs(struct cvs_file *cf)
{
- char repo[MAXPATHLEN];
+ char repo[PATH_MAX];
cvs_get_repository_path(cf->file_wd, repo, sizeof(repo));
cvs_log(LP_TRACE, "cvs_commit_lock_dirs: %s", repo);
@@ -446,7 +446,7 @@ cvs_commit_local(struct cvs_file *cf)
int openflags, rcsflags;
char rbuf[CVS_REV_BUFSZ], nbuf[CVS_REV_BUFSZ];
CVSENTRIES *entlist;
- char attic[MAXPATHLEN], repo[MAXPATHLEN], rcsfile[MAXPATHLEN];
+ char attic[PATH_MAX], repo[PATH_MAX], rcsfile[PATH_MAX];
struct file_info *fi;
cvs_log(LP_TRACE, "cvs_commit_local(%s)", cf->file_path);
@@ -559,8 +559,8 @@ cvs_commit_local(struct cvs_file *cf)
"to be dead", cf->file_path);
cvs_get_repository_path(cf->file_wd, repo,
- MAXPATHLEN);
- (void)xsnprintf(rcsfile, MAXPATHLEN, "%s/%s%s",
+ PATH_MAX);
+ (void)xsnprintf(rcsfile, PATH_MAX, "%s/%s%s",
repo, cf->file_name, RCS_FILE_EXT);
if (rename(cf->file_rpath, rcsfile) == -1)
@@ -666,15 +666,15 @@ cvs_commit_local(struct cvs_file *cf)
entlist = cvs_ent_open(cf->file_wd);
cvs_ent_remove(entlist, cf->file_name);
- cvs_get_repository_path(cf->file_wd, repo, MAXPATHLEN);
+ cvs_get_repository_path(cf->file_wd, repo, PATH_MAX);
- (void)xsnprintf(attic, MAXPATHLEN, "%s/%s",
+ (void)xsnprintf(attic, PATH_MAX, "%s/%s",
repo, CVS_PATH_ATTIC);
if (mkdir(attic, 0755) == -1 && errno != EEXIST)
fatal("cvs_commit_local: failed to create Attic");
- (void)xsnprintf(attic, MAXPATHLEN, "%s/%s/%s%s", repo,
+ (void)xsnprintf(attic, PATH_MAX, "%s/%s/%s%s", repo,
CVS_PATH_ATTIC, cf->file_name, RCS_FILE_EXT);
if (rename(cf->file_rpath, attic) == -1)
@@ -772,9 +772,9 @@ commit_desc_set(struct cvs_file *cf)
{
BUF *bp;
int fd;
- char desc_path[MAXPATHLEN], *desc;
+ char desc_path[PATH_MAX], *desc;
- (void)xsnprintf(desc_path, MAXPATHLEN, "%s/%s/%s%s",
+ (void)xsnprintf(desc_path, PATH_MAX, "%s/%s/%s%s",
cf->file_wd, CVS_PATH_CVSDIR, cf->file_name, CVS_DESCR_FILE_EXT);
if ((fd = open(desc_path, O_RDONLY)) == -1)
diff --git a/usr.bin/cvs/config.c b/usr.bin/cvs/config.c
index f9e29e50ba3..0d45f681ec0 100644
--- a/usr.bin/cvs/config.c
+++ b/usr.bin/cvs/config.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: config.c,v 1.15 2008/03/02 11:58:45 joris Exp $ */
+/* $OpenBSD: config.c,v 1.16 2015/01/16 06:40:07 deraadt Exp $ */
/*
* Copyright (c) 2006 Joris Vink <joris@openbsd.org>
*
@@ -15,7 +15,7 @@
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
-#include <sys/param.h>
+#include <sys/types.h>
#include <sys/dirent.h>
#include <sys/resource.h>
@@ -83,7 +83,7 @@ cvs_read_config(char *name, int (*cb)(char *, int))
FILE *fp;
size_t len;
int lineno;
- char *p, *buf, *lbuf, fpath[MAXPATHLEN];
+ char *p, *buf, *lbuf, fpath[PATH_MAX];
(void)xsnprintf(fpath, sizeof(fpath), "%s/%s",
current_cvsroot->cr_dir, name);
diff --git a/usr.bin/cvs/cvs.c b/usr.bin/cvs/cvs.c
index 15210e015f3..912be1af66d 100644
--- a/usr.bin/cvs/cvs.c
+++ b/usr.bin/cvs/cvs.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cvs.c,v 1.154 2014/12/01 21:58:46 deraadt Exp $ */
+/* $OpenBSD: cvs.c,v 1.155 2015/01/16 06:40:07 deraadt Exp $ */
/*
* Copyright (c) 2006, 2007 Joris Vink <joris@openbsd.org>
* Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org>
@@ -184,7 +184,7 @@ main(int argc, char **argv)
int i, ret, cmd_argc;
struct passwd *pw;
struct stat st;
- char fpath[MAXPATHLEN];
+ char fpath[PATH_MAX];
tzset();
@@ -426,7 +426,7 @@ cvs_getopt(int argc, char **argv)
static void
cvs_read_rcfile(void)
{
- char rcpath[MAXPATHLEN], *buf, *lbuf, *lp, *p;
+ char rcpath[PATH_MAX], *buf, *lbuf, *lp, *p;
int cmd_parsed, cvs_parsed, i, linenum;
size_t len, pos;
struct cvs_cmd *tcmdp;
@@ -434,8 +434,8 @@ cvs_read_rcfile(void)
linenum = 0;
- i = snprintf(rcpath, MAXPATHLEN, "%s/%s", cvs_homedir, CVS_PATH_RC);
- if (i < 0 || i >= MAXPATHLEN) {
+ i = snprintf(rcpath, PATH_MAX, "%s/%s", cvs_homedir, CVS_PATH_RC);
+ if (i < 0 || i >= PATH_MAX) {
cvs_log(LP_ERRNO, "%s", rcpath);
return;
}
diff --git a/usr.bin/cvs/diff3.c b/usr.bin/cvs/diff3.c
index 5f0d95e31ab..a15248a1bb7 100644
--- a/usr.bin/cvs/diff3.c
+++ b/usr.bin/cvs/diff3.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: diff3.c,v 1.56 2014/12/01 21:58:46 deraadt Exp $ */
+/* $OpenBSD: diff3.c,v 1.57 2015/01/16 06:40:07 deraadt Exp $ */
/*
* Copyright (C) Caldera International Inc. 2001-2002.
@@ -128,7 +128,7 @@ static int last[4];
static int eflag;
static int oflag; /* indicates whether to mark overlaps (-E or -X)*/
static int debug = 0;
-static char f1mark[MAXPATHLEN], f3mark[MAXPATHLEN]; /* markers for -E and -X */
+static char f1mark[PATH_MAX], f3mark[PATH_MAX]; /* markers for -E and -X */
static int duplicate(struct range *, struct range *);
static int edit(struct diff *, int, int);
diff --git a/usr.bin/cvs/diff_internals.c b/usr.bin/cvs/diff_internals.c
index 706415acbb5..1b34d922a65 100644
--- a/usr.bin/cvs/diff_internals.c
+++ b/usr.bin/cvs/diff_internals.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: diff_internals.c,v 1.35 2014/12/01 21:58:46 deraadt Exp $ */
+/* $OpenBSD: diff_internals.c,v 1.36 2015/01/16 06:40:07 deraadt Exp $ */
/*
* Copyright (C) Caldera International Inc. 2001-2002.
* All rights reserved.
@@ -64,7 +64,7 @@
* @(#)diffreg.c 8.1 (Berkeley) 6/6/93
*/
-#include <sys/param.h>
+#include <sys/types.h>
#include <sys/stat.h>
#include <ctype.h>
@@ -79,6 +79,9 @@
#include "cvs.h"
#include "diff.h"
+#define MINIMUM(a, b) (((a) < (b)) ? (a) : (b))
+#define MAXIMUM(a, b) (((a) > (b)) ? (a) : (b))
+
/*
* diff - compare two files.
*/
@@ -545,7 +548,7 @@ stone(int *a, int n, int *b, int *c, int flags)
bound = UINT_MAX;
else {
sq = isqrt(n);
- bound = MAX(256, sq);
+ bound = MAXIMUM(256, sq);
}
k = 0;
@@ -1273,10 +1276,10 @@ dump_context_vec(FILE *f1, FILE *f2, int flags)
return;
b = d = 0; /* gcc */
- lowa = MAX(1, cvp->a - diff_context);
- upb = MIN(len[0], context_vec_ptr->b + diff_context);
- lowc = MAX(1, cvp->c - diff_context);
- upd = MIN(len[1], context_vec_ptr->d + diff_context);
+ lowa = MAXIMUM(1, cvp->a - diff_context);
+ upb = MINIMUM(len[0], context_vec_ptr->b + diff_context);
+ lowc = MAXIMUM(1, cvp->c - diff_context);
+ upd = MINIMUM(len[1], context_vec_ptr->d + diff_context);
diff_output("***************");
if ((flags & D_PROTOTYPE)) {
@@ -1376,10 +1379,10 @@ dump_unified_vec(FILE *f1, FILE *f2, int flags)
return;
b = d = 0; /* gcc */
- lowa = MAX(1, cvp->a - diff_context);
- upb = MIN(len[0], context_vec_ptr->b + diff_context);
- lowc = MAX(1, cvp->c - diff_context);
- upd = MIN(len[1], context_vec_ptr->d + diff_context);
+ lowa = MAXIMUM(1, cvp->a - diff_context);
+ upb = MINIMUM(len[0], context_vec_ptr->b + diff_context);
+ lowc = MAXIMUM(1, cvp->c - diff_context);
+ upd = MINIMUM(len[1], context_vec_ptr->d + diff_context);
diff_output("@@ -");
uni_range(lowa, upb);
diff --git a/usr.bin/cvs/edit.c b/usr.bin/cvs/edit.c
index 8031b7000d0..2e292b93a68 100644
--- a/usr.bin/cvs/edit.c
+++ b/usr.bin/cvs/edit.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: edit.c,v 1.49 2010/07/09 18:42:14 zinovik Exp $ */
+/* $OpenBSD: edit.c,v 1.50 2015/01/16 06:40:07 deraadt Exp $ */
/*
* Copyright (c) 2006, 2007 Xavier Santolaria <xsa@openbsd.org>
*
@@ -260,8 +260,8 @@ cvs_edit_local(struct cvs_file *cf)
FILE *fp;
struct tm t;
time_t now;
- char timebuf[CVS_TIME_BUFSZ], thishost[MAXHOSTNAMELEN];
- char bfpath[MAXPATHLEN], wdir[MAXPATHLEN];
+ char timebuf[CVS_TIME_BUFSZ], thishost[HOST_NAME_MAX+1];
+ char bfpath[PATH_MAX], wdir[PATH_MAX];
if (cvs_noexec == 1)
return;
@@ -302,7 +302,7 @@ cvs_edit_local(struct cvs_file *cf)
if (fchmod(cf->fd, 0644) == -1)
fatal("cvs_edit_local: fchmod %s", strerror(errno));
- (void)xsnprintf(bfpath, MAXPATHLEN, "%s/%s",
+ (void)xsnprintf(bfpath, PATH_MAX, "%s/%s",
CVS_PATH_BASEDIR, cf->file_name);
if (mkdir(CVS_PATH_BASEDIR, 0755) == -1 && errno != EEXIST)
@@ -327,8 +327,8 @@ cvs_unedit_local(struct cvs_file *cf)
struct stat st;
struct tm t;
time_t now;
- char bfpath[MAXPATHLEN], timebuf[64], thishost[MAXHOSTNAMELEN];
- char wdir[MAXPATHLEN], sticky[CVS_ENT_MAXLINELEN];
+ char bfpath[PATH_MAX], timebuf[64], thishost[HOST_NAME_MAX+1];
+ char wdir[PATH_MAX], sticky[CVS_ENT_MAXLINELEN];
RCSNUM *ba_rev;
cvs_log(LP_TRACE, "cvs_unedit_local(%s)", cf->file_path);
@@ -338,7 +338,7 @@ cvs_unedit_local(struct cvs_file *cf)
cvs_file_classify(cf, cvs_directory_tag);
- (void)xsnprintf(bfpath, MAXPATHLEN, "%s/%s",
+ (void)xsnprintf(bfpath, PATH_MAX, "%s/%s",
CVS_PATH_BASEDIR, cf->file_name);
if (stat(bfpath, &st) == -1)
@@ -427,7 +427,7 @@ cvs_base_handle(struct cvs_file *cf, int flags)
RCSNUM *ba_rev;
int i;
char *dp, *sp;
- char buf[MAXPATHLEN], *fields[2], rbuf[CVS_REV_BUFSZ];
+ char buf[PATH_MAX], *fields[2], rbuf[CVS_REV_BUFSZ];
cvs_log(LP_TRACE, "cvs_base_handle(%s)", cf->file_path);
diff --git a/usr.bin/cvs/entries.c b/usr.bin/cvs/entries.c
index a4e2ce7a3f8..36fc65da695 100644
--- a/usr.bin/cvs/entries.c
+++ b/usr.bin/cvs/entries.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: entries.c,v 1.102 2009/03/19 09:53:16 joris Exp $ */
+/* $OpenBSD: entries.c,v 1.103 2015/01/16 06:40:07 deraadt Exp $ */
/*
* Copyright (c) 2006 Joris Vink <joris@openbsd.org>
*
@@ -35,7 +35,7 @@ cvs_ent_open(const char *dir)
{
FILE *fp;
CVSENTRIES *ep;
- char *p, buf[MAXPATHLEN];
+ char *p, buf[PATH_MAX];
struct cvs_ent *ent;
struct cvs_ent_line *line;
@@ -422,7 +422,7 @@ cvs_parse_tagfile(char *dir, char **tagp, char **datep, int *nbp)
int i, linenum;
size_t len;
struct tm datetm;
- char linebuf[128], tagpath[MAXPATHLEN];
+ char linebuf[128], tagpath[PATH_MAX];
cvs_directory_date = -1;
@@ -435,8 +435,8 @@ cvs_parse_tagfile(char *dir, char **tagp, char **datep, int *nbp)
if (nbp != NULL)
*nbp = 0;
- i = snprintf(tagpath, MAXPATHLEN, "%s/%s", dir, CVS_PATH_TAG);
- if (i < 0 || i >= MAXPATHLEN)
+ i = snprintf(tagpath, PATH_MAX, "%s/%s", dir, CVS_PATH_TAG);
+ if (i < 0 || i >= PATH_MAX)
return;
if ((fp = fopen(tagpath, "r")) == NULL) {
@@ -499,7 +499,7 @@ cvs_write_tagfile(const char *dir, char *tag, char *date)
{
FILE *fp;
RCSNUM *rev;
- char tagpath[MAXPATHLEN];
+ char tagpath[PATH_MAX];
char sticky[CVS_REV_BUFSZ];
struct tm datetm;
int i;
@@ -510,8 +510,8 @@ cvs_write_tagfile(const char *dir, char *tag, char *date)
if (cvs_noexec == 1)
return;
- i = snprintf(tagpath, MAXPATHLEN, "%s/%s", dir, CVS_PATH_TAG);
- if (i < 0 || i >= MAXPATHLEN)
+ i = snprintf(tagpath, PATH_MAX, "%s/%s", dir, CVS_PATH_TAG);
+ if (i < 0 || i >= PATH_MAX)
return;
if (tag != NULL || cvs_specified_date != -1 ||
diff --git a/usr.bin/cvs/file.c b/usr.bin/cvs/file.c
index be038b9fc50..7b26580461e 100644
--- a/usr.bin/cvs/file.c
+++ b/usr.bin/cvs/file.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: file.c,v 1.263 2013/12/13 15:19:41 zhuk Exp $ */
+/* $OpenBSD: file.c,v 1.264 2015/01/16 06:40:07 deraadt Exp $ */
/*
* Copyright (c) 2006 Joris Vink <joris@openbsd.org>
* Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org>
@@ -89,7 +89,7 @@ cvs_file_init(void)
{
int i;
FILE *ifp;
- char path[MAXPATHLEN], buf[MAXNAMLEN];
+ char path[PATH_MAX], buf[MAXNAMLEN];
TAILQ_INIT(&cvs_ign_pats);
TAILQ_INIT(&dir_ign_pats);
@@ -103,7 +103,7 @@ cvs_file_init(void)
return;
/* read the cvsignore file in the user's home directory, if any */
- (void)xsnprintf(path, MAXPATHLEN, "%s/.cvsignore", cvs_homedir);
+ (void)xsnprintf(path, PATH_MAX, "%s/.cvsignore", cvs_homedir);
ifp = fopen(path, "r");
if (ifp == NULL) {
@@ -264,7 +264,7 @@ cvs_file_walklist(struct cvs_flisthead *fl, struct cvs_recursion *cr)
struct stat st;
struct cvs_file *cf;
struct cvs_filelist *l, *nxt;
- char *d, *f, repo[MAXPATHLEN], fpath[MAXPATHLEN];
+ char *d, *f, repo[PATH_MAX], fpath[PATH_MAX];
for (l = RB_MIN(cvs_flisthead, fl); l != NULL; l = nxt) {
if (cvs_quit)
@@ -311,12 +311,12 @@ cvs_file_walklist(struct cvs_flisthead *fl, struct cvs_recursion *cr)
goto next;
}
- cvs_get_repository_path(d, repo, MAXPATHLEN);
- (void)xsnprintf(fpath, MAXPATHLEN, "%s/%s",
+ cvs_get_repository_path(d, repo, PATH_MAX);
+ (void)xsnprintf(fpath, PATH_MAX, "%s/%s",
repo, f);
if ((fd = open(fpath, O_RDONLY)) == -1) {
- strlcat(fpath, RCS_FILE_EXT, MAXPATHLEN);
+ strlcat(fpath, RCS_FILE_EXT, PATH_MAX);
fd = open(fpath, O_RDONLY);
}
@@ -362,7 +362,7 @@ cvs_file_walklist(struct cvs_flisthead *fl, struct cvs_recursion *cr)
if (current_cvsroot->cr_method ==
CVS_METHOD_LOCAL) {
cvs_get_repository_path(cf->file_wd,
- repo, MAXPATHLEN);
+ repo, PATH_MAX);
cvs_repository_lock(repo,
(cmdp->cmd_flags & CVS_LOCK_REPO));
}
@@ -402,7 +402,7 @@ cvs_file_walkdir(struct cvs_file *cf, struct cvs_recursion *cr)
struct cvs_ent_line *line;
struct cvs_flisthead fl, dl;
CVSENTRIES *entlist;
- char *buf, *ebuf, *cp, repo[MAXPATHLEN], fpath[MAXPATHLEN];
+ char *buf, *ebuf, *cp, repo[PATH_MAX], fpath[PATH_MAX];
cvs_log(LP_TRACE, "cvs_file_walkdir(%s)", cf->file_path);
@@ -429,7 +429,7 @@ cvs_file_walkdir(struct cvs_file *cf, struct cvs_recursion *cr)
* If we do not have an admin directory inside here, dont bother,
* unless we are running export or import.
*/
- (void)xsnprintf(fpath, MAXPATHLEN, "%s/%s", cf->file_path,
+ (void)xsnprintf(fpath, PATH_MAX, "%s/%s", cf->file_path,
CVS_PATH_CVSDIR);
l = stat(fpath, &st);
@@ -443,10 +443,10 @@ cvs_file_walkdir(struct cvs_file *cf, struct cvs_recursion *cr)
/*
* check for a local .cvsignore file
*/
- (void)xsnprintf(fpath, MAXPATHLEN, "%s/.cvsignore", cf->file_path);
+ (void)xsnprintf(fpath, PATH_MAX, "%s/.cvsignore", cf->file_path);
if ((fp = fopen(fpath, "r")) != NULL) {
- while (fgets(fpath, MAXPATHLEN, fp) != NULL) {
+ while (fgets(fpath, PATH_MAX, fp) != NULL) {
fpath[strcspn(fpath, "\n")] = '\0';
if (fpath[0] == '\0')
continue;
@@ -493,7 +493,7 @@ cvs_file_walkdir(struct cvs_file *cf, struct cvs_recursion *cr)
continue;
}
- (void)xsnprintf(fpath, MAXPATHLEN, "%s/%s",
+ (void)xsnprintf(fpath, PATH_MAX, "%s/%s",
cf->file_path, dp->d_name);
/*
@@ -572,7 +572,7 @@ cvs_file_walkdir(struct cvs_file *cf, struct cvs_recursion *cr)
TAILQ_FOREACH(line, &(entlist->cef_ent), entries_list) {
ent = cvs_ent_parse(line->buf);
- (void)xsnprintf(fpath, MAXPATHLEN, "%s/%s", cf->file_path,
+ (void)xsnprintf(fpath, PATH_MAX, "%s/%s", cf->file_path,
ent->ce_name);
if (!(cr->flags & CR_RECURSE_DIRS) &&
@@ -588,7 +588,7 @@ cvs_file_walkdir(struct cvs_file *cf, struct cvs_recursion *cr)
walkrepo:
if (current_cvsroot->cr_method == CVS_METHOD_LOCAL) {
- cvs_get_repository_path(cf->file_path, repo, MAXPATHLEN);
+ cvs_get_repository_path(cf->file_path, repo, PATH_MAX);
cvs_repository_lock(repo, (cmdp->cmd_flags & CVS_LOCK_REPO));
}
@@ -646,7 +646,7 @@ cvs_file_classify(struct cvs_file *cf, const char *tag)
int rflags, ismodified, rcsdead;
CVSENTRIES *entlist = NULL;
const char *state;
- char repo[MAXPATHLEN], rcsfile[MAXPATHLEN];
+ char repo[PATH_MAX], rcsfile[PATH_MAX];
cvs_log(LP_TRACE, "cvs_file_classify(%s, %s)", cf->file_path,
(tag != NULL) ? tag : "none");
@@ -656,13 +656,13 @@ cvs_file_classify(struct cvs_file *cf, const char *tag)
return;
}
- cvs_get_repository_path(cf->file_wd, repo, MAXPATHLEN);
- (void)xsnprintf(rcsfile, MAXPATHLEN, "%s/%s",
+ cvs_get_repository_path(cf->file_wd, repo, PATH_MAX);
+ (void)xsnprintf(rcsfile, PATH_MAX, "%s/%s",
repo, cf->file_name);
if (cf->file_type == CVS_FILE) {
- len = strlcat(rcsfile, RCS_FILE_EXT, MAXPATHLEN);
- if (len >= MAXPATHLEN)
+ len = strlcat(rcsfile, RCS_FILE_EXT, PATH_MAX);
+ if (len >= PATH_MAX)
fatal("cvs_file_classify: truncation");
}
@@ -748,7 +748,7 @@ cvs_file_classify(struct cvs_file *cf, const char *tag)
if (cf->file_rcs == NULL)
fatal("cvs_file_classify: failed to parse RCS");
} else {
- (void)xsnprintf(rcsfile, MAXPATHLEN, "%s/%s/%s%s",
+ (void)xsnprintf(rcsfile, PATH_MAX, "%s/%s/%s%s",
repo, CVS_PATH_ATTIC, cf->file_name, RCS_FILE_EXT);
cf->repo_fd = open(rcsfile, O_RDONLY);
diff --git a/usr.bin/cvs/hash.c b/usr.bin/cvs/hash.c
index 54a41466adf..6abad73c438 100644
--- a/usr.bin/cvs/hash.c
+++ b/usr.bin/cvs/hash.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: hash.c,v 1.1 2008/06/21 15:39:15 joris Exp $ */
+/* $OpenBSD: hash.c,v 1.2 2015/01/16 06:40:07 deraadt Exp $ */
/*
* Copyright (c) 2008 Joris Vink <joris@openbsd.org>
*
@@ -15,7 +15,7 @@
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
-#include <sys/param.h>
+#include <sys/types.h>
#include <sys/queue.h>
#include <stdio.h>
diff --git a/usr.bin/cvs/history.c b/usr.bin/cvs/history.c
index 53fb061a907..c9241aeefc5 100644
--- a/usr.bin/cvs/history.c
+++ b/usr.bin/cvs/history.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: history.c,v 1.41 2013/12/13 15:19:41 zhuk Exp $ */
+/* $OpenBSD: history.c,v 1.42 2015/01/16 06:40:07 deraadt Exp $ */
/*
* Copyright (c) 2007 Joris Vink <joris@openbsd.org>
*
@@ -70,7 +70,7 @@ cvs_history_add(int type, struct cvs_file *cf, const char *argument)
size_t len;
int fd;
char *cwd, *p, *rev;
- char revbuf[CVS_REV_BUFSZ], repo[MAXPATHLEN], fpath[MAXPATHLEN];
+ char revbuf[CVS_REV_BUFSZ], repo[PATH_MAX], fpath[PATH_MAX];
char timebuf[CVS_TIME_BUFSZ];
struct tm datetm;
diff --git a/usr.bin/cvs/import.c b/usr.bin/cvs/import.c
index 04b8c2f2410..20a6b6eaed6 100644
--- a/usr.bin/cvs/import.c
+++ b/usr.bin/cvs/import.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: import.c,v 1.103 2010/09/23 18:10:16 nicm Exp $ */
+/* $OpenBSD: import.c,v 1.104 2015/01/16 06:40:07 deraadt Exp $ */
/*
* Copyright (c) 2006 Joris Vink <joris@openbsd.org>
*
@@ -67,7 +67,7 @@ int
cvs_import(int argc, char **argv)
{
int i, ch;
- char repo[MAXPATHLEN], *arg = ".";
+ char repo[PATH_MAX], *arg = ".";
struct cvs_recursion cr;
struct trigger_list *line_list;
@@ -217,7 +217,7 @@ cvs_import_local(struct cvs_file *cf)
{
int isnew;
struct stat st;
- char repo[MAXPATHLEN];
+ char repo[PATH_MAX];
cvs_log(LP_TRACE, "cvs_import_local(%s)", cf->file_path);
@@ -258,7 +258,7 @@ static void
import_loginfo(char *repo)
{
int i;
- char pwd[MAXPATHLEN];
+ char pwd[PATH_MAX];
if (getcwd(pwd, sizeof(pwd)) == NULL)
fatal("Can't get working directory");
diff --git a/usr.bin/cvs/init.c b/usr.bin/cvs/init.c
index 513db507c26..54e37079070 100644
--- a/usr.bin/cvs/init.c
+++ b/usr.bin/cvs/init.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: init.c,v 1.38 2010/10/31 15:37:34 nicm Exp $ */
+/* $OpenBSD: init.c,v 1.39 2015/01/16 06:40:07 deraadt Exp $ */
/*
* Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org>
* Copyright (c) 2006 Xavier Santolaria <xsa@openbsd.org>
@@ -100,7 +100,7 @@ void
cvs_init_local(void)
{
u_int i;
- char path[MAXPATHLEN];
+ char path[PATH_MAX];
cvs_log(LP_TRACE, "cvs_init_local()");
@@ -108,14 +108,14 @@ cvs_init_local(void)
init_mkdir(current_cvsroot->cr_dir, 0777);
for (i = 0; i < INIT_NDIRS; i++) {
- (void)xsnprintf(path, MAXPATHLEN, "%s/%s",
+ (void)xsnprintf(path, PATH_MAX, "%s/%s",
current_cvsroot->cr_dir, cvsroot_dirs[i]);
init_mkdir(path, 0777);
}
for (i = 0; i < INIT_NFILES; i++) {
- (void)xsnprintf(path, MAXPATHLEN, "%s/%s",
+ (void)xsnprintf(path, PATH_MAX, "%s/%s",
current_cvsroot->cr_dir, cvsroot_files[i].cf_path);
init_mkfile(path, cvsroot_files[i].cf_content);
@@ -143,7 +143,7 @@ init_mkfile(char *path, const char **content)
BUF *b;
size_t len;
int fd, openflags, rcsflags;
- char rpath[MAXPATHLEN];
+ char rpath[PATH_MAX];
const char **p;
RCSFILE *file;
@@ -172,7 +172,7 @@ init_mkfile(char *path, const char **content)
return;
}
- (void)xsnprintf(rpath, MAXPATHLEN, "%s%s", path, RCS_FILE_EXT);
+ (void)xsnprintf(rpath, PATH_MAX, "%s%s", path, RCS_FILE_EXT);
if ((file = rcs_open(rpath, -1, rcsflags, 0444)) == NULL)
fatal("failed to create RCS file for `%s'", path);
diff --git a/usr.bin/cvs/logmsg.c b/usr.bin/cvs/logmsg.c
index 12e667de44f..7e4eae7ccfb 100644
--- a/usr.bin/cvs/logmsg.c
+++ b/usr.bin/cvs/logmsg.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: logmsg.c,v 1.54 2010/07/23 21:46:05 ray Exp $ */
+/* $OpenBSD: logmsg.c,v 1.55 2015/01/16 06:40:07 deraadt Exp $ */
/*
* Copyright (c) 2007 Joris Vink <joris@openbsd.org>
*
@@ -99,7 +99,7 @@ cvs_logmsg_create(char *dir, struct cvs_flisthead *added,
int c, fd, rd, saved_errno;
struct cvs_filelist *cf;
struct stat st1, st2;
- char *fpath, *logmsg, repo[MAXPATHLEN];
+ char *fpath, *logmsg, repo[PATH_MAX];
struct stat st;
struct trigger_list *line_list;
struct trigger_line *line;
diff --git a/usr.bin/cvs/modules.c b/usr.bin/cvs/modules.c
index 95b0c37febf..82c385340df 100644
--- a/usr.bin/cvs/modules.c
+++ b/usr.bin/cvs/modules.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: modules.c,v 1.17 2014/01/08 13:23:55 okan Exp $ */
+/* $OpenBSD: modules.c,v 1.18 2015/01/16 06:40:07 deraadt Exp $ */
/*
* Copyright (c) 2008 Joris Vink <joris@openbsd.org>
*
@@ -15,7 +15,7 @@
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
-#include <sys/param.h>
+#include <sys/types.h>
#include <sys/dirent.h>
#include <sys/resource.h>
@@ -55,7 +55,7 @@ modules_parse_line(char *line, int lineno)
int flags;
struct module_info *mi;
char *bline, *val, *p, *module, *sp, *dp;
- char *dirname, fpath[MAXPATHLEN], *prog;
+ char *dirname, fpath[PATH_MAX], *prog;
prog = NULL;
bline = xstrdup(line);
diff --git a/usr.bin/cvs/rcs.c b/usr.bin/cvs/rcs.c
index c355c2243ae..220fee8f2f4 100644
--- a/usr.bin/cvs/rcs.c
+++ b/usr.bin/cvs/rcs.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rcs.c,v 1.311 2014/01/08 13:23:55 okan Exp $ */
+/* $OpenBSD: rcs.c,v 1.312 2015/01/16 06:40:07 deraadt Exp $ */
/*
* Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org>
* All rights reserved.
@@ -40,6 +40,8 @@
#include "rcs.h"
#include "rcsparse.h"
+#define MINIMUM(a, b) (((a) < (b)) ? (a) : (b))
+
#define RCS_KWEXP_SIZE 1024
#define ANNOTATE_NEVER 0
@@ -284,7 +286,7 @@ void
rcs_write(RCSFILE *rfp)
{
FILE *fp;
- char numbuf[CVS_REV_BUFSZ], *fn, tmpdir[MAXPATHLEN];
+ char numbuf[CVS_REV_BUFSZ], *fn, tmpdir[PATH_MAX];
struct rcs_access *ap;
struct rcs_sym *symp;
struct rcs_branch *brp;
@@ -1704,7 +1706,7 @@ rcs_get_revision(const char *revstr, RCSFILE *rfp)
* instead of just 2.
*/
if (rfp->rf_head == NULL || rcsnum_cmp(rev, rfp->rf_head,
- MIN(rfp->rf_head->rn_len, rev->rn_len)) < 0) {
+ MINIMUM(rfp->rf_head->rn_len, rev->rn_len)) < 0) {
rcsnum_free(rev);
return (NULL);
}
diff --git a/usr.bin/cvs/rcsnum.c b/usr.bin/cvs/rcsnum.c
index ac613b4ac5a..cd35a3b16da 100644
--- a/usr.bin/cvs/rcsnum.c
+++ b/usr.bin/cvs/rcsnum.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rcsnum.c,v 1.55 2014/01/08 13:23:55 okan Exp $ */
+/* $OpenBSD: rcsnum.c,v 1.56 2015/01/16 06:40:07 deraadt Exp $ */
/*
* Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org>
* All rights reserved.
@@ -29,6 +29,8 @@
#include "cvs.h"
+#define MINIMUM(a, b) (((a) < (b)) ? (a) : (b))
+
static void rcsnum_setsize(RCSNUM *, u_int);
static char *rcsnum_itoa(u_int16_t, char *, size_t);
@@ -188,7 +190,7 @@ rcsnum_cmp(RCSNUM *n1, RCSNUM *n2, u_int depth)
if (!rcsnum_differ(n1, n2))
return (0);
- slen = MIN(n1->rn_len, n2->rn_len);
+ slen = MINIMUM(n1->rn_len, n2->rn_len);
if (depth != 0 && slen > depth)
slen = depth;
@@ -435,7 +437,7 @@ rcsnum_differ(RCSNUM *r1, RCSNUM *r2)
if (r1->rn_len != r2->rn_len)
return (1);
- len = MIN(r1->rn_len, r2->rn_len);
+ len = MINIMUM(r1->rn_len, r2->rn_len);
for (i = 0; i < len; i++) {
if (r1->rn_id[i] != r2->rn_id[i])
return (1);
diff --git a/usr.bin/cvs/release.c b/usr.bin/cvs/release.c
index 8ca08835256..9544791cb07 100644
--- a/usr.bin/cvs/release.c
+++ b/usr.bin/cvs/release.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: release.c,v 1.41 2009/03/21 11:18:45 joris Exp $ */
+/* $OpenBSD: release.c,v 1.42 2015/01/16 06:40:07 deraadt Exp $ */
/*-
* Copyright (c) 2005-2007 Xavier Santolaria <xsa@openbsd.org>
*
@@ -96,7 +96,7 @@ cvs_release_local(struct cvs_file *cf)
{
struct stat st;
struct cvs_recursion cr;
- char *wdir, cwd[MAXPATHLEN];
+ char *wdir, cwd[PATH_MAX];
char *arg = ".";
int saved_noexec;
diff --git a/usr.bin/cvs/remote.c b/usr.bin/cvs/remote.c
index 162fe539282..4c122ad984f 100644
--- a/usr.bin/cvs/remote.c
+++ b/usr.bin/cvs/remote.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: remote.c,v 1.29 2010/07/23 21:46:05 ray Exp $ */
+/* $OpenBSD: remote.c,v 1.30 2015/01/16 06:40:07 deraadt Exp $ */
/*
* Copyright (c) 2006 Joris Vink <joris@openbsd.org>
*
@@ -15,6 +15,7 @@
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
+#include <sys/param.h> /* MAXBSIZE */
#include <sys/stat.h>
#include <errno.h>
@@ -27,6 +28,8 @@
#include "cvs.h"
#include "remote.h"
+#define MINIMUM(a, b) (((a) < (b)) ? (a) : (b))
+
struct cvs_resp *
cvs_remote_get_response_info(const char *response)
{
@@ -136,7 +139,7 @@ cvs_remote_receive_file(int fd, size_t len)
nleft = len;
while (nleft > 0) {
- toread = MIN(nleft, MAXBSIZE);
+ toread = MINIMUM(nleft, MAXBSIZE);
nread = fread(data, sizeof(char), toread, in);
if (nread == 0)
diff --git a/usr.bin/cvs/remove.c b/usr.bin/cvs/remove.c
index 72a0575840f..e2a143d460e 100644
--- a/usr.bin/cvs/remove.c
+++ b/usr.bin/cvs/remove.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: remove.c,v 1.81 2011/12/27 13:59:01 nicm Exp $ */
+/* $OpenBSD: remove.c,v 1.82 2015/01/16 06:40:07 deraadt Exp $ */
/*
* Copyright (c) 2005, 2006 Xavier Santolaria <xsa@openbsd.org>
*
@@ -137,7 +137,7 @@ void
cvs_remove_local(struct cvs_file *cf)
{
CVSENTRIES *entlist;
- char *entry, buf[MAXPATHLEN], tbuf[CVS_TIME_BUFSZ], rbuf[CVS_REV_BUFSZ];
+ char *entry, buf[PATH_MAX], tbuf[CVS_TIME_BUFSZ], rbuf[CVS_REV_BUFSZ];
char sticky[CVS_ENT_MAXLINELEN];
cvs_log(LP_TRACE, "cvs_remove_local(%s)", cf->file_path);
diff --git a/usr.bin/cvs/repository.c b/usr.bin/cvs/repository.c
index c2df4be05e6..a5d0fa761ac 100644
--- a/usr.bin/cvs/repository.c
+++ b/usr.bin/cvs/repository.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: repository.c,v 1.23 2010/07/23 08:31:19 ray Exp $ */
+/* $OpenBSD: repository.c,v 1.24 2015/01/16 06:40:07 deraadt Exp $ */
/*
* Copyright (c) 2006 Joris Vink <joris@openbsd.org>
*
@@ -30,7 +30,7 @@ struct wklhead repo_locks;
void
cvs_repository_unlock(const char *repo)
{
- char fpath[MAXPATHLEN];
+ char fpath[PATH_MAX];
cvs_log(LP_TRACE, "cvs_repository_unlock(%s)", repo);
@@ -46,7 +46,7 @@ cvs_repository_lock(const char *repo, int wantlock)
int i;
uid_t myuid;
struct stat st;
- char fpath[MAXPATHLEN];
+ char fpath[PATH_MAX];
struct passwd *pw;
if (cvs_noexec == 1 || cvs_readonlyfs == 1)
@@ -102,7 +102,7 @@ cvs_repository_getdir(const char *dir, const char *wdir,
DIR *dirp;
struct stat st;
struct dirent *dp;
- char *s, fpath[MAXPATHLEN], rpath[MAXPATHLEN];
+ char *s, fpath[PATH_MAX], rpath[PATH_MAX];
if ((dirp = opendir(dir)) == NULL)
fatal("cvs_repository_getdir: failed to open '%s'", dir);
@@ -113,8 +113,8 @@ cvs_repository_getdir(const char *dir, const char *wdir,
!strcmp(dp->d_name, CVS_LOCK))
continue;
- (void)xsnprintf(fpath, MAXPATHLEN, "%s/%s", wdir, dp->d_name);
- (void)xsnprintf(rpath, MAXPATHLEN, "%s/%s", dir, dp->d_name);
+ (void)xsnprintf(fpath, PATH_MAX, "%s/%s", wdir, dp->d_name);
+ (void)xsnprintf(rpath, PATH_MAX, "%s/%s", dir, dp->d_name);
if (!TAILQ_EMPTY(&checkout_ign_pats)) {
if ((s = strrchr(fpath, ',')) != NULL)
diff --git a/usr.bin/cvs/root.c b/usr.bin/cvs/root.c
index d71b2f66be2..1143ea9f280 100644
--- a/usr.bin/cvs/root.c
+++ b/usr.bin/cvs/root.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: root.c,v 1.47 2010/10/23 18:36:35 nicm Exp $ */
+/* $OpenBSD: root.c,v 1.48 2015/01/16 06:40:07 deraadt Exp $ */
/*
* Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org>
* All rights reserved.
@@ -163,7 +163,7 @@ cvsroot_parse(const char *str)
struct cvsroot *
cvsroot_get(const char *dir)
{
- char rootpath[MAXPATHLEN], *rootstr, line[128];
+ char rootpath[PATH_MAX], *rootstr, line[128];
FILE *fp;
if (cvs_rootstr != NULL)
@@ -178,7 +178,7 @@ cvsroot_get(const char *dir)
return (NULL);
}
- (void)xsnprintf(rootpath, MAXPATHLEN, "%s/%s", dir, CVS_PATH_ROOTSPEC);
+ (void)xsnprintf(rootpath, PATH_MAX, "%s/%s", dir, CVS_PATH_ROOTSPEC);
if ((fp = fopen(rootpath, "r")) == NULL) {
if (errno == ENOENT) {
diff --git a/usr.bin/cvs/server.c b/usr.bin/cvs/server.c
index c733ab49a9b..e01a23db438 100644
--- a/usr.bin/cvs/server.c
+++ b/usr.bin/cvs/server.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: server.c,v 1.101 2014/12/01 21:58:46 deraadt Exp $ */
+/* $OpenBSD: server.c,v 1.102 2015/01/16 06:40:07 deraadt Exp $ */
/*
* Copyright (c) 2006 Joris Vink <joris@openbsd.org>
*
@@ -244,9 +244,9 @@ void
cvs_server_static_directory(char *data)
{
FILE *fp;
- char fpath[MAXPATHLEN];
+ char fpath[PATH_MAX];
- (void)xsnprintf(fpath, MAXPATHLEN, "%s/%s",
+ (void)xsnprintf(fpath, PATH_MAX, "%s/%s",
server_currentdir, CVS_PATH_STATICENTRIES);
if ((fp = fopen(fpath, "w+")) == NULL) {
@@ -260,12 +260,12 @@ void
cvs_server_sticky(char *data)
{
FILE *fp;
- char tagpath[MAXPATHLEN];
+ char tagpath[PATH_MAX];
if (data == NULL)
fatal("Missing argument for Sticky");
- (void)xsnprintf(tagpath, MAXPATHLEN, "%s/%s",
+ (void)xsnprintf(tagpath, PATH_MAX, "%s/%s",
server_currentdir, CVS_PATH_TAG);
if ((fp = fopen(tagpath, "w+")) == NULL) {
@@ -392,7 +392,7 @@ cvs_server_modified(char *data)
size_t flen;
mode_t fmode;
const char *errstr;
- char *mode, *len, fpath[MAXPATHLEN];
+ char *mode, *len, fpath[PATH_MAX];
if (data == NULL)
fatal("Missing argument for Modified");
@@ -411,7 +411,7 @@ cvs_server_modified(char *data)
fatal("cvs_server_modified: %s", errstr);
xfree(len);
- (void)xsnprintf(fpath, MAXPATHLEN, "%s/%s", server_currentdir, data);
+ (void)xsnprintf(fpath, PATH_MAX, "%s/%s", server_currentdir, data);
if ((fd = open(fpath, O_WRONLY | O_CREAT | O_TRUNC)) == -1)
fatal("cvs_server_modified: %s: %s", fpath, strerror(errno));
@@ -432,7 +432,7 @@ cvs_server_useunchanged(char *data)
void
cvs_server_unchanged(char *data)
{
- char fpath[MAXPATHLEN];
+ char fpath[PATH_MAX];
CVSENTRIES *entlist;
struct cvs_ent *ent;
char sticky[CVS_ENT_MAXLINELEN];
@@ -444,7 +444,7 @@ cvs_server_unchanged(char *data)
/* sorry, we have to use TMP_DIR */
disable_fast_checkout = 1;
- (void)xsnprintf(fpath, MAXPATHLEN, "%s/%s", server_currentdir, data);
+ (void)xsnprintf(fpath, PATH_MAX, "%s/%s", server_currentdir, data);
entlist = cvs_ent_open(server_currentdir);
ent = cvs_ent_get(entlist, data);
@@ -771,13 +771,13 @@ void
cvs_server_update_entry(const char *resp, struct cvs_file *cf)
{
char *p;
- char repo[MAXPATHLEN], fpath[MAXPATHLEN];
+ char repo[PATH_MAX], fpath[PATH_MAX];
if ((p = strrchr(cf->file_rpath, ',')) != NULL)
*p = '\0';
- cvs_get_repository_path(cf->file_wd, repo, MAXPATHLEN);
- (void)xsnprintf(fpath, MAXPATHLEN, "%s/%s", repo, cf->file_name);
+ cvs_get_repository_path(cf->file_wd, repo, PATH_MAX);
+ (void)xsnprintf(fpath, PATH_MAX, "%s/%s", repo, cf->file_name);
cvs_server_send_response("%s %s/", resp, cf->file_wd);
cvs_remote_output(fpath);
@@ -789,11 +789,11 @@ cvs_server_update_entry(const char *resp, struct cvs_file *cf)
void
cvs_server_set_sticky(const char *dir, const char *tag)
{
- char fpath[MAXPATHLEN];
- char repo[MAXPATHLEN];
+ char fpath[PATH_MAX];
+ char repo[PATH_MAX];
- cvs_get_repository_path(dir, repo, MAXPATHLEN);
- (void)xsnprintf(fpath, MAXPATHLEN, "%s/", repo);
+ cvs_get_repository_path(dir, repo, PATH_MAX);
+ (void)xsnprintf(fpath, PATH_MAX, "%s/", repo);
cvs_server_send_response("Set-sticky %s/", dir);
cvs_remote_output(fpath);
@@ -803,11 +803,11 @@ cvs_server_set_sticky(const char *dir, const char *tag)
void
cvs_server_clear_sticky(char *dir)
{
- char fpath[MAXPATHLEN];
- char repo[MAXPATHLEN];
+ char fpath[PATH_MAX];
+ char repo[PATH_MAX];
- cvs_get_repository_path(dir, repo, MAXPATHLEN);
- (void)xsnprintf(fpath, MAXPATHLEN, "%s/", repo);
+ cvs_get_repository_path(dir, repo, PATH_MAX);
+ (void)xsnprintf(fpath, PATH_MAX, "%s/", repo);
cvs_server_send_response("Clear-sticky %s//", dir);
cvs_remote_output(fpath);
diff --git a/usr.bin/cvs/status.c b/usr.bin/cvs/status.c
index 2089752f3dc..80bc5077ab3 100644
--- a/usr.bin/cvs/status.c
+++ b/usr.bin/cvs/status.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: status.c,v 1.93 2010/04/19 13:03:10 millert Exp $ */
+/* $OpenBSD: status.c,v 1.94 2015/01/16 06:40:07 deraadt Exp $ */
/*
* Copyright (c) 2006 Joris Vink <joris@openbsd.org>
* Copyright (c) 2005-2008 Xavier Santolaria <xsa@openbsd.org>
@@ -121,7 +121,7 @@ cvs_status_local(struct cvs_file *cf)
size_t len;
RCSNUM *head;
const char *status;
- char buf[MAXPATHLEN + CVS_REV_BUFSZ + 128];
+ char buf[PATH_MAX + CVS_REV_BUFSZ + 128];
char timebuf[CVS_TIME_BUFSZ], revbuf[CVS_REV_BUFSZ];
struct rcs_sym *sym;
diff --git a/usr.bin/cvs/tag.c b/usr.bin/cvs/tag.c
index 41c6b643820..a7a5fe47e33 100644
--- a/usr.bin/cvs/tag.c
+++ b/usr.bin/cvs/tag.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: tag.c,v 1.80 2010/10/28 12:30:27 tobias Exp $ */
+/* $OpenBSD: tag.c,v 1.81 2015/01/16 06:40:07 deraadt Exp $ */
/*
* Copyright (c) 2006 Xavier Santolaria <xsa@openbsd.org>
*
@@ -65,7 +65,7 @@ int
cvs_tag(int argc, char **argv)
{
int ch, flags, i;
- char repo[MAXPATHLEN];
+ char repo[PATH_MAX];
char *arg = ".";
struct cvs_recursion cr;
struct trigger_list *line_list;
@@ -186,7 +186,7 @@ cvs_tag(int argc, char **argv)
cr.flags = flags;
- cvs_get_repository_name(".", repo, MAXPATHLEN);
+ cvs_get_repository_name(".", repo, PATH_MAX);
line_list = cvs_trigger_getlines(CVS_PATH_TAGINFO, repo);
if (line_list != NULL) {
TAILQ_INIT(&files_info);
diff --git a/usr.bin/cvs/trigger.c b/usr.bin/cvs/trigger.c
index 5fc306408af..20a5e4dd650 100644
--- a/usr.bin/cvs/trigger.c
+++ b/usr.bin/cvs/trigger.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: trigger.c,v 1.21 2014/01/08 13:23:55 okan Exp $ */
+/* $OpenBSD: trigger.c,v 1.22 2015/01/16 06:40:07 deraadt Exp $ */
/*
* Copyright (c) 2008 Tobias Stoeckmann <tobias@openbsd.org>
* Copyright (c) 2008 Jonathan Armani <dbd@asystant.net>
@@ -382,7 +382,7 @@ cvs_trigger_getlines(char * file, char * repo)
regex_t preg;
struct trigger_list *list;
struct trigger_line *tline;
- char fpath[MAXPATHLEN];
+ char fpath[PATH_MAX];
char *currentline, *defaultline = NULL, *nline, *p, *q, *regex;
if (strcmp(file, CVS_PATH_EDITINFO) == 0 ||
@@ -391,7 +391,7 @@ cvs_trigger_getlines(char * file, char * repo)
else
allow_all = 1;
- (void)xsnprintf(fpath, MAXPATHLEN, "%s/%s", current_cvsroot->cr_dir,
+ (void)xsnprintf(fpath, PATH_MAX, "%s/%s", current_cvsroot->cr_dir,
file);
if ((fp = fopen(fpath, "r")) == NULL) {
@@ -535,8 +535,8 @@ cvs_trigger_freeinfo(struct file_info_list * list)
void
cvs_trigger_loginfo_header(BUF *buf, char *repo)
{
- char *dir, pwd[MAXPATHLEN];
- char hostname[MAXHOSTNAMELEN];
+ char *dir, pwd[PATH_MAX];
+ char hostname[HOST_NAME_MAX+1];
if (gethostname(hostname, sizeof(hostname)) == -1) {
fatal("cvs_trigger_loginfo_header: gethostname failed %s",
diff --git a/usr.bin/cvs/update.c b/usr.bin/cvs/update.c
index 2441dcafa9c..7290937bfc9 100644
--- a/usr.bin/cvs/update.c
+++ b/usr.bin/cvs/update.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: update.c,v 1.168 2013/12/13 15:19:41 zhuk Exp $ */
+/* $OpenBSD: update.c,v 1.169 2015/01/16 06:40:07 deraadt Exp $ */
/*
* Copyright (c) 2006 Joris Vink <joris@openbsd.org>
*
@@ -192,7 +192,7 @@ void
cvs_update_enterdir(struct cvs_file *cf)
{
CVSENTRIES *entlist;
- char *dirtag, *entry, fpath[MAXPATHLEN];
+ char *dirtag, *entry, fpath[PATH_MAX];
cvs_log(LP_TRACE, "cvs_update_enterdir(%s)", cf->file_path);
@@ -223,7 +223,7 @@ cvs_update_enterdir(struct cvs_file *cf)
cf->file_status == FILE_UNKNOWN) {
cf->file_status = FILE_SKIP;
} else if (reset_tag) {
- (void)xsnprintf(fpath, MAXPATHLEN, "%s/%s",
+ (void)xsnprintf(fpath, PATH_MAX, "%s/%s",
cf->file_path, CVS_PATH_TAG);
(void)unlink(fpath);
} else {
@@ -725,7 +725,7 @@ out:
void
cvs_backup_file(struct cvs_file *cf)
{
- char backup_name[MAXPATHLEN];
+ char backup_name[PATH_MAX];
char revstr[RCSNUM_MAXSTR];
if (cf->file_status == FILE_ADDED)
@@ -733,12 +733,12 @@ cvs_backup_file(struct cvs_file *cf)
else
rcsnum_tostr(cf->file_ent->ce_rev, revstr, sizeof(revstr));
- (void)xsnprintf(backup_name, MAXPATHLEN, "%s/.#%s.%s",
+ (void)xsnprintf(backup_name, PATH_MAX, "%s/.#%s.%s",
cf->file_wd, cf->file_name, revstr);
cvs_file_copy(cf->file_path, backup_name);
- (void)xsnprintf(backup_name, MAXPATHLEN, ".#%s.%s",
+ (void)xsnprintf(backup_name, PATH_MAX, ".#%s.%s",
cf->file_name, revstr);
cvs_printf("(Locally modified %s moved to %s)\n",
cf->file_name, backup_name);
diff --git a/usr.bin/cvs/util.c b/usr.bin/cvs/util.c
index 3d6b0948aab..747c28346fd 100644
--- a/usr.bin/cvs/util.c
+++ b/usr.bin/cvs/util.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: util.c,v 1.156 2014/12/01 21:58:46 deraadt Exp $ */
+/* $OpenBSD: util.c,v 1.157 2015/01/16 06:40:07 deraadt Exp $ */
/*
* Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org>
* Copyright (c) 2005, 2006 Joris Vink <joris@openbsd.org>
@@ -366,7 +366,7 @@ cvs_rmdir(const char *path)
DIR *dirp;
struct dirent *ent;
struct stat st;
- char fpath[MAXPATHLEN];
+ char fpath[PATH_MAX];
if (cvs_server_active == 0)
cvs_log(LP_TRACE, "cvs_rmdir(%s)", path);
@@ -444,7 +444,7 @@ done:
void
cvs_get_repository_path(const char *dir, char *dst, size_t len)
{
- char buf[MAXPATHLEN];
+ char buf[PATH_MAX];
cvs_get_repository_name(dir, buf, sizeof(buf));
(void)xsnprintf(dst, len, "%s/%s", current_cvsroot->cr_dir, buf);
@@ -455,7 +455,7 @@ void
cvs_get_repository_name(const char *dir, char *dst, size_t len)
{
FILE *fp;
- char fpath[MAXPATHLEN];
+ char fpath[PATH_MAX];
dst[0] = '\0';
@@ -501,7 +501,7 @@ cvs_mkadmin(const char *path, const char *root, const char *repo,
{
FILE *fp;
int fd;
- char buf[MAXPATHLEN];
+ char buf[PATH_MAX];
struct hash_data *hdata, hd;
hdata = hash_table_find(&created_cvs_directories, path, strlen(path));
@@ -565,7 +565,7 @@ cvs_mkpath(const char *path, char *tag)
FILE *fp;
size_t len;
struct hash_data *hdata, hd;
- char *entry, *sp, *dp, *dir, *p, rpath[MAXPATHLEN], repo[MAXPATHLEN];
+ char *entry, *sp, *dp, *dir, *p, rpath[PATH_MAX], repo[PATH_MAX];
hdata = hash_table_find(&created_directories, path, strlen(path));
if (hdata != NULL)
@@ -662,7 +662,7 @@ void
cvs_mkdir(const char *path, mode_t mode)
{
size_t len;
- char *sp, *dp, *dir, rpath[MAXPATHLEN];
+ char *sp, *dp, *dir, rpath[PATH_MAX];
if (current_cvsroot->cr_method != CVS_METHOD_LOCAL ||
cvs_server_active == 1)
diff --git a/usr.bin/cvs/worklist.h b/usr.bin/cvs/worklist.h
index d2eaa533d21..5a7125fcead 100644
--- a/usr.bin/cvs/worklist.h
+++ b/usr.bin/cvs/worklist.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: worklist.h,v 1.7 2010/07/23 08:31:19 ray Exp $ */
+/* $OpenBSD: worklist.h,v 1.8 2015/01/16 06:40:07 deraadt Exp $ */
/*
* Copyright (c) 2006 Joris Vink <joris@openbsd.org>
* All rights reserved.
@@ -27,10 +27,11 @@
#ifndef WORKLIST_H
#define WORKLIST_H
-#include <sys/param.h>
+#include <sys/types.h>
+#include <limits.h>
struct worklist {
- char wkl_path[MAXPATHLEN];
+ char wkl_path[PATH_MAX];
volatile SLIST_ENTRY(worklist) wkl_list;
};
diff --git a/usr.bin/diff/diff.c b/usr.bin/diff/diff.c
index e0c6dbe8c73..fbe46714f7d 100644
--- a/usr.bin/diff/diff.c
+++ b/usr.bin/diff/diff.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: diff.c,v 1.57 2010/07/16 23:27:58 ray Exp $ */
+/* $OpenBSD: diff.c,v 1.58 2015/01/16 06:40:07 deraadt Exp $ */
/*
* Copyright (c) 2003 Todd C. Miller <Todd.Miller@courtesan.com>
@@ -20,7 +20,6 @@
* Materiel Command, USAF, under agreement number F39502-99-1-0512.
*/
-#include <sys/param.h>
#include <sys/stat.h>
#include <ctype.h>
@@ -33,6 +32,7 @@
#include <stdarg.h>
#include <string.h>
#include <unistd.h>
+#include <limits.h>
#include "diff.h"
#include "xmalloc.h"
diff --git a/usr.bin/diff/diffdir.c b/usr.bin/diff/diffdir.c
index 64b173975bd..dc6f17fd3c4 100644
--- a/usr.bin/diff/diffdir.c
+++ b/usr.bin/diff/diffdir.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: diffdir.c,v 1.42 2014/05/20 01:25:23 guenther Exp $ */
+/* $OpenBSD: diffdir.c,v 1.43 2015/01/16 06:40:07 deraadt Exp $ */
/*
* Copyright (c) 2003, 2010 Todd C. Miller <Todd.Miller@courtesan.com>
@@ -20,7 +20,6 @@
* Materiel Command, USAF, under agreement number F39502-99-1-0512.
*/
-#include <sys/param.h>
#include <sys/stat.h>
#include <dirent.h>
@@ -33,6 +32,7 @@
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
+#include <limits.h>
#include "diff.h"
#include "xmalloc.h"
@@ -51,7 +51,7 @@ diffdir(char *p1, char *p2, int flags)
struct dirent *dent1, **dp1, **edp1, **dirp1 = NULL;
struct dirent *dent2, **dp2, **edp2, **dirp2 = NULL;
size_t dirlen1, dirlen2;
- char path1[MAXPATHLEN], path2[MAXPATHLEN];
+ char path1[PATH_MAX], path2[PATH_MAX];
int pos;
dirlen1 = strlcpy(path1, *p1 ? p1 : ".", sizeof(path1));
@@ -184,7 +184,7 @@ diffit(struct dirent *dp, char *path1, size_t plen1, char *path2, size_t plen2,
int flags)
{
flags |= D_HEADER;
- strlcpy(path1 + plen1, dp->d_name, MAXPATHLEN - plen1);
+ strlcpy(path1 + plen1, dp->d_name, PATH_MAX - plen1);
if (stat(path1, &stb1) != 0) {
if (!(Nflag || Pflag) || errno != ENOENT) {
warn("%s", path1);
@@ -194,7 +194,7 @@ diffit(struct dirent *dp, char *path1, size_t plen1, char *path2, size_t plen2,
memset(&stb1, 0, sizeof(stb1));
}
- strlcpy(path2 + plen2, dp->d_name, MAXPATHLEN - plen2);
+ strlcpy(path2 + plen2, dp->d_name, PATH_MAX - plen2);
if (stat(path2, &stb2) != 0) {
if (!Nflag || errno != ENOENT) {
warn("%s", path2);
diff --git a/usr.bin/diff/diffreg.c b/usr.bin/diff/diffreg.c
index f949cd27c27..83a86e6aab4 100644
--- a/usr.bin/diff/diffreg.c
+++ b/usr.bin/diff/diffreg.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: diffreg.c,v 1.83 2014/08/27 15:22:40 kspillner Exp $ */
+/* $OpenBSD: diffreg.c,v 1.84 2015/01/16 06:40:07 deraadt Exp $ */
/*
* Copyright (C) Caldera International Inc. 2001-2002.
@@ -64,7 +64,6 @@
* @(#)diffreg.c 8.1 (Berkeley) 6/6/93
*/
-#include <sys/param.h>
#include <sys/stat.h>
#include <sys/wait.h>
@@ -77,11 +76,15 @@
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
+#include <limits.h>
#include "diff.h"
#include "pathnames.h"
#include "xmalloc.h"
+#define MINIMUM(a, b) (((a) < (b)) ? (a) : (b))
+#define MAXIMUM(a, b) (((a) > (b)) ? (a) : (b))
+
/*
* diff - compare two files.
*/
@@ -495,7 +498,7 @@ files_differ(FILE *f1, FILE *f2, int flags)
static FILE *
opentemp(const char *file)
{
- char buf[BUFSIZ], *tempdir, tempfile[MAXPATHLEN];
+ char buf[BUFSIZ], *tempdir, tempfile[PATH_MAX];
ssize_t nread;
int ifd, ofd;
@@ -653,7 +656,7 @@ stone(int *a, int n, int *b, int *c, int flags)
bound = UINT_MAX;
else {
sq = isqrt(n);
- bound = MAX(256, sq);
+ bound = MAXIMUM(256, sq);
}
k = 0;
@@ -1360,10 +1363,10 @@ dump_context_vec(FILE *f1, FILE *f2, int flags)
return;
b = d = 0; /* gcc */
- lowa = MAX(1, cvp->a - diff_context);
- upb = MIN(len[0], context_vec_ptr->b + diff_context);
- lowc = MAX(1, cvp->c - diff_context);
- upd = MIN(len[1], context_vec_ptr->d + diff_context);
+ lowa = MAXIMUM(1, cvp->a - diff_context);
+ upb = MINIMUM(len[0], context_vec_ptr->b + diff_context);
+ lowc = MAXIMUM(1, cvp->c - diff_context);
+ upd = MINIMUM(len[1], context_vec_ptr->d + diff_context);
diff_output("***************");
if ((flags & D_PROTOTYPE)) {
@@ -1463,10 +1466,10 @@ dump_unified_vec(FILE *f1, FILE *f2, int flags)
return;
b = d = 0; /* gcc */
- lowa = MAX(1, cvp->a - diff_context);
- upb = MIN(len[0], context_vec_ptr->b + diff_context);
- lowc = MAX(1, cvp->c - diff_context);
- upd = MIN(len[1], context_vec_ptr->d + diff_context);
+ lowa = MAXIMUM(1, cvp->a - diff_context);
+ upb = MINIMUM(len[0], context_vec_ptr->b + diff_context);
+ lowc = MAXIMUM(1, cvp->c - diff_context);
+ upd = MINIMUM(len[1], context_vec_ptr->d + diff_context);
diff_output("@@ -");
uni_range(lowa, upb);
diff --git a/usr.bin/find/function.c b/usr.bin/find/function.c
index cb9542ecff8..be4e013393f 100644
--- a/usr.bin/find/function.c
+++ b/usr.bin/find/function.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: function.c,v 1.41 2014/05/18 08:10:00 espie Exp $ */
+/* $OpenBSD: function.c,v 1.42 2015/01/16 06:40:07 deraadt Exp $ */
/*-
* Copyright (c) 1990, 1993
@@ -32,8 +32,6 @@
* SUCH DAMAGE.
*/
-#include <sys/param.h>
-#include <sys/ucred.h>
#include <sys/stat.h>
#include <sys/wait.h>
#include <sys/mount.h>
@@ -575,8 +573,8 @@ c_exec(char *unused, char ***argvp, int isok)
for (p = *argv; *p; ++p)
if (p[0] == '{' && p[1] == '}') {
new->e_argv[cnt] =
- emalloc((u_int)MAXPATHLEN);
- new->e_len[cnt] = MAXPATHLEN;
+ emalloc((u_int)PATH_MAX);
+ new->e_len[cnt] = PATH_MAX;
break;
}
if (!*p) {
@@ -607,7 +605,7 @@ f_execdir(PLAN *plan, FTSENT *entry)
int cnt;
pid_t pid;
int status, fd;
- char base[MAXPATHLEN];
+ char base[PATH_MAX];
/* fts(3) does not chdir for the root level so we do it ourselves. */
if (entry->fts_level == FTS_ROOTLEVEL) {
@@ -693,8 +691,8 @@ c_execdir(char *ignored, char ***argvp, int unused)
new->e_orig[cnt] = *argv;
for (p = *argv; *p; ++p)
if (p[0] == '{' && p[1] == '}') {
- new->e_argv[cnt] = emalloc((u_int)MAXPATHLEN);
- new->e_len[cnt] = MAXPATHLEN;
+ new->e_argv[cnt] = emalloc((u_int)PATH_MAX);
+ new->e_len[cnt] = PATH_MAX;
break;
}
if (!*p) {
diff --git a/usr.bin/find/ls.c b/usr.bin/find/ls.c
index b78ae1734a7..adbc0d7e81c 100644
--- a/usr.bin/find/ls.c
+++ b/usr.bin/find/ls.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ls.c,v 1.15 2014/01/10 04:53:35 guenther Exp $ */
+/* $OpenBSD: ls.c,v 1.16 2015/01/16 06:40:07 deraadt Exp $ */
/*
* Copyright (c) 1989, 1993
@@ -29,7 +29,6 @@
* SUCH DAMAGE.
*/
-#include <sys/param.h>
#include <sys/stat.h>
#include <err.h>
@@ -39,6 +38,7 @@
#include <time.h>
#include <tzfile.h>
#include <unistd.h>
+#include <limits.h>
#include <utmp.h>
#include <pwd.h>
#include <grp.h>
@@ -106,7 +106,7 @@ static void
printlink(char *name)
{
int lnklen;
- char path[MAXPATHLEN];
+ char path[PATH_MAX];
if ((lnklen = readlink(name, path, sizeof(path) - 1)) == -1) {
warn("%s", name);
diff --git a/usr.bin/finger/finger.c b/usr.bin/finger/finger.c
index 8c683ed5bac..e2e2134e49d 100644
--- a/usr.bin/finger/finger.c
+++ b/usr.bin/finger/finger.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: finger.c,v 1.18 2009/11/12 15:33:21 nicm Exp $ */
+/* $OpenBSD: finger.c,v 1.19 2015/01/16 06:40:07 deraadt Exp $ */
/*
* Copyright (c) 1989 The Regents of the University of California.
@@ -56,7 +56,6 @@
* well as home directory, shell, mail info, and .plan/.project files.
*/
-#include <sys/param.h>
#include <sys/file.h>
#include <sys/stat.h>
#include <stdio.h>
@@ -64,6 +63,7 @@
#include <string.h>
#include <time.h>
#include <unistd.h>
+#include <limits.h>
#include <err.h>
#include "finger.h"
#include "extern.h"
@@ -80,7 +80,7 @@ main(int argc, char *argv[])
extern int optind;
extern char *__progname;
int ch;
- char domain[MAXHOSTNAMELEN];
+ char domain[HOST_NAME_MAX+1];
struct stat sb;
oflag = 1; /* default to old "office" behavior */
diff --git a/usr.bin/finger/net.c b/usr.bin/finger/net.c
index 62cac5d18fc..86c41211f25 100644
--- a/usr.bin/finger/net.c
+++ b/usr.bin/finger/net.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: net.c,v 1.12 2009/10/27 23:59:38 deraadt Exp $ */
+/* $OpenBSD: net.c,v 1.13 2015/01/16 06:40:07 deraadt Exp $ */
/*
* Copyright (c) 1989 The Regents of the University of California.
@@ -32,7 +32,6 @@
* SUCH DAMAGE.
*/
-#include <sys/param.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
diff --git a/usr.bin/finger/util.c b/usr.bin/finger/util.c
index 3b4b3654c52..6e845c1ed71 100644
--- a/usr.bin/finger/util.c
+++ b/usr.bin/finger/util.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: util.c,v 1.29 2014/11/19 22:07:13 millert Exp $ */
+/* $OpenBSD: util.c,v 1.30 2015/01/16 06:40:07 deraadt Exp $ */
/*
* Copyright (c) 1989 The Regents of the University of California.
@@ -35,7 +35,6 @@
#include <sys/types.h>
#include <sys/uio.h>
-#include <sys/param.h>
#include <sys/stat.h>
#include <err.h>
#include <stdio.h>
diff --git a/usr.bin/from/from.c b/usr.bin/from/from.c
index 17a09c15029..07abc2ce74e 100644
--- a/usr.bin/from/from.c
+++ b/usr.bin/from/from.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: from.c,v 1.16 2013/11/27 13:32:02 okan Exp $ */
+/* $OpenBSD: from.c,v 1.17 2015/01/16 06:40:07 deraadt Exp $ */
/* $NetBSD: from.c,v 1.6 1995/09/01 01:39:10 jtc Exp $ */
/*
@@ -48,8 +48,8 @@ main(int argc, char *argv[])
struct passwd *pwd;
int ch, newline;
char *file, *sender, *p;
-#if MAXPATHLEN > BUFSIZ
- char buf[MAXPATHLEN];
+#if PATH_MAX > BUFSIZ
+ char buf[PATH_MAX];
#else
char buf[BUFSIZ];
#endif
diff --git a/usr.bin/fstat/fstat.c b/usr.bin/fstat/fstat.c
index ac2c501a658..bbf26c55d7a 100644
--- a/usr.bin/fstat/fstat.c
+++ b/usr.bin/fstat/fstat.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: fstat.c,v 1.79 2014/08/20 11:23:42 mikeb Exp $ */
+/* $OpenBSD: fstat.c,v 1.80 2015/01/16 06:40:08 deraadt Exp $ */
/*
* Copyright (c) 2009 Todd C. Miller <Todd.Miller@courtesan.com>
@@ -45,7 +45,7 @@
* SUCH DAMAGE.
*/
-#include <sys/param.h>
+#include <sys/types.h>
#include <sys/queue.h>
#include <sys/mount.h>
#include <sys/stat.h>
@@ -84,6 +84,8 @@
#include "fstat.h"
+#define MAXIMUM(a, b) (((a) > (b)) ? (a) : (b))
+
struct fileargs fileargs = SLIST_HEAD_INITIALIZER(fileargs);
int fsflg; /* show files on same filesystem as file(s) argument */
@@ -480,7 +482,7 @@ pipetrans(struct kinfo_file *kf)
* same visible addr. (it's the higher address because when the other
* end closes, it becomes 0)
*/
- maxaddr = (void *)(uintptr_t)MAX(kf->f_data, kf->pipe_peer);
+ maxaddr = (void *)(uintptr_t)MAXIMUM(kf->f_data, kf->pipe_peer);
printf("pipe ");
hide(maxaddr);
diff --git a/usr.bin/fstat/fuser.c b/usr.bin/fstat/fuser.c
index 4824e33c936..96212e6ece3 100644
--- a/usr.bin/fstat/fuser.c
+++ b/usr.bin/fstat/fuser.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: fuser.c,v 1.5 2014/10/26 06:03:24 guenther Exp $ */
+/* $OpenBSD: fuser.c,v 1.6 2015/01/16 06:40:08 deraadt Exp $ */
/*
* Copyright (c) 2009 Todd C. Miller <Todd.Miller@courtesan.com>
@@ -41,7 +41,6 @@
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include <sys/param.h>
#include <sys/queue.h>
#include <sys/stat.h>
#include <sys/sysctl.h>
diff --git a/usr.bin/ftp/cmds.c b/usr.bin/ftp/cmds.c
index d918391edc5..e0dc7f24e45 100644
--- a/usr.bin/ftp/cmds.c
+++ b/usr.bin/ftp/cmds.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cmds.c,v 1.72 2014/08/16 07:49:27 deraadt Exp $ */
+/* $OpenBSD: cmds.c,v 1.73 2015/01/16 06:40:08 deraadt Exp $ */
/* $NetBSD: cmds.c,v 1.27 1997/08/18 10:20:15 lukem Exp $ */
/*
@@ -281,7 +281,7 @@ usage:
oldintr = signal(SIGINT, mabort);
(void)setjmp(jabort);
if (proxy) {
- char *cp, *tp2, tmpbuf[MAXPATHLEN];
+ char *cp, *tp2, tmpbuf[PATH_MAX];
while ((cp = remglob(argv, 0, NULL)) != NULL) {
if (*cp == '\0') {
@@ -696,7 +696,7 @@ setprompt(int argc, char *argv[])
void
setgate(int argc, char *argv[])
{
- static char gsbuf[MAXHOSTNAMELEN];
+ static char gsbuf[HOST_NAME_MAX+1];
if (argc > 3) {
fprintf(ttyout, "usage: %s [on | off | host [port]]\n",
@@ -800,7 +800,7 @@ setdebug(int argc, char *argv[])
void
lcd(int argc, char *argv[])
{
- char buf[MAXPATHLEN];
+ char buf[PATH_MAX];
char *oldargv1;
if (argc < 2)
@@ -993,7 +993,7 @@ shell(int argc, char *argv[])
{
pid_t pid;
sig_t old1, old2;
- char shellnam[MAXPATHLEN], *shellp, *namep;
+ char shellnam[PATH_MAX], *shellp, *namep;
int wait_status;
old1 = signal (SIGINT, SIG_IGN);
@@ -1120,7 +1120,7 @@ pwd(int argc, char *argv[])
void
lpwd(int argc, char *argv[])
{
- char buf[MAXPATHLEN];
+ char buf[PATH_MAX];
if (getcwd(buf, sizeof(buf)) != NULL)
fprintf(ttyout, "Local directory %s\n", buf);
@@ -1462,10 +1462,10 @@ setnmap(int argc, char *argv[])
cp = strchr(altarg, ' ');
}
*cp = '\0';
- (void)strncpy(mapin, altarg, MAXPATHLEN - 1);
+ (void)strncpy(mapin, altarg, PATH_MAX - 1);
while (*++cp == ' ')
continue;
- (void)strncpy(mapout, cp, MAXPATHLEN - 1);
+ (void)strncpy(mapout, cp, PATH_MAX - 1);
}
void
diff --git a/usr.bin/ftp/complete.c b/usr.bin/ftp/complete.c
index bd249f9f370..dd5c55f483e 100644
--- a/usr.bin/ftp/complete.c
+++ b/usr.bin/ftp/complete.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: complete.c,v 1.27 2014/04/23 11:47:04 jca Exp $ */
+/* $OpenBSD: complete.c,v 1.28 2015/01/16 06:40:08 deraadt Exp $ */
/* $NetBSD: complete.c,v 1.10 1997/08/18 10:20:18 lukem Exp $ */
/*-
@@ -71,7 +71,7 @@ comparstr(const void *a, const void *b)
static unsigned char
complete_ambiguous(char *word, int list, StringList *words)
{
- char insertstr[MAXPATHLEN * 2];
+ char insertstr[PATH_MAX * 2];
char *lastmatch;
int i, j;
size_t matchlen, wordlen;
@@ -151,7 +151,7 @@ static unsigned char
complete_local(char *word, int list)
{
StringList *words;
- char dir[MAXPATHLEN];
+ char dir[PATH_MAX];
char *file;
DIR *dd;
struct dirent *dp;
@@ -204,9 +204,9 @@ static unsigned char
complete_remote(char *word, int list)
{
static StringList *dirlist;
- static char lastdir[MAXPATHLEN];
+ static char lastdir[PATH_MAX];
StringList *words;
- char dir[MAXPATHLEN];
+ char dir[PATH_MAX];
char *file, *cp;
int i;
unsigned char rv;
diff --git a/usr.bin/ftp/fetch.c b/usr.bin/ftp/fetch.c
index 20667988442..6cb9094e2a7 100644
--- a/usr.bin/ftp/fetch.c
+++ b/usr.bin/ftp/fetch.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: fetch.c,v 1.136 2015/01/12 15:46:55 bluhm Exp $ */
+/* $OpenBSD: fetch.c,v 1.137 2015/01/16 06:40:08 deraadt Exp $ */
/* $NetBSD: fetch.c,v 1.14 1997/08/18 10:20:20 lukem Exp $ */
/*-
@@ -35,7 +35,6 @@
*/
#include <sys/types.h>
-#include <sys/param.h>
#include <sys/socket.h>
#include <sys/stat.h>
@@ -47,7 +46,6 @@
#include <ctype.h>
#include <err.h>
#include <libgen.h>
-#include <limits.h>
#include <netdb.h>
#include <fcntl.h>
#include <signal.h>
@@ -1058,7 +1056,7 @@ auto_fetch(int argc, char *argv[], char *outfile)
int rval, xargc;
volatile int argpos;
int dirhasglob, filehasglob, oautologin;
- char rempath[MAXPATHLEN];
+ char rempath[PATH_MAX];
argpos = 0;
diff --git a/usr.bin/ftp/ftp.c b/usr.bin/ftp/ftp.c
index c85627000ff..717a9164dca 100644
--- a/usr.bin/ftp/ftp.c
+++ b/usr.bin/ftp/ftp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ftp.c,v 1.88 2014/10/24 02:01:20 lteo Exp $ */
+/* $OpenBSD: ftp.c,v 1.89 2015/01/16 06:40:08 deraadt Exp $ */
/* $NetBSD: ftp.c,v 1.27 1997/08/18 10:20:23 lukem Exp $ */
/*
@@ -112,7 +112,7 @@ char *
hookup(char *host, char *port)
{
int s, tos, error;
- static char hostnamebuf[MAXHOSTNAMELEN];
+ static char hostnamebuf[HOST_NAME_MAX+1];
struct addrinfo hints, *res, *res0, *ares;
char hbuf[NI_MAXHOST];
char *cause = "unknown";
@@ -1755,7 +1755,7 @@ pswitch(int flag)
sig_t oldintr;
static struct comvars {
int connect;
- char name[MAXHOSTNAMELEN];
+ char name[HOST_NAME_MAX+1];
union sockunion mctl;
union sockunion hctl;
FILE *in;
@@ -1770,8 +1770,8 @@ pswitch(int flag)
char nti[17];
char nto[17];
int mapflg;
- char mi[MAXPATHLEN];
- char mo[MAXPATHLEN];
+ char mi[PATH_MAX];
+ char mo[PATH_MAX];
} proxstruct, tmpstruct;
struct comvars *ip, *op;
@@ -1996,7 +1996,7 @@ reset(int argc, char *argv[])
char *
gunique(const char *local)
{
- static char new[MAXPATHLEN];
+ static char new[PATH_MAX];
char *cp = strrchr(local, '/');
int d, count=0;
char ext = '1';
diff --git a/usr.bin/ftp/ftp_var.h b/usr.bin/ftp/ftp_var.h
index 7a0a279effa..3974cdeb68d 100644
--- a/usr.bin/ftp/ftp_var.h
+++ b/usr.bin/ftp/ftp_var.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: ftp_var.h,v 1.36 2014/10/31 13:48:21 jsing Exp $ */
+/* $OpenBSD: ftp_var.h,v 1.37 2015/01/16 06:40:08 deraadt Exp $ */
/* $NetBSD: ftp_var.h,v 1.18 1997/08/18 10:20:25 lukem Exp $ */
/*
@@ -65,7 +65,8 @@
* FTP global variables.
*/
-#include <sys/param.h>
+#include <sys/signal.h>
+#include <limits.h>
#include <setjmp.h>
#ifndef SMALL
@@ -84,7 +85,7 @@ int fclose(FILE *);
#include "small.h"
#define HASHBYTES 1024
-#define FTPBUFLEN MAXPATHLEN + 200
+#define FTPBUFLEN PATH_MAX + 200
#define STALLTIME 5 /* # of seconds of no xfer before "stalling" */
@@ -138,8 +139,8 @@ int passivemode; /* passive mode enabled */
int activefallback; /* fall back to active mode if passive fails */
char ntin[17]; /* input translation table */
char ntout[17]; /* output translation table */
-char mapin[MAXPATHLEN]; /* input map template */
-char mapout[MAXPATHLEN]; /* output map template */
+char mapin[PATH_MAX]; /* input map template */
+char mapout[PATH_MAX]; /* output map template */
char typename[32]; /* name of file transfer type */
int type; /* requested file transfer type */
int curtype; /* current file transfer type */
diff --git a/usr.bin/ftp/main.c b/usr.bin/ftp/main.c
index 43a0517faee..bbf5249058e 100644
--- a/usr.bin/ftp/main.c
+++ b/usr.bin/ftp/main.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: main.c,v 1.95 2014/10/31 13:48:21 jsing Exp $ */
+/* $OpenBSD: main.c,v 1.96 2015/01/16 06:40:08 deraadt Exp $ */
/* $NetBSD: main.c,v 1.24 1997/08/18 10:20:26 lukem Exp $ */
/*
@@ -67,7 +67,6 @@
#include <ctype.h>
#include <err.h>
-#include <limits.h>
#include <netdb.h>
#include <pwd.h>
#include <stdio.h>
@@ -109,7 +108,7 @@ main(volatile int argc, char *argv[])
{
int ch, top, rval;
struct passwd *pw = NULL;
- char *cp, homedir[MAXPATHLEN];
+ char *cp, homedir[PATH_MAX];
char *outfile = NULL;
const char *errstr;
int dumb_terminal = 0;
diff --git a/usr.bin/ftp/ruserpass.c b/usr.bin/ftp/ruserpass.c
index c0b31233a4b..795b3012491 100644
--- a/usr.bin/ftp/ruserpass.c
+++ b/usr.bin/ftp/ruserpass.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ruserpass.c,v 1.29 2014/05/20 01:25:23 guenther Exp $ */
+/* $OpenBSD: ruserpass.c,v 1.30 2015/01/16 06:40:08 deraadt Exp $ */
/* $NetBSD: ruserpass.c,v 1.14 1997/07/20 09:46:01 lukem Exp $ */
/*
@@ -75,8 +75,8 @@ static struct toktab {
int
ruserpass(const char *host, char **aname, char **apass, char **aacct)
{
- char *hdir, buf[MAXPATHLEN], *tmp;
- char myname[MAXHOSTNAMELEN], *mydomain;
+ char *hdir, buf[PATH_MAX], *tmp;
+ char myname[HOST_NAME_MAX+1], *mydomain;
int t, i, c, usedefault = 0;
struct stat stb;
diff --git a/usr.bin/ftp/small.c b/usr.bin/ftp/small.c
index e959a556081..8954fe93c81 100644
--- a/usr.bin/ftp/small.c
+++ b/usr.bin/ftp/small.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: small.c,v 1.2 2014/08/16 07:49:27 deraadt Exp $ */
+/* $OpenBSD: small.c,v 1.3 2015/01/16 06:40:08 deraadt Exp $ */
/* $NetBSD: cmds.c,v 1.27 1997/08/18 10:20:15 lukem Exp $ */
/*
@@ -242,7 +242,7 @@ usage:
}
globargv2 = argv[2];
if (loc && mcase) {
- char *tp = argv[1], *tp2, tmpbuf[MAXPATHLEN];
+ char *tp = argv[1], *tp2, tmpbuf[PATH_MAX];
while (*tp && !islower(*tp)) {
tp++;
@@ -329,7 +329,7 @@ mget(int argc, char *argv[])
extern int optind, optreset;
sig_t oldintr;
int ch, xargc = 2;
- char *cp, localcwd[MAXPATHLEN], *xargv[] = { argv[0], NULL, NULL };
+ char *cp, localcwd[PATH_MAX], *xargv[] = { argv[0], NULL, NULL };
static int restartit = 0;
#ifndef SMALL
extern char *optarg;
@@ -532,7 +532,7 @@ disconnect(int argc, char *argv[])
char *
dotrans(char *name)
{
- static char new[MAXPATHLEN];
+ static char new[PATH_MAX];
char *cp1, *cp2 = new;
int i, ostop, found;
@@ -560,7 +560,7 @@ dotrans(char *name)
char *
domap(char *name)
{
- static char new[MAXPATHLEN];
+ static char new[PATH_MAX];
char *cp1 = name, *cp2 = mapin;
char *tp[9], *te[9];
int i, toks[9], toknum = 0, match = 1;
diff --git a/usr.bin/ftp/util.c b/usr.bin/ftp/util.c
index 65dd8d6bce5..8c576580160 100644
--- a/usr.bin/ftp/util.c
+++ b/usr.bin/ftp/util.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: util.c,v 1.67 2014/08/16 07:49:27 deraadt Exp $ */
+/* $OpenBSD: util.c,v 1.68 2015/01/16 06:40:08 deraadt Exp $ */
/* $NetBSD: util.c,v 1.12 1997/08/18 10:20:27 lukem Exp $ */
/*-
@@ -66,6 +66,7 @@
/*
* FTP User Program -- Misc support routines
*/
+#include <sys/param.h> /* BSD */
#include <sys/ioctl.h>
#include <sys/time.h>
#include <arpa/ftp.h>
@@ -75,7 +76,6 @@
#include <errno.h>
#include <fcntl.h>
#include <libgen.h>
-#include <limits.h>
#include <glob.h>
#include <pwd.h>
#include <signal.h>
@@ -89,6 +89,9 @@
#include "ftp_var.h"
#include "pathnames.h"
+#define MINIMUM(a, b) (((a) < (b)) ? (a) : (b))
+#define MAXIMUM(a, b) (((a) > (b)) ? (a) : (b))
+
static void updateprogressmeter(int);
/*
@@ -223,8 +226,8 @@ setpeer(int argc, char *argv[])
int
ftp_login(const char *host, char *user, char *pass)
{
- char tmp[80], *acctname = NULL, host_name[MAXHOSTNAMELEN];
- char anonpass[MAXLOGNAME + 1 + MAXHOSTNAMELEN]; /* "user@hostname" */
+ char tmp[80], *acctname = NULL, host_name[HOST_NAME_MAX+1];
+ char anonpass[LOGIN_NAME_MAX + 1 + HOST_NAME_MAX+1]; /* "user@hostname" */
int n, aflag = 0, retry = 0;
struct passwd *pw;
@@ -375,8 +378,8 @@ another(int *pargc, char ***pargv, const char *prompt)
char *
remglob2(char *argv[], int doswitch, char **errbuf, FILE **ftemp, char *type)
{
- char temp[MAXPATHLEN], *bufp, *cp, *lmode;
- static char buf[MAXPATHLEN], **args;
+ char temp[PATH_MAX], *bufp, *cp, *lmode;
+ static char buf[PATH_MAX], **args;
int oldverbose, oldhash, fd;
if (!mflag) {
@@ -687,8 +690,8 @@ remotemodtime(const char *file, int noisy)
int
fileindir(const char *file, const char *dir)
{
- char parentdirbuf[MAXPATHLEN], *parentdir;
- char realdir[MAXPATHLEN];
+ char parentdirbuf[PATH_MAX], *parentdir;
+ char realdir[PATH_MAX];
size_t dirlen;
/* determine parent directory of file */
@@ -787,8 +790,8 @@ progressmeter(int flag, const char *filename)
ratio = cursize * 100 / filesize;
else
ratio = 100;
- ratio = MAX(ratio, 0);
- ratio = MIN(ratio, 100);
+ ratio = MAXIMUM(ratio, 0);
+ ratio = MINIMUM(ratio, 100);
if (!verbose && flag == -1) {
filename = basename(filename);
if (filename != NULL)
diff --git a/usr.bin/getent/getent.c b/usr.bin/getent/getent.c
index acade337ab2..f12291c6144 100644
--- a/usr.bin/getent/getent.c
+++ b/usr.bin/getent/getent.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: getent.c,v 1.8 2014/10/24 10:23:32 schwarze Exp $ */
+/* $OpenBSD: getent.c,v 1.9 2015/01/16 06:40:08 deraadt Exp $ */
/* $NetBSD: getent.c,v 1.7 2005/08/24 14:31:02 ginsbach Exp $ */
/*-
@@ -144,7 +144,7 @@ printfmtstrings(char *strings[], const char *prefix, const char *sep,
static int
ethers(int argc, char *argv[])
{
- char hostname[MAXHOSTNAMELEN], *hp;
+ char hostname[HOST_NAME_MAX+1], *hp;
int i, rv = RV_OK;
struct ether_addr ea, *eap;
diff --git a/usr.bin/gprof/hertz.c b/usr.bin/gprof/hertz.c
index 05d1acd2f62..1fec6c35f77 100644
--- a/usr.bin/gprof/hertz.c
+++ b/usr.bin/gprof/hertz.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: hertz.c,v 1.6 2006/03/25 19:06:36 espie Exp $ */
+/* $OpenBSD: hertz.c,v 1.7 2015/01/16 06:40:08 deraadt Exp $ */
/*
* Copyright (c) 2005 Artur Grabowski <art@openbsd.org>
@@ -17,7 +17,6 @@
*/
-#include <sys/param.h>
#include <sys/time.h>
#include <sys/sysctl.h>
diff --git a/usr.bin/grep/file.c b/usr.bin/grep/file.c
index c590dcd4b6c..1bef79733dc 100644
--- a/usr.bin/grep/file.c
+++ b/usr.bin/grep/file.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: file.c,v 1.11 2010/07/02 20:48:48 nicm Exp $ */
+/* $OpenBSD: file.c,v 1.12 2015/01/16 06:40:08 deraadt Exp $ */
/*-
* Copyright (c) 1999 James Howard and Dag-Erling Coïdan Smørgrav
@@ -26,16 +26,15 @@
* SUCH DAMAGE.
*/
-#include <sys/param.h>
-
#include <err.h>
#include <stdio.h>
#include <stdlib.h>
+#include <limits.h>
#include <zlib.h>
#include "grep.h"
-static char fname[MAXPATHLEN];
+static char fname[PATH_MAX];
#ifndef NOZ
static char *lnbuf;
static size_t lnbuflen;
diff --git a/usr.bin/grep/mmfile.c b/usr.bin/grep/mmfile.c
index 4a985b1d5bc..d8ef73bfa31 100644
--- a/usr.bin/grep/mmfile.c
+++ b/usr.bin/grep/mmfile.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mmfile.c,v 1.15 2014/11/08 22:13:47 brad Exp $ */
+/* $OpenBSD: mmfile.c,v 1.16 2015/01/16 06:40:08 deraadt Exp $ */
/*-
* Copyright (c) 1999 James Howard and Dag-Erling Coïdan Smørgrav
@@ -26,7 +26,6 @@
* SUCH DAMAGE.
*/
-#include <sys/param.h>
#include <sys/mman.h>
#include <sys/stat.h>
diff --git a/usr.bin/grep/queue.c b/usr.bin/grep/queue.c
index 96de3b2736a..96e50abe8b4 100644
--- a/usr.bin/grep/queue.c
+++ b/usr.bin/grep/queue.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: queue.c,v 1.6 2011/07/08 01:20:24 tedu Exp $ */
+/* $OpenBSD: queue.c,v 1.7 2015/01/16 06:40:08 deraadt Exp $ */
/*-
* Copyright (c) 1999 James Howard and Dag-Erling Coïdan Smørgrav
@@ -31,8 +31,6 @@
* Dodge.
*/
-#include <sys/param.h>
-
#include <stdlib.h>
#include <string.h>
diff --git a/usr.bin/hexdump/display.c b/usr.bin/hexdump/display.c
index ce861b35a0f..db9506765c1 100644
--- a/usr.bin/hexdump/display.c
+++ b/usr.bin/hexdump/display.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: display.c,v 1.20 2010/10/22 14:04:24 millert Exp $ */
+/* $OpenBSD: display.c,v 1.21 2015/01/16 06:40:08 deraadt Exp $ */
/* $NetBSD: display.c,v 1.12 2001/12/07 15:14:29 bjh21 Exp $ */
/*
@@ -30,7 +30,6 @@
* SUCH DAMAGE.
*/
-#include <sys/param.h>
#include <sys/stat.h>
#include <ctype.h>
@@ -43,6 +42,8 @@
#include "hexdump.h"
+#define MINIMUM(a, b) (((a) < (b)) ? (a) : (b))
+
enum _vflag vflag = FIRST;
static off_t address; /* address/offset in stream */
@@ -253,7 +254,7 @@ get(void)
return(curp);
}
n = fread((char *)curp + nread, sizeof(u_char),
- length == -1 ? need : MIN(length, need), stdin);
+ length == -1 ? need : MINIMUM(length, need), stdin);
if (!n) {
if (ferror(stdin))
warn("%s", _argv[-1]);
diff --git a/usr.bin/hexdump/hexdump.c b/usr.bin/hexdump/hexdump.c
index 17dd5975f9c..a84a8c315bd 100644
--- a/usr.bin/hexdump/hexdump.c
+++ b/usr.bin/hexdump/hexdump.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: hexdump.c,v 1.16 2011/09/22 09:09:42 stsp Exp $ */
+/* $OpenBSD: hexdump.c,v 1.17 2015/01/16 06:40:08 deraadt Exp $ */
/* $NetBSD: hexdump.c,v 1.7 1997/10/19 02:34:06 lukem Exp $ */
/*
@@ -30,13 +30,14 @@
* SUCH DAMAGE.
*/
-#include <sys/param.h>
#include <err.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "hexdump.h"
+#define MINIMUM(a, b) (((a) < (b)) ? (a) : (b))
+
FS *fshead; /* head of format strings */
int blocksize; /* data block size */
int exitval; /* final exit value */
@@ -64,7 +65,7 @@ main(int argc, char *argv[])
blocksize = tfs->bcnt;
}
if (length != -1) {
- iobufsiz = MIN(length, blocksize);
+ iobufsiz = MINIMUM(length, blocksize);
if ((iobuf = malloc(iobufsiz)) == NULL)
err(1, NULL);
}
diff --git a/usr.bin/id/id.c b/usr.bin/id/id.c
index 34538f5b2d5..45461b3457a 100644
--- a/usr.bin/id/id.c
+++ b/usr.bin/id/id.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: id.c,v 1.21 2014/07/14 05:41:00 guenther Exp $ */
+/* $OpenBSD: id.c,v 1.22 2015/01/16 06:40:08 deraadt Exp $ */
/*-
* Copyright (c) 1991, 1993
@@ -29,8 +29,6 @@
* SUCH DAMAGE.
*/
-#include <sys/param.h>
-
#include <err.h>
#include <errno.h>
#include <grp.h>
@@ -39,6 +37,7 @@
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
+#include <limits.h>
void current(void);
void pretty(struct passwd *);
@@ -200,7 +199,7 @@ current(void)
struct passwd *pw;
int cnt, ngroups;
uid_t uid, euid;
- gid_t groups[NGROUPS], gid, egid, lastgid;
+ gid_t groups[NGROUPS_MAX], gid, egid, lastgid;
char *prefix;
uid = getuid();
@@ -221,7 +220,7 @@ current(void)
if ((gr = getgrgid(egid)))
(void)printf("(%s)", gr->gr_name);
}
- if ((ngroups = getgroups(NGROUPS, groups))) {
+ if ((ngroups = getgroups(NGROUPS_MAX, groups))) {
for (prefix = " groups=", lastgid = (gid_t)-1, cnt = 0;
cnt < ngroups; prefix = ", ", lastgid = gid) {
gid = groups[cnt++];
@@ -238,7 +237,7 @@ current(void)
void
user(struct passwd *pw)
{
- gid_t gid, groups[NGROUPS + 1];
+ gid_t gid, groups[NGROUPS_MAX + 1];
int cnt, ngroups;
uid_t uid;
struct group *gr;
@@ -249,7 +248,7 @@ user(struct passwd *pw)
(void)printf(" gid=%u", pw->pw_gid);
if ((gr = getgrgid(pw->pw_gid)))
(void)printf("(%s)", gr->gr_name);
- ngroups = NGROUPS + 1;
+ ngroups = NGROUPS_MAX + 1;
(void) getgrouplist(pw->pw_name, pw->pw_gid, groups, &ngroups);
prefix = " groups=";
for (cnt = 0; cnt < ngroups;) {
@@ -268,16 +267,16 @@ void
group(struct passwd *pw, int nflag)
{
int cnt, ngroups;
- gid_t gid, groups[NGROUPS + 1];
+ gid_t gid, groups[NGROUPS_MAX + 1];
struct group *gr;
char *prefix;
if (pw) {
- ngroups = NGROUPS + 1;
+ ngroups = NGROUPS_MAX + 1;
(void) getgrouplist(pw->pw_name, pw->pw_gid, groups, &ngroups);
} else {
groups[0] = getgid();
- ngroups = getgroups(NGROUPS, groups + 1) + 1;
+ ngroups = getgroups(NGROUPS_MAX, groups + 1) + 1;
}
prefix = "";
for (cnt = 0; cnt < ngroups;) {
diff --git a/usr.bin/indent/indent.c b/usr.bin/indent/indent.c
index 1bff676952b..ad33d215568 100644
--- a/usr.bin/indent/indent.c
+++ b/usr.bin/indent/indent.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: indent.c,v 1.25 2014/07/20 01:38:40 guenther Exp $ */
+/* $OpenBSD: indent.c,v 1.26 2015/01/16 06:40:08 deraadt Exp $ */
/*
* Copyright (c) 1980, 1993
@@ -32,9 +32,9 @@
* SUCH DAMAGE.
*/
-#include <sys/param.h>
#include <fcntl.h>
#include <unistd.h>
+#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -48,7 +48,7 @@ char *in_name = "Standard Input"; /* will always point to name of input
* file */
char *out_name = "Standard Output"; /* will always point to name
* of output file */
-char bakfile[MAXPATHLEN] = "";
+char bakfile[PATH_MAX] = "";
void bakcopy(void);
@@ -1178,7 +1178,7 @@ bakcopy(void)
p--;
if (*p == '/')
p++;
- if (snprintf(bakfile, MAXPATHLEN, "%s.BAK", p) >= MAXPATHLEN)
+ if (snprintf(bakfile, PATH_MAX, "%s.BAK", p) >= PATH_MAX)
errc(1, ENAMETOOLONG, "%s.BAK", p);
/* copy in_name to backup file */
diff --git a/usr.bin/ipcs/ipcs.c b/usr.bin/ipcs/ipcs.c
index 4c3dbb28f86..146aa1c10cc 100644
--- a/usr.bin/ipcs/ipcs.c
+++ b/usr.bin/ipcs/ipcs.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ipcs.c,v 1.25 2012/02/05 18:27:03 guenther Exp $ */
+/* $OpenBSD: ipcs.c,v 1.26 2015/01/16 06:40:08 deraadt Exp $ */
/* $NetBSD: ipcs.c,v 1.25 2000/06/16 03:58:20 simonb Exp $ */
/*-
@@ -55,7 +55,7 @@
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include <sys/param.h>
+#include <sys/types.h>
#include <sys/sysctl.h>
#define _KERNEL /* XXX */
#include <sys/ipc.h>
diff --git a/usr.bin/join/join.c b/usr.bin/join/join.c
index 8fd1cd57796..b7922cd8030 100644
--- a/usr.bin/join/join.c
+++ b/usr.bin/join/join.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: join.c,v 1.23 2014/10/11 04:31:55 doug Exp $ */
+/* $OpenBSD: join.c,v 1.24 2015/01/16 06:40:08 deraadt Exp $ */
/*-
* Copyright (c) 1991, 1993, 1994
@@ -33,14 +33,14 @@
* SUCH DAMAGE.
*/
-#include <sys/param.h>
-
#include <err.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
+#define MAXIMUM(a, b) (((a) > (b)) ? (a) : (b))
+
/*
* There's a structure per input file which encapsulates the state of the
* file. We repeatedly read lines from each file until we've read in all
@@ -347,7 +347,7 @@ slurpit(INPUT *F)
if (lp->linealloc <= len + 1) {
char *p;
u_long newsize = lp->linealloc +
- MAX(100, len + 1 - lp->linealloc);
+ MAXIMUM(100, len + 1 - lp->linealloc);
if ((p = realloc(lp->line, newsize)) == NULL)
err(1, NULL);
lp->line = p;
diff --git a/usr.bin/kdump/kdump.c b/usr.bin/kdump/kdump.c
index 515c1f6ee68..4b33a924b73 100644
--- a/usr.bin/kdump/kdump.c
+++ b/usr.bin/kdump/kdump.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kdump.c,v 1.96 2014/12/28 11:11:01 bluhm Exp $ */
+/* $OpenBSD: kdump.c,v 1.97 2015/01/16 06:40:09 deraadt Exp $ */
/*-
* Copyright (c) 1988, 1993
@@ -29,8 +29,9 @@
* SUCH DAMAGE.
*/
-#include <sys/param.h>
+#include <sys/param.h> /* MAXCOMLEN nitems */
#include <sys/time.h>
+#include <sys/signal.h>
#include <sys/uio.h>
#include <sys/ktrace.h>
#include <sys/ioctl.h>
diff --git a/usr.bin/ktrace/ktrace.c b/usr.bin/ktrace/ktrace.c
index d73a0b0bebe..178180822eb 100644
--- a/usr.bin/ktrace/ktrace.c
+++ b/usr.bin/ktrace/ktrace.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ktrace.c,v 1.30 2014/05/24 17:04:16 deraadt Exp $ */
+/* $OpenBSD: ktrace.c,v 1.31 2015/01/16 06:40:09 deraadt Exp $ */
/* $NetBSD: ktrace.c,v 1.4 1995/08/31 23:01:44 jtc Exp $ */
/*-
@@ -30,7 +30,8 @@
* SUCH DAMAGE.
*/
-#include <sys/param.h>
+#include <sys/param.h> /* MAXCOMLEN */
+#include <sys/signal.h>
#include <sys/stat.h>
#include <sys/time.h>
#include <sys/uio.h>
diff --git a/usr.bin/ktrace/subr.c b/usr.bin/ktrace/subr.c
index 251a5db5096..96bded2611a 100644
--- a/usr.bin/ktrace/subr.c
+++ b/usr.bin/ktrace/subr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: subr.c,v 1.8 2013/06/01 09:51:28 miod Exp $ */
+/* $OpenBSD: subr.c,v 1.9 2015/01/16 06:40:09 deraadt Exp $ */
/* $NetBSD: subr.c,v 1.6 1995/08/31 23:01:45 jtc Exp $ */
/*-
@@ -30,7 +30,7 @@
* SUCH DAMAGE.
*/
-#include <sys/param.h>
+#include <sys/param.h> /* MAXCOMLEN */
#include <sys/file.h>
#include <sys/user.h>
#include <sys/proc.h>
diff --git a/usr.bin/lam/lam.c b/usr.bin/lam/lam.c
index 87877952fc2..bade6206216 100644
--- a/usr.bin/lam/lam.c
+++ b/usr.bin/lam/lam.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: lam.c,v 1.16 2013/11/20 21:22:17 deraadt Exp $ */
+/* $OpenBSD: lam.c,v 1.17 2015/01/16 06:40:09 deraadt Exp $ */
/* $NetBSD: lam.c,v 1.2 1994/11/14 20:27:42 jtc Exp $ */
/*-
@@ -35,7 +35,7 @@
* Author: John Kunze, UCB
*/
-#include <sys/param.h>
+#include <sys/param.h> /* NOFILE_MAX */
#include <ctype.h>
#include <err.h>
diff --git a/usr.bin/last/last.c b/usr.bin/last/last.c
index 44519264103..954ffbd6cfc 100644
--- a/usr.bin/last/last.c
+++ b/usr.bin/last/last.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: last.c,v 1.44 2014/12/09 15:40:23 tedu Exp $ */
+/* $OpenBSD: last.c,v 1.45 2015/01/16 06:40:09 deraadt Exp $ */
/* $NetBSD: last.c,v 1.6 1994/12/24 16:49:02 cgd Exp $ */
/*
@@ -30,7 +30,6 @@
* SUCH DAMAGE.
*/
-#include <sys/param.h>
#include <sys/stat.h>
#include <ctype.h>
@@ -45,6 +44,7 @@
#include <time.h>
#include <tzfile.h>
#include <unistd.h>
+#include <limits.h>
#include <utmp.h>
#define NO 0 /* false/no */
@@ -494,7 +494,7 @@ addtty(char *ttyname)
void
hostconv(char *arg)
{
- static char *hostdot, name[MAXHOSTNAMELEN];
+ static char *hostdot, name[HOST_NAME_MAX+1];
static int first = 1;
char *argdot;
diff --git a/usr.bin/lastcomm/lastcomm.c b/usr.bin/lastcomm/lastcomm.c
index 614613c4f12..9aa1dd6ece7 100644
--- a/usr.bin/lastcomm/lastcomm.c
+++ b/usr.bin/lastcomm/lastcomm.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: lastcomm.c,v 1.19 2013/11/27 13:32:02 okan Exp $ */
+/* $OpenBSD: lastcomm.c,v 1.20 2015/01/16 06:40:09 deraadt Exp $ */
/* $NetBSD: lastcomm.c,v 1.9 1995/10/22 01:43:42 ghudson Exp $ */
/*
@@ -30,7 +30,7 @@
* SUCH DAMAGE.
*/
-#include <sys/param.h>
+#include <sys/param.h> /* NODEV */
#include <sys/stat.h>
#include <sys/acct.h>
diff --git a/usr.bin/leave/leave.c b/usr.bin/leave/leave.c
index 9bbf6db9a1d..4a317ce3fa3 100644
--- a/usr.bin/leave/leave.c
+++ b/usr.bin/leave/leave.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: leave.c,v 1.14 2014/11/26 18:34:51 millert Exp $ */
+/* $OpenBSD: leave.c,v 1.15 2015/01/16 06:40:09 deraadt Exp $ */
/* $NetBSD: leave.c,v 1.4 1995/07/03 16:50:13 phil Exp $ */
/*
@@ -30,7 +30,6 @@
* SUCH DAMAGE.
*/
-#include <sys/param.h>
#include <sys/time.h>
#include <ctype.h>
#include <err.h>
diff --git a/usr.bin/lndir/lndir.c b/usr.bin/lndir/lndir.c
index a6f30449824..75bcc457745 100644
--- a/usr.bin/lndir/lndir.c
+++ b/usr.bin/lndir/lndir.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: lndir.c,v 1.20 2014/05/20 01:25:23 guenther Exp $ */
+/* $OpenBSD: lndir.c,v 1.21 2015/01/16 06:40:09 deraadt Exp $ */
/* $XConsortium: lndir.c /main/15 1995/08/30 10:56:18 gildea $ */
/*
@@ -47,7 +47,6 @@ in this Software without prior written authorization from the X Consortium.
% lndir ../X
*/
-#include <sys/param.h>
#include <sys/stat.h>
#include <dirent.h>
@@ -58,6 +57,7 @@ in this Software without prior written authorization from the X Consortium.
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
+#include <limits.h>
extern char *__progname;
@@ -179,8 +179,8 @@ addexcept(char *name)
int
dodir(char *fn, struct stat *fs, struct stat *ts, int rel)
{
- char buf[MAXPATHLEN + 1], symbuf[MAXPATHLEN + 1];
- char basesym[MAXPATHLEN + 1];
+ char buf[PATH_MAX + 1], symbuf[PATH_MAX + 1];
+ char basesym[PATH_MAX + 1];
int n_dirs, symlen, basesymlen = -1;
struct stat sb, sc;
struct except *cur;
diff --git a/usr.bin/locate/bigram/locate.bigram.c b/usr.bin/locate/bigram/locate.bigram.c
index 48d5db2836c..8e944e1c087 100644
--- a/usr.bin/locate/bigram/locate.bigram.c
+++ b/usr.bin/locate/bigram/locate.bigram.c
@@ -1,5 +1,5 @@
/*
- * $OpenBSD: locate.bigram.c,v 1.12 2009/10/27 23:59:39 deraadt Exp $
+ * $OpenBSD: locate.bigram.c,v 1.13 2015/01/16 06:40:09 deraadt Exp $
*
* Copyright (c) 1995 Wolfram Schneider <wosch@FreeBSD.org>. Berlin.
* Copyright (c) 1989, 1993
@@ -32,7 +32,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: locate.bigram.c,v 1.12 2009/10/27 23:59:39 deraadt Exp $
+ * $Id: locate.bigram.c,v 1.13 2015/01/16 06:40:09 deraadt Exp $
*/
/*
@@ -45,11 +45,11 @@
#include <stdio.h>
#include <stdlib.h>
-#include <sys/param.h> /* for MAXPATHLEN */
+#include <limits.h>
#include "locate.h"
-u_char buf1[MAXPATHLEN] = " ";
-u_char buf2[MAXPATHLEN];
+u_char buf1[PATH_MAX] = " ";
+u_char buf2[PATH_MAX];
u_int bigram[UCHAR_MAX + 1][UCHAR_MAX + 1];
int
diff --git a/usr.bin/locate/code/locate.code.c b/usr.bin/locate/code/locate.code.c
index 50c42c67cae..cf2167016d4 100644
--- a/usr.bin/locate/code/locate.code.c
+++ b/usr.bin/locate/code/locate.code.c
@@ -1,5 +1,5 @@
/*
- * $OpenBSD: locate.code.c,v 1.17 2013/11/17 20:19:36 okan Exp $
+ * $OpenBSD: locate.code.c,v 1.18 2015/01/16 06:40:09 deraadt Exp $
*
* Copyright (c) 1989, 1993
* The Regents of the University of California. All rights reserved.
@@ -31,7 +31,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: locate.code.c,v 1.17 2013/11/17 20:19:36 okan Exp $
+ * $Id: locate.code.c,v 1.18 2015/01/16 06:40:09 deraadt Exp $
*/
/*
@@ -78,21 +78,20 @@
* Wolfram Schneider, Berlin September 1996
*/
-#include <sys/param.h>
-
#include <err.h>
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
+#include <limits.h>
#include "locate.h"
#define BGBUFSIZE (NBG * 2) /* size of bigram buffer */
-u_char buf1[MAXPATHLEN] = " ";
-u_char buf2[MAXPATHLEN];
+u_char buf1[PATH_MAX] = " ";
+u_char buf2[PATH_MAX];
u_char bigrams[BGBUFSIZE + 1] = { 0 };
#define LOOKUP 1 /* use a lookup array instead a function, 3x faster */
diff --git a/usr.bin/locate/locate/fastfind.c b/usr.bin/locate/locate/fastfind.c
index a366f4cd572..53253029fa8 100644
--- a/usr.bin/locate/locate/fastfind.c
+++ b/usr.bin/locate/locate/fastfind.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: fastfind.c,v 1.11 2010/10/25 19:16:45 millert Exp $ */
+/* $OpenBSD: fastfind.c,v 1.12 2015/01/16 06:40:09 deraadt Exp $ */
/*
* Copyright (c) 1995 Wolfram Schneider <wosch@FreeBSD.org>. Berlin.
@@ -32,7 +32,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: fastfind.c,v 1.11 2010/10/25 19:16:45 millert Exp $
+ * $Id: fastfind.c,v 1.12 2015/01/16 06:40:09 deraadt Exp $
*/
#ifndef _LOCATE_STATISTIC_
@@ -47,7 +47,7 @@ statistic (fp, path_fcodes)
u_char *p, *s;
int c;
int count, umlaut;
- u_char bigram1[NBG], bigram2[NBG], path[MAXPATHLEN];
+ u_char bigram1[NBG], bigram2[NBG], path[PATH_MAX];
for (c = 0, p = bigram1, s = bigram2; c < NBG; c++) {
p[c] = check_bigram_char(getc(fp));
@@ -140,7 +140,7 @@ fastfind
int c, cc;
int count, found, globflag;
u_char *cutoff;
- u_char bigram1[NBG], bigram2[NBG], path[MAXPATHLEN];
+ u_char bigram1[NBG], bigram2[NBG], path[PATH_MAX];
#ifdef FF_ICASE
/* use a lookup table for case insensitive search */
diff --git a/usr.bin/locate/locate/locate.c b/usr.bin/locate/locate/locate.c
index 20e83809a84..7acad40a365 100644
--- a/usr.bin/locate/locate/locate.c
+++ b/usr.bin/locate/locate/locate.c
@@ -1,5 +1,5 @@
/*
- * $OpenBSD: locate.c,v 1.25 2012/04/13 15:13:07 ajacoutot Exp $
+ * $OpenBSD: locate.c,v 1.26 2015/01/16 06:40:09 deraadt Exp $
*
* Copyright (c) 1995 Wolfram Schneider <wosch@FreeBSD.org>. Berlin.
* Copyright (c) 1989, 1993
@@ -32,7 +32,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: locate.c,v 1.25 2012/04/13 15:13:07 ajacoutot Exp $
+ * $Id: locate.c,v 1.26 2015/01/16 06:40:09 deraadt Exp $
*/
/*
@@ -63,7 +63,6 @@
* in the standard 'find'.
*/
-#include <sys/param.h>
#include <ctype.h>
#include <err.h>
#include <fnmatch.h>
@@ -73,6 +72,7 @@
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
+#include <limits.h>
#ifdef MMAP
# include <sys/types.h>
@@ -334,7 +334,7 @@ usage(void)
void
sane_count(int count)
{
- if (count < 0 || count >= MAXPATHLEN) {
+ if (count < 0 || count >= PATH_MAX) {
fprintf(stderr, "locate: corrupted database\n");
exit(1);
}
diff --git a/usr.bin/locate/locate/util.c b/usr.bin/locate/locate/util.c
index b10b7ff24f1..2c709e01e4e 100644
--- a/usr.bin/locate/locate/util.c
+++ b/usr.bin/locate/locate/util.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: util.c,v 1.12 2014/11/16 00:04:53 tedu Exp $
+/* $OpenBSD: util.c,v 1.13 2015/01/16 06:40:09 deraadt Exp $
*
* Copyright (c) 1995 Wolfram Schneider <wosch@FreeBSD.org>. Berlin.
* Copyright (c) 1989, 1993
@@ -31,15 +31,15 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: util.c,v 1.12 2014/11/16 00:04:53 tedu Exp $
+ * $Id: util.c,v 1.13 2015/01/16 06:40:09 deraadt Exp $
*/
#include <stdlib.h>
#include <string.h>
#include <err.h>
-#include <sys/param.h>
#include <stdio.h>
+#include <limits.h>
#include "locate.h"
@@ -242,12 +242,12 @@ getwm(p)
i = u.i;
- if (i > MAXPATHLEN || i < -(MAXPATHLEN)) {
+ if (i > PATH_MAX || i < -(PATH_MAX)) {
i = ntohl(i);
- if (i > MAXPATHLEN || i < -(MAXPATHLEN)) {
+ if (i > PATH_MAX || i < -(PATH_MAX)) {
(void)fprintf(stderr,
- "integer out of +-MAXPATHLEN (%d): %d\n",
- MAXPATHLEN, i);
+ "integer out of +-PATH_MAX (%d): %d\n",
+ PATH_MAX, i);
exit(1);
}
}
@@ -270,12 +270,12 @@ getwf(fp)
word = getw(fp);
- if (word > MAXPATHLEN || word < -(MAXPATHLEN)) {
+ if (word > PATH_MAX || word < -(PATH_MAX)) {
word = ntohl(word);
- if (word > MAXPATHLEN || word < -(MAXPATHLEN)) {
+ if (word > PATH_MAX || word < -(PATH_MAX)) {
(void)fprintf(stderr,
- "integer out of +-MAXPATHLEN (%d): %d\n",
- MAXPATHLEN, word);
+ "integer out of +-PATH_MAX (%d): %d\n",
+ PATH_MAX, word);
exit(1);
}
}
diff --git a/usr.bin/lock/lock.c b/usr.bin/lock/lock.c
index 12d89e9a756..12276498879 100644
--- a/usr.bin/lock/lock.c
+++ b/usr.bin/lock/lock.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: lock.c,v 1.27 2013/08/22 04:43:40 guenther Exp $ */
+/* $OpenBSD: lock.c,v 1.28 2015/01/16 06:40:09 deraadt Exp $ */
/* $NetBSD: lock.c,v 1.8 1996/05/07 18:32:31 jtc Exp $ */
/*
@@ -41,7 +41,6 @@
* an argument of the form -time where time is in minutes
*/
-#include <sys/param.h>
#include <sys/stat.h>
#include <sys/time.h>
#include <signal.h>
@@ -55,6 +54,7 @@
#include <string.h>
#include <termios.h>
#include <unistd.h>
+#include <limits.h>
#include <login_cap.h>
#include <bsd_auth.h>
@@ -75,7 +75,7 @@ extern char *__progname;
int
main(int argc, char *argv[])
{
- char hostname[MAXHOSTNAMELEN], s[BUFSIZ], s1[BUFSIZ], date[256];
+ char hostname[HOST_NAME_MAX+1], s[BUFSIZ], s1[BUFSIZ], date[256];
char *p, *style, *nstyle, *ttynam;
struct itimerval ntimer, otimer;
int ch, sectimeout, usemine, cnt, tries = 10, backoff = 3;
diff --git a/usr.bin/login/failedlogin.c b/usr.bin/login/failedlogin.c
index 970c9490996..ae6a92bfe2c 100644
--- a/usr.bin/login/failedlogin.c
+++ b/usr.bin/login/failedlogin.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: failedlogin.c,v 1.16 2013/06/01 21:06:39 deraadt Exp $ */
+/* $OpenBSD: failedlogin.c,v 1.17 2015/01/16 06:40:09 deraadt Exp $ */
/*
* Copyright (c) 1996 Todd C. Miller <Todd.Miller@courtesan.com>
@@ -23,7 +23,6 @@
* the last failed login was.
*/
-#include <sys/param.h>
#include <sys/stat.h>
#include <sys/time.h>
diff --git a/usr.bin/login/login.c b/usr.bin/login/login.c
index b0dd066b8e3..8816252d385 100644
--- a/usr.bin/login/login.c
+++ b/usr.bin/login/login.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: login.c,v 1.62 2014/05/20 01:25:23 guenther Exp $ */
+/* $OpenBSD: login.c,v 1.63 2015/01/16 06:40:09 deraadt Exp $ */
/* $NetBSD: login.c,v 1.13 1996/05/15 23:50:16 jtc Exp $ */
/*-
@@ -70,7 +70,6 @@
* login -p (preserve existing environment; for getty)
*/
-#include <sys/param.h>
#include <sys/socket.h>
#include <sys/stat.h>
#include <sys/time.h>
@@ -93,6 +92,7 @@
#include <ttyent.h>
#include <tzfile.h>
#include <unistd.h>
+#include <limits.h>
#include <utmp.h>
#include <util.h>
#include <bsd_auth.h>
@@ -138,8 +138,8 @@ main(int argc, char *argv[])
{
char *domain, *p, *ttyn, *shell, *fullname, *instance;
char *lipaddr, *script, *ripaddr, *style, *type, *fqdn;
- char tbuf[MAXPATHLEN + 2], tname[sizeof(_PATH_TTY) + 10];
- char localhost[MAXHOSTNAMELEN], *copyright;
+ char tbuf[PATH_MAX + 2], tname[sizeof(_PATH_TTY) + 10];
+ char localhost[HOST_NAME_MAX+1], *copyright;
char mail[sizeof(_PATH_MAILDIR) + 1 + NAME_MAX];
int ask, ch, cnt, fflag, pflag, quietlog, rootlogin, lastchance;
int error, homeless, needto, authok, tries, backoff;
@@ -565,7 +565,7 @@ failed:
shell = login_getcapstr(lc, "shell", pwd->pw_shell, pwd->pw_shell);
if (*shell == '\0')
shell = _PATH_BSHELL;
- else if (strlen(shell) >= MAXPATHLEN) {
+ else if (strlen(shell) >= PATH_MAX) {
syslog(LOG_ERR, "shell path too long: %s", shell);
warnx("invalid shell");
quickexit(1);
diff --git a/usr.bin/m4/gnum4.c b/usr.bin/m4/gnum4.c
index 612c21c9617..4837cf8b14b 100644
--- a/usr.bin/m4/gnum4.c
+++ b/usr.bin/m4/gnum4.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: gnum4.c,v 1.46 2014/07/10 14:12:31 espie Exp $ */
+/* $OpenBSD: gnum4.c,v 1.47 2015/01/16 06:40:09 deraadt Exp $ */
/*
* Copyright (c) 1999 Marc Espie
@@ -29,7 +29,6 @@
* functions needed to support gnu-m4 extensions, including a fake freezing
*/
-#include <sys/param.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <ctype.h>
@@ -42,6 +41,7 @@
#include <string.h>
#include <errno.h>
#include <unistd.h>
+#include <limits.h>
#include "mdef.h"
#include "stdd.h"
#include "extern.h"
@@ -124,7 +124,7 @@ static
struct input_file *
dopath(struct input_file *i, const char *filename)
{
- char path[MAXPATHLEN];
+ char path[PATH_MAX];
struct path_entry *pe;
FILE *f;
diff --git a/usr.bin/mail/aux.c b/usr.bin/mail/aux.c
index 3c6e961f59f..31a6d9b7643 100644
--- a/usr.bin/mail/aux.c
+++ b/usr.bin/mail/aux.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: aux.c,v 1.26 2014/01/17 18:42:30 okan Exp $ */
+/* $OpenBSD: aux.c,v 1.27 2015/01/16 06:40:09 deraadt Exp $ */
/* $NetBSD: aux.c,v 1.5 1997/05/13 06:15:52 mikel Exp $ */
/*
@@ -260,7 +260,7 @@ struct sstack {
FILE *s_file; /* File we were in. */
int s_cond; /* Saved state of conditionals */
int s_loading; /* Loading .mailrc, etc. */
-} sstack[NOFILE];
+} sstack[OPEN_MAX];
/*
* Pushdown current input file and switch to a new one.
@@ -280,7 +280,7 @@ source(void *v)
warn("%s", cp);
return(1);
}
- if (ssp >= NOFILE - 1) {
+ if (ssp >= OPEN_MAX - 1) {
puts("Too much \"sourcing\" going on.");
(void)Fclose(fi);
return(1);
diff --git a/usr.bin/mail/def.h b/usr.bin/mail/def.h
index 322be15ad85..17bdaf54eb5 100644
--- a/usr.bin/mail/def.h
+++ b/usr.bin/mail/def.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: def.h,v 1.13 2003/06/25 15:13:32 millert Exp $ */
+/* $OpenBSD: def.h,v 1.14 2015/01/16 06:40:09 deraadt Exp $ */
/* $NetBSD: def.h,v 1.9 1996/12/28 07:11:00 tls Exp $ */
/*
@@ -30,7 +30,7 @@
* SUCH DAMAGE.
*
* @(#)def.h 8.4 (Berkeley) 4/20/95
- * $OpenBSD: def.h,v 1.13 2003/06/25 15:13:32 millert Exp $
+ * $OpenBSD: def.h,v 1.14 2015/01/16 06:40:09 deraadt Exp $
*/
/*
@@ -42,7 +42,6 @@
#ifndef MAIL_DEF_H
#define MAIL_DEF_H
-#include <sys/param.h>
#include <sys/stat.h>
#include <sys/time.h>
@@ -54,6 +53,7 @@
#include <string.h>
#include <termios.h>
#include <unistd.h>
+#include <limits.h>
#include <vis.h>
#include "pathnames.h"
@@ -61,7 +61,7 @@
#define ESCAPE '~' /* Default escape for sending */
#define NMLSIZE 1024 /* max names in a message list */
-#define PATHSIZE MAXPATHLEN /* Size of pathnames throughout */
+#define PATHSIZE PATH_MAX /* Size of pathnames throughout */
#define HSHSIZE 59 /* Hash size for aliases and vars */
#define LINESIZE BUFSIZ /* max readable line width */
#define STRINGSIZE ((unsigned) 128)/* Dynamic allocation units */
diff --git a/usr.bin/mail/main.c b/usr.bin/mail/main.c
index d7faa687972..2dfde98ef28 100644
--- a/usr.bin/mail/main.c
+++ b/usr.bin/mail/main.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: main.c,v 1.26 2014/12/16 18:37:17 millert Exp $ */
+/* $OpenBSD: main.c,v 1.27 2015/01/16 06:40:09 deraadt Exp $ */
/* $NetBSD: main.c,v 1.7 1997/05/13 06:15:57 mikel Exp $ */
/*
@@ -84,7 +84,7 @@ main(int argc, char **argv)
/*
* Next argument is person to pretend to be.
*/
- if (strlen(optarg) >= MAXLOGNAME)
+ if (strlen(optarg) >= LOGIN_NAME_MAX)
errx(1, "username `%s' too long", optarg);
unsetenv("MAIL");
myname = optarg;
diff --git a/usr.bin/mail/popen.c b/usr.bin/mail/popen.c
index 5a1cd561ef1..2ce59fe2e8d 100644
--- a/usr.bin/mail/popen.c
+++ b/usr.bin/mail/popen.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: popen.c,v 1.36 2013/04/29 00:28:23 okan Exp $ */
+/* $OpenBSD: popen.c,v 1.37 2015/01/16 06:40:09 deraadt Exp $ */
/* $NetBSD: popen.c,v 1.6 1997/05/13 06:48:42 mikel Exp $ */
/*
@@ -434,7 +434,7 @@ handle_spool_locks(int action)
lockfp = NULL;
} else if (action == 1) {
char *cmd;
- char buf[sizeof(_PATH_LOCKSPOOL) + MAXLOGNAME + 1];
+ char buf[sizeof(_PATH_LOCKSPOOL) + LOGIN_NAME_MAX + 1];
/* XXX - lockspool requires root for user arg, we do not */
if (uflag) {
diff --git a/usr.bin/man/man.c b/usr.bin/man/man.c
index 812df45309f..ed380019bbb 100644
--- a/usr.bin/man/man.c
+++ b/usr.bin/man/man.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: man.c,v 1.48 2013/07/01 18:47:39 schwarze Exp $ */
+/* $OpenBSD: man.c,v 1.49 2015/01/16 06:40:09 deraadt Exp $ */
/* $NetBSD: man.c,v 1.7 1995/09/28 06:05:34 tls Exp $ */
/*
@@ -47,7 +47,6 @@
*/
#include <sys/types.h>
-#include <sys/param.h>
#include <sys/queue.h>
#include <sys/stat.h>
diff --git a/usr.bin/netstat/if.c b/usr.bin/netstat/if.c
index 90e392da783..675f33f3982 100644
--- a/usr.bin/netstat/if.c
+++ b/usr.bin/netstat/if.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if.c,v 1.69 2014/11/21 17:49:00 mikeb Exp $ */
+/* $OpenBSD: if.c,v 1.70 2015/01/16 06:40:09 deraadt Exp $ */
/* $NetBSD: if.c,v 1.16.4.2 1996/06/07 21:46:46 thorpej Exp $ */
/*
@@ -30,7 +30,7 @@
* SUCH DAMAGE.
*/
-#include <sys/param.h>
+#include <sys/param.h> /* roundup() */
#include <sys/types.h>
#include <sys/ioctl.h>
#include <sys/protosw.h>
diff --git a/usr.bin/netstat/inet.c b/usr.bin/netstat/inet.c
index cfebd8fe33d..af3d0a76582 100644
--- a/usr.bin/netstat/inet.c
+++ b/usr.bin/netstat/inet.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: inet.c,v 1.137 2014/11/03 17:20:46 bluhm Exp $ */
+/* $OpenBSD: inet.c,v 1.138 2015/01/16 06:40:09 deraadt Exp $ */
/* $NetBSD: inet.c,v 1.14 1995/10/03 21:42:37 thorpej Exp $ */
/*
@@ -30,7 +30,6 @@
* SUCH DAMAGE.
*/
-#include <sys/param.h>
#include <sys/queue.h>
#include <sys/socket.h>
#include <sys/socketvar.h>
@@ -802,7 +801,7 @@ inetname(struct in_addr *inp)
char *cp;
static char line[50];
struct hostent *hp;
- static char domain[MAXHOSTNAMELEN];
+ static char domain[HOST_NAME_MAX+1];
static int first = 1;
if (first && !nflag) {
diff --git a/usr.bin/netstat/inet6.c b/usr.bin/netstat/inet6.c
index a321ae369cc..124e28cd57a 100644
--- a/usr.bin/netstat/inet6.c
+++ b/usr.bin/netstat/inet6.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: inet6.c,v 1.46 2014/08/14 12:55:50 mpi Exp $ */
+/* $OpenBSD: inet6.c,v 1.47 2015/01/16 06:40:10 deraadt Exp $ */
/* BSDI inet.c,v 2.3 1995/10/24 02:19:29 prb Exp */
/*
* Copyright (c) 1983, 1988, 1993
@@ -29,7 +29,7 @@
* SUCH DAMAGE.
*/
-#include <sys/param.h>
+#include <sys/types.h>
#include <sys/socket.h>
#include <sys/socketvar.h>
#include <sys/ioctl.h>
@@ -60,6 +60,7 @@
#include <stdio.h>
#include <string.h>
#include <unistd.h>
+#include <limits.h>
#include "netstat.h"
struct socket sockb;
@@ -1113,7 +1114,7 @@ inet6name(struct in6_addr *in6p)
char *cp;
static char line[NI_MAXHOST];
struct hostent *hp;
- static char domain[MAXHOSTNAMELEN];
+ static char domain[HOST_NAME_MAX+1];
static int first = 1;
char hbuf[NI_MAXHOST];
struct sockaddr_in6 sin6;
diff --git a/usr.bin/netstat/main.c b/usr.bin/netstat/main.c
index f3074c99ef9..5b0eb1f0bec 100644
--- a/usr.bin/netstat/main.c
+++ b/usr.bin/netstat/main.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: main.c,v 1.102 2014/10/23 16:45:57 schwarze Exp $ */
+/* $OpenBSD: main.c,v 1.103 2015/01/16 06:40:10 deraadt Exp $ */
/* $NetBSD: main.c,v 1.9 1996/05/07 02:55:02 thorpej Exp $ */
/*
@@ -30,7 +30,7 @@
* SUCH DAMAGE.
*/
-#include <sys/param.h>
+#include <sys/types.h>
#include <sys/protosw.h>
#include <sys/socket.h>
#include <sys/sysctl.h>
diff --git a/usr.bin/netstat/mbuf.c b/usr.bin/netstat/mbuf.c
index 38e784fb80b..5d19182215a 100644
--- a/usr.bin/netstat/mbuf.c
+++ b/usr.bin/netstat/mbuf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mbuf.c,v 1.33 2014/11/06 12:50:55 dlg Exp $ */
+/* $OpenBSD: mbuf.c,v 1.34 2015/01/16 06:40:10 deraadt Exp $ */
/* $NetBSD: mbuf.c,v 1.9 1996/05/07 02:55:03 thorpej Exp $ */
/*
@@ -30,7 +30,7 @@
* SUCH DAMAGE.
*/
-#include <sys/param.h>
+#include <sys/param.h> /* MSIZE */
#include <sys/protosw.h>
#include <sys/socket.h>
#include <sys/mbuf.h>
diff --git a/usr.bin/netstat/mroute.c b/usr.bin/netstat/mroute.c
index 97f9275f988..48d5bee3bae 100644
--- a/usr.bin/netstat/mroute.c
+++ b/usr.bin/netstat/mroute.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mroute.c,v 1.22 2014/08/14 12:34:04 mpi Exp $ */
+/* $OpenBSD: mroute.c,v 1.23 2015/01/16 06:40:10 deraadt Exp $ */
/* $NetBSD: mroute.c,v 1.10 1996/05/11 13:51:27 mycroft Exp $ */
/*
@@ -42,7 +42,7 @@
* MROUTING 1.0
*/
-#include <sys/param.h>
+#include <sys/types.h>
#include <sys/socket.h>
#include <sys/socketvar.h>
#include <sys/protosw.h>
diff --git a/usr.bin/netstat/mroute6.c b/usr.bin/netstat/mroute6.c
index 438d04b17c7..79f824b8026 100644
--- a/usr.bin/netstat/mroute6.c
+++ b/usr.bin/netstat/mroute6.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mroute6.c,v 1.14 2014/11/21 17:49:00 mikeb Exp $ */
+/* $OpenBSD: mroute6.c,v 1.15 2015/01/16 06:40:10 deraadt Exp $ */
/*
* Copyright (C) 1998 WIDE Project.
@@ -64,7 +64,7 @@
* @(#)mroute.c 8.2 (Berkeley) 4/28/95
*/
-#include <sys/param.h>
+#include <sys/types.h>
#include <sys/queue.h>
#include <sys/socket.h>
#include <sys/protosw.h>
diff --git a/usr.bin/netstat/net80211.c b/usr.bin/netstat/net80211.c
index 6cf8a4413f6..07129060b08 100644
--- a/usr.bin/netstat/net80211.c
+++ b/usr.bin/netstat/net80211.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: net80211.c,v 1.12 2014/11/21 17:49:00 mikeb Exp $ */
+/* $OpenBSD: net80211.c,v 1.13 2015/01/16 06:40:10 deraadt Exp $ */
/*
* Copyright (c) 2005 Reyk Floeter <reyk@openbsd.org>
@@ -16,7 +16,7 @@
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
-#include <sys/param.h>
+#include <sys/types.h>
#include <sys/time.h>
#include <sys/socket.h>
#include <sys/file.h>
diff --git a/usr.bin/netstat/route.c b/usr.bin/netstat/route.c
index 004d2794410..dabfdcc0a9d 100644
--- a/usr.bin/netstat/route.c
+++ b/usr.bin/netstat/route.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: route.c,v 1.94 2014/12/26 05:47:23 tedu Exp $ */
+/* $OpenBSD: route.c,v 1.95 2015/01/16 06:40:10 deraadt Exp $ */
/* $NetBSD: route.c,v 1.15 1996/05/07 02:55:06 thorpej Exp $ */
/*
@@ -30,7 +30,7 @@
* SUCH DAMAGE.
*/
-#include <sys/param.h>
+#include <sys/types.h>
#include <sys/protosw.h>
#include <sys/socket.h>
diff --git a/usr.bin/netstat/show.c b/usr.bin/netstat/show.c
index e27e30198e1..8099bfcb182 100644
--- a/usr.bin/netstat/show.c
+++ b/usr.bin/netstat/show.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: show.c,v 1.43 2014/10/23 16:45:57 schwarze Exp $ */
+/* $OpenBSD: show.c,v 1.44 2015/01/16 06:40:10 deraadt Exp $ */
/* $NetBSD: show.c,v 1.1 1996/11/15 18:01:41 gwr Exp $ */
/*
@@ -30,7 +30,6 @@
* SUCH DAMAGE.
*/
-#include <sys/param.h>
#include <sys/socket.h>
#include <sys/sysctl.h>
@@ -53,6 +52,7 @@
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
+#include <limits.h>
#include "netstat.h"
@@ -563,8 +563,8 @@ p_sockaddr(struct sockaddr *sa, struct sockaddr *mask, int flags, int width)
}
}
-static char line[MAXHOSTNAMELEN];
-static char domain[MAXHOSTNAMELEN];
+static char line[HOST_NAME_MAX+1];
+static char domain[HOST_NAME_MAX+1];
void
p_sockaddr_mpls(struct sockaddr *in, struct sockaddr *out, int flags, int width)
diff --git a/usr.bin/netstat/unix.c b/usr.bin/netstat/unix.c
index e92a88bf5f3..c422a30b6b6 100644
--- a/usr.bin/netstat/unix.c
+++ b/usr.bin/netstat/unix.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: unix.c,v 1.23 2014/07/10 14:08:13 deraadt Exp $ */
+/* $OpenBSD: unix.c,v 1.24 2015/01/16 06:40:10 deraadt Exp $ */
/* $NetBSD: unix.c,v 1.13 1995/10/03 21:42:48 thorpej Exp $ */
/*-
@@ -33,7 +33,7 @@
/*
* Display protocol blocks in the unix domain.
*/
-#include <sys/param.h>
+#include <sys/param.h> /* MSIZE */
#include <sys/protosw.h>
#include <sys/socket.h>
#include <sys/socketvar.h>
diff --git a/usr.bin/newsyslog/newsyslog.c b/usr.bin/newsyslog/newsyslog.c
index 2527c5a87d8..95bcdcfd785 100644
--- a/usr.bin/newsyslog/newsyslog.c
+++ b/usr.bin/newsyslog/newsyslog.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: newsyslog.c,v 1.92 2013/11/26 13:19:07 deraadt Exp $ */
+/* $OpenBSD: newsyslog.c,v 1.93 2015/01/16 06:40:10 deraadt Exp $ */
/*
* Copyright (c) 1999, 2002, 2003 Todd C. Miller <Todd.Miller@courtesan.com>
@@ -90,7 +90,7 @@
#define SENDMAIL "/usr/lib/sendmail"
#endif
-#include <sys/param.h>
+#include <sys/param.h> /* DEV_BSIZE */
#include <sys/stat.h>
#include <sys/time.h>
#include <sys/wait.h>
@@ -153,7 +153,7 @@ int monitormode = 0; /* Don't do monitoring by default */
int force = 0; /* Force the logs to be rotated */
char *conf = CONF; /* Configuration file to use */
time_t timenow;
-char hostname[MAXHOSTNAMELEN]; /* Hostname */
+char hostname[HOST_NAME_MAX+1]; /* Hostname */
char *daytime; /* timenow in human readable form */
char *arcdir; /* Dir to put archives in (if it exists) */
@@ -648,7 +648,7 @@ parse_file(int *nentries)
break;
if (*q == '/') {
*(parse = son(parse)) = '\0';
- if (strlen(q) >= MAXPATHLEN)
+ if (strlen(q) >= PATH_MAX)
errx(1, "%s:%d: pathname too long: %s",
conf, lineno, q);
working->pidfile = strdup(q);
@@ -714,17 +714,17 @@ parse_file(int *nentries)
} else
working->backdir = NULL;
- /* Make sure we can't oflow MAXPATHLEN */
+ /* Make sure we can't oflow PATH_MAX */
if (working->backdir != NULL) {
if (snprintf(line, sizeof(line), "%s/%s.%d%s",
working->backdir, working->logbase,
- working->numlogs, COMPRESS_POSTFIX) >= MAXPATHLEN)
+ working->numlogs, COMPRESS_POSTFIX) >= PATH_MAX)
errx(1, "%s:%d: pathname too long: %s",
conf, lineno, q);
} else {
if (snprintf(line, sizeof(line), "%s.%d%s",
working->log, working->numlogs, COMPRESS_POSTFIX)
- >= MAXPATHLEN)
+ >= PATH_MAX)
errx(1, "%s:%d: pathname too long: %s",
conf, lineno, working->log);
}
@@ -749,7 +749,7 @@ missing_field(char *p, char *errline, int lineno)
void
rotate(struct conf_entry *ent, const char *oldlog)
{
- char file1[MAXPATHLEN], file2[MAXPATHLEN], *suffix;
+ char file1[PATH_MAX], file2[PATH_MAX], *suffix;
int numdays = ent->numlogs - 1;
int done = 0;
@@ -798,7 +798,7 @@ rotate(struct conf_entry *ent, const char *oldlog)
void
dotrim(struct conf_entry *ent)
{
- char file1[MAXPATHLEN], file2[MAXPATHLEN], oldlog[MAXPATHLEN];
+ char file1[PATH_MAX], file2[PATH_MAX], oldlog[PATH_MAX];
int fd;
/* Is there a separate backup dir? */
@@ -871,7 +871,7 @@ log_trim(char *log)
void
compress_log(struct conf_entry *ent)
{
- char *base, tmp[MAXPATHLEN];
+ char *base, tmp[PATH_MAX];
pid_t pid;
if (ent->backdir != NULL)
@@ -913,7 +913,7 @@ sizefile(struct stat *sb)
int
age_old_log(struct conf_entry *ent)
{
- char file[MAXPATHLEN];
+ char file[PATH_MAX];
struct stat sb;
if (ent->backdir != NULL)
@@ -967,7 +967,7 @@ isnumberstr(char *string)
int
domonitor(struct conf_entry *ent)
{
- char fname[MAXPATHLEN], *flog, *p, *rb = NULL;
+ char fname[PATH_MAX], *flog, *p, *rb = NULL;
struct stat sb, tsb;
off_t osize;
FILE *fp;
diff --git a/usr.bin/nfsstat/nfsstat.c b/usr.bin/nfsstat/nfsstat.c
index e0c44250f2f..878a0eed164 100644
--- a/usr.bin/nfsstat/nfsstat.c
+++ b/usr.bin/nfsstat/nfsstat.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: nfsstat.c,v 1.33 2009/10/27 23:59:40 deraadt Exp $ */
+/* $OpenBSD: nfsstat.c,v 1.34 2015/01/16 06:40:10 deraadt Exp $ */
/* $NetBSD: nfsstat.c,v 1.7 1996/03/03 17:21:30 thorpej Exp $ */
/*
@@ -33,7 +33,7 @@
* SUCH DAMAGE.
*/
-#include <sys/param.h>
+#include <sys/types.h>
#include <sys/mount.h>
#include <sys/sysctl.h>
#include <nfs/rpcv2.h>
diff --git a/usr.bin/nm/elf.c b/usr.bin/nm/elf.c
index 7e323d31de8..74b3bd35979 100644
--- a/usr.bin/nm/elf.c
+++ b/usr.bin/nm/elf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: elf.c,v 1.23 2013/11/26 13:19:07 deraadt Exp $ */
+/* $OpenBSD: elf.c,v 1.24 2015/01/16 06:40:10 deraadt Exp $ */
/*
* Copyright (c) 2003 Michael Shalayeff
@@ -26,7 +26,6 @@
* THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include <sys/param.h>
#include <sys/mman.h>
#include <unistd.h>
#include <a.out.h>
@@ -36,6 +35,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <limits.h>
#include <ctype.h>
#include "elfuncs.h"
#include "util.h"
diff --git a/usr.bin/nm/nm.c b/usr.bin/nm/nm.c
index a9622b67cad..3937f4926c1 100644
--- a/usr.bin/nm/nm.c
+++ b/usr.bin/nm/nm.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: nm.c,v 1.41 2014/04/28 18:49:28 miod Exp $ */
+/* $OpenBSD: nm.c,v 1.42 2015/01/16 06:40:10 deraadt Exp $ */
/* $NetBSD: nm.c,v 1.7 1996/01/14 23:04:03 pk Exp $ */
/*
@@ -33,7 +33,7 @@
* SUCH DAMAGE.
*/
-#include <sys/param.h>
+#include <sys/types.h>
#include <sys/mman.h>
#include <a.out.h>
#include <elf_abi.h>
diff --git a/usr.bin/nohup/nohup.c b/usr.bin/nohup/nohup.c
index bb4f9d389ee..dd9a158d169 100644
--- a/usr.bin/nohup/nohup.c
+++ b/usr.bin/nohup/nohup.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: nohup.c,v 1.14 2009/10/27 23:59:41 deraadt Exp $ */
+/* $OpenBSD: nohup.c,v 1.15 2015/01/16 06:40:10 deraadt Exp $ */
/* $NetBSD: nohup.c,v 1.6 1995/08/31 23:35:25 jtc Exp $ */
/*
@@ -30,7 +30,6 @@
* SUCH DAMAGE.
*/
-#include <sys/param.h>
#include <sys/file.h>
#include <sys/stat.h>
#include <fcntl.h>
@@ -40,6 +39,7 @@
#include <stdlib.h>
#include <string.h>
#include <errno.h>
+#include <limits.h>
#include <err.h>
static void dofile(void);
@@ -100,7 +100,7 @@ dofile(void)
{
int fd;
const char *p;
- char path[MAXPATHLEN];
+ char path[PATH_MAX];
p = FILENAME;
if ((fd = open(p, O_RDWR|O_CREAT|O_APPEND, S_IRUSR|S_IWUSR)) >= 0)
diff --git a/usr.bin/passwd/yp_passwd.c b/usr.bin/passwd/yp_passwd.c
index 2765eef00e2..de9a6603edf 100644
--- a/usr.bin/passwd/yp_passwd.c
+++ b/usr.bin/passwd/yp_passwd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: yp_passwd.c,v 1.34 2014/11/21 05:13:44 tedu Exp $ */
+/* $OpenBSD: yp_passwd.c,v 1.35 2015/01/16 06:40:10 deraadt Exp $ */
/*
* Copyright (c) 1988 The Regents of the University of California.
@@ -39,6 +39,7 @@
#include <time.h>
#include <pwd.h>
#include <err.h>
+#include <signal.h>
#include <errno.h>
#include <ctype.h>
#include <login_cap.h>
diff --git a/usr.bin/patch/util.c b/usr.bin/patch/util.c
index 4db53a42b5b..ee6e5d12a9f 100644
--- a/usr.bin/patch/util.c
+++ b/usr.bin/patch/util.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: util.c,v 1.38 2014/12/13 10:31:07 tobias Exp $ */
+/* $OpenBSD: util.c,v 1.39 2015/01/16 06:40:10 deraadt Exp $ */
/*
* patch - a program to apply diffs to original files
@@ -26,7 +26,6 @@
* behaviour
*/
-#include <sys/param.h>
#include <sys/stat.h>
#include <ctype.h>
@@ -95,7 +94,7 @@ int
backup_file(const char *orig)
{
struct stat filestat;
- char bakname[MAXPATHLEN], *s, *simplename;
+ char bakname[PATH_MAX], *s, *simplename;
dev_t orig_device;
ino_t orig_inode;
@@ -396,7 +395,7 @@ fetchname(const char *at, bool *exists, int strip_leading)
char *
checked_in(char *file)
{
- char *filebase, *filedir, tmpbuf[MAXPATHLEN];
+ char *filebase, *filedir, tmpbuf[PATH_MAX];
struct stat filestat;
filebase = basename(file);
diff --git a/usr.bin/pctr/pctr.c b/usr.bin/pctr/pctr.c
index 017dc5dd92a..85af51e7368 100644
--- a/usr.bin/pctr/pctr.c
+++ b/usr.bin/pctr/pctr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pctr.c,v 1.20 2008/07/08 21:39:52 sobrado Exp $ */
+/* $OpenBSD: pctr.c,v 1.21 2015/01/16 06:40:10 deraadt Exp $ */
/*
* Copyright (c) 2007 Mike Belopuhov, Aleksey Lomovtsev
@@ -25,7 +25,6 @@
* OpenBSD project by leaving this copyright notice intact.
*/
-#include <sys/param.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/sysctl.h>
diff --git a/usr.bin/pkill/pkill.c b/usr.bin/pkill/pkill.c
index df349bb0980..b03b7075d4c 100644
--- a/usr.bin/pkill/pkill.c
+++ b/usr.bin/pkill/pkill.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pkill.c,v 1.35 2014/05/07 01:27:42 tedu Exp $ */
+/* $OpenBSD: pkill.c,v 1.36 2015/01/16 06:40:10 deraadt Exp $ */
/* $NetBSD: pkill.c,v 1.5 2002/10/27 11:49:34 kleink Exp $ */
/*-
@@ -30,8 +30,8 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
+#include <sys/param.h> /* MAXCOMLEN */
#include <sys/types.h>
-#include <sys/param.h>
#include <sys/sysctl.h>
#include <sys/proc.h>
#include <sys/queue.h>
@@ -540,7 +540,7 @@ makelist(struct listhead *head, enum listtype type, char *src)
struct passwd *pw;
struct group *gr;
struct stat st;
- char *sp, *p, buf[MAXPATHLEN];
+ char *sp, *p, buf[PATH_MAX];
int empty;
empty = 1;
diff --git a/usr.bin/quota/quota.c b/usr.bin/quota/quota.c
index b2038ff9752..e122b9975dd 100644
--- a/usr.bin/quota/quota.c
+++ b/usr.bin/quota/quota.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: quota.c,v 1.32 2013/11/26 13:19:07 deraadt Exp $ */
+/* $OpenBSD: quota.c,v 1.33 2015/01/16 06:40:10 deraadt Exp $ */
/*
* Copyright (c) 1980, 1990, 1993
@@ -35,7 +35,7 @@
/*
* Disk quota reporting program.
*/
-#include <sys/param.h>
+#include <sys/param.h> /* DEV_BSIZE */
#include <sys/types.h>
#include <sys/file.h>
#include <sys/stat.h>
@@ -67,7 +67,7 @@ struct quotause {
struct quotause *next;
long flags;
struct dqblk dqblk;
- char fsname[MAXPATHLEN + 1];
+ char fsname[PATH_MAX + 1];
};
#define FOUND 0x01
diff --git a/usr.bin/rcs/ci.c b/usr.bin/rcs/ci.c
index 1ddaf3392d6..1ec9aeceed1 100644
--- a/usr.bin/rcs/ci.c
+++ b/usr.bin/rcs/ci.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ci.c,v 1.218 2014/10/02 06:23:15 otto Exp $ */
+/* $OpenBSD: ci.c,v 1.219 2015/01/16 06:40:11 deraadt Exp $ */
/*
* Copyright (c) 2005, 2006 Niall O'Higgins <niallo@openbsd.org>
* All rights reserved.
@@ -70,7 +70,7 @@ struct checkin_params {
RCSFILE *file;
RCSNUM *frev, *newrev;
const char *description, *symbol;
- char fpath[MAXPATHLEN], *rcs_msg, *username, *filename;
+ char fpath[PATH_MAX], *rcs_msg, *username, *filename;
char *author, *state;
BUF *deltatext;
};
diff --git a/usr.bin/rcs/co.c b/usr.bin/rcs/co.c
index 1d3cdc5acf4..ce050de96a5 100644
--- a/usr.bin/rcs/co.c
+++ b/usr.bin/rcs/co.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: co.c,v 1.119 2014/10/10 08:15:25 otto Exp $ */
+/* $OpenBSD: co.c,v 1.120 2015/01/16 06:40:11 deraadt Exp $ */
/*
* Copyright (c) 2005 Joris Vink <joris@openbsd.org>
* All rights reserved.
@@ -50,7 +50,7 @@ checkout_main(int argc, char **argv)
RCSNUM *rev;
RCSFILE *file;
const char *author, *date, *state;
- char fpath[MAXPATHLEN];
+ char fpath[PATH_MAX];
char *rev_str, *username;
time_t rcs_mtime = -1;
diff --git a/usr.bin/rcs/diff.c b/usr.bin/rcs/diff.c
index b19dcd1224c..1d0a4577166 100644
--- a/usr.bin/rcs/diff.c
+++ b/usr.bin/rcs/diff.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: diff.c,v 1.36 2014/12/01 21:58:46 deraadt Exp $ */
+/* $OpenBSD: diff.c,v 1.37 2015/01/16 06:40:11 deraadt Exp $ */
/*
* Copyright (C) Caldera International Inc. 2001-2002.
* All rights reserved.
@@ -64,21 +64,25 @@
* @(#)diffreg.c 8.1 (Berkeley) 6/6/93
*/
-#include <sys/param.h>
#include <sys/stat.h>
#include <ctype.h>
#include <err.h>
#include <stdarg.h>
+#include <stdint.h>
#include <stddef.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
+#include <limits.h>
#include "buf.h"
#include "diff.h"
#include "xmalloc.h"
+#define MINIMUM(a, b) (((a) < (b)) ? (a) : (b))
+#define MAXIMUM(a, b) (((a) > (b)) ? (a) : (b))
+
/*
* diff - compare two files.
*/
@@ -527,7 +531,7 @@ stone(int *a, int n, int *b, int *c, int flags)
bound = UINT_MAX;
else {
sq = isqrt(n);
- bound = MAX(256, sq);
+ bound = MAXIMUM(256, sq);
}
k = 0;
@@ -1200,10 +1204,10 @@ dump_context_vec(FILE *f1, FILE *f2, int flags)
return;
b = d = 0; /* gcc */
- lowa = MAX(1, cvp->a - diff_context);
- upb = MIN(len[0], context_vec_ptr->b + diff_context);
- lowc = MAX(1, cvp->c - diff_context);
- upd = MIN(len[1], context_vec_ptr->d + diff_context);
+ lowa = MAXIMUM(1, cvp->a - diff_context);
+ upb = MINIMUM(len[0], context_vec_ptr->b + diff_context);
+ lowc = MAXIMUM(1, cvp->c - diff_context);
+ upd = MINIMUM(len[1], context_vec_ptr->d + diff_context);
diff_output("***************");
if ((flags & D_PROTOTYPE)) {
@@ -1303,10 +1307,10 @@ dump_unified_vec(FILE *f1, FILE *f2, int flags)
return;
d = 0; /* gcc */
- lowa = MAX(1, cvp->a - diff_context);
- upb = MIN(len[0], context_vec_ptr->b + diff_context);
- lowc = MAX(1, cvp->c - diff_context);
- upd = MIN(len[1], context_vec_ptr->d + diff_context);
+ lowa = MAXIMUM(1, cvp->a - diff_context);
+ upb = MINIMUM(len[0], context_vec_ptr->b + diff_context);
+ lowc = MAXIMUM(1, cvp->c - diff_context);
+ upd = MINIMUM(len[1], context_vec_ptr->d + diff_context);
diff_output("@@ -");
uni_range(lowa, upb);
diff --git a/usr.bin/rcs/diff3.c b/usr.bin/rcs/diff3.c
index 9ceae97d302..27b57ea4d91 100644
--- a/usr.bin/rcs/diff3.c
+++ b/usr.bin/rcs/diff3.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: diff3.c,v 1.34 2014/12/01 21:58:46 deraadt Exp $ */
+/* $OpenBSD: diff3.c,v 1.35 2015/01/16 06:40:11 deraadt Exp $ */
/*
* Copyright (C) Caldera International Inc. 2001-2002.
@@ -126,7 +126,7 @@ static int last[4];
static int eflag = 3; /* default -E for compatibility with former RCS */
static int oflag = 1; /* default -E for compatibility with former RCS */
static int debug = 0;
-static char f1mark[MAXPATHLEN], f3mark[MAXPATHLEN]; /* markers for -E and -X */
+static char f1mark[PATH_MAX], f3mark[PATH_MAX]; /* markers for -E and -X */
static int duplicate(struct range *, struct range *);
static int edit(struct diff *, int, int);
diff --git a/usr.bin/rcs/rcs.c b/usr.bin/rcs/rcs.c
index cd86d6991a9..4db755e0cdc 100644
--- a/usr.bin/rcs/rcs.c
+++ b/usr.bin/rcs/rcs.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rcs.c,v 1.81 2014/10/10 08:15:25 otto Exp $ */
+/* $OpenBSD: rcs.c,v 1.82 2015/01/16 06:40:11 deraadt Exp $ */
/*
* Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org>
* All rights reserved.
@@ -24,6 +24,7 @@
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+#include <sys/param.h> /* MAXBSIZE */
#include <sys/stat.h>
#include <ctype.h>
@@ -44,6 +45,8 @@
#include "rcsutil.h"
#include "xmalloc.h"
+#define MINIMUM(a, b) (((a) < (b)) ? (a) : (b))
+
/* invalid characters in RCS states */
static const char rcs_state_invch[] = RCS_STATE_INVALCHAR;
@@ -981,7 +984,7 @@ rcs_getrev(RCSFILE *rfp, RCSNUM *frev)
/* XXX rcsnum_cmp() is totally broken for
* this purpose.
*/
- numlen = MIN(brev->rn_len,
+ numlen = MINIMUM(brev->rn_len,
rb->rb_num->rn_len - 1);
for (i = 0; i < numlen; i++) {
if (rb->rb_num->rn_id[i] !=
@@ -1477,7 +1480,7 @@ rcs_expand_keywords(char *rcsfile_in, struct rcs_delta *rdp, BUF *bp, int mode)
{
BUF *newbuf;
u_char *c, *kw, *fin;
- char buf[256], *tmpf, resolved[MAXPATHLEN], *rcsfile;
+ char buf[256], *tmpf, resolved[PATH_MAX], *rcsfile;
u_char *line, *line2;
u_int i, j;
int kwtype;
diff --git a/usr.bin/rcs/rcsclean.c b/usr.bin/rcs/rcsclean.c
index 1241e756d21..4bff4894fd4 100644
--- a/usr.bin/rcs/rcsclean.c
+++ b/usr.bin/rcs/rcsclean.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rcsclean.c,v 1.53 2014/10/02 06:23:15 otto Exp $ */
+/* $OpenBSD: rcsclean.c,v 1.54 2015/01/16 06:40:11 deraadt Exp $ */
/*
* Copyright (c) 2005 Joris Vink <joris@openbsd.org>
* All rights reserved.
@@ -133,7 +133,7 @@ rcsclean_file(char *fname, const char *rev_str)
{
int fd, match;
RCSFILE *file;
- char fpath[MAXPATHLEN], numb[RCS_REV_BUFSZ];
+ char fpath[PATH_MAX], numb[RCS_REV_BUFSZ];
RCSNUM *rev;
BUF *b1, *b2;
time_t rcs_mtime = -1;
diff --git a/usr.bin/rcs/rcsdiff.c b/usr.bin/rcs/rcsdiff.c
index f508dba3ecf..bd3a3edbdf6 100644
--- a/usr.bin/rcs/rcsdiff.c
+++ b/usr.bin/rcs/rcsdiff.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rcsdiff.c,v 1.81 2014/12/01 21:58:46 deraadt Exp $ */
+/* $OpenBSD: rcsdiff.c,v 1.82 2015/01/16 06:40:11 deraadt Exp $ */
/*
* Copyright (c) 2005 Joris Vink <joris@openbsd.org>
* All rights reserved.
@@ -51,7 +51,7 @@ rcsdiff_main(int argc, char **argv)
int fd, i, ch, dflags, status;
RCSNUM *rev1, *rev2;
RCSFILE *file;
- char fpath[MAXPATHLEN], *rev_str1, *rev_str2;
+ char fpath[PATH_MAX], *rev_str1, *rev_str2;
const char *errstr;
rev1 = rev2 = NULL;
diff --git a/usr.bin/rcs/rcsmerge.c b/usr.bin/rcs/rcsmerge.c
index d5806e367f0..96ff687d17a 100644
--- a/usr.bin/rcs/rcsmerge.c
+++ b/usr.bin/rcs/rcsmerge.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rcsmerge.c,v 1.54 2014/10/10 08:15:25 otto Exp $ */
+/* $OpenBSD: rcsmerge.c,v 1.55 2015/01/16 06:40:11 deraadt Exp $ */
/*
* Copyright (c) 2005, 2006 Xavier Santolaria <xsa@openbsd.org>
* All rights reserved.
@@ -37,7 +37,7 @@ int
rcsmerge_main(int argc, char **argv)
{
int fd, ch, flags, kflag, status;
- char fpath[MAXPATHLEN], r1[RCS_REV_BUFSZ], r2[RCS_REV_BUFSZ];
+ char fpath[PATH_MAX], r1[RCS_REV_BUFSZ], r2[RCS_REV_BUFSZ];
char *rev_str1, *rev_str2;
RCSFILE *file;
RCSNUM *rev1, *rev2;
diff --git a/usr.bin/rcs/rcsnum.c b/usr.bin/rcs/rcsnum.c
index 907683453cb..71cc05d848a 100644
--- a/usr.bin/rcs/rcsnum.c
+++ b/usr.bin/rcs/rcsnum.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rcsnum.c,v 1.15 2014/12/01 21:58:46 deraadt Exp $ */
+/* $OpenBSD: rcsnum.c,v 1.16 2015/01/16 06:40:11 deraadt Exp $ */
/*
* Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org>
* All rights reserved.
@@ -24,15 +24,16 @@
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include <sys/param.h>
-
#include <ctype.h>
#include <err.h>
#include <string.h>
+#include <limits.h>
#include "rcs.h"
#include "xmalloc.h"
+#define MINIMUM(a, b) (((a) < (b)) ? (a) : (b))
+
static void rcsnum_setsize(RCSNUM *, u_int);
static char *rcsnum_itoa(u_int16_t, char *, size_t);
@@ -199,7 +200,7 @@ rcsnum_cmp(const RCSNUM *n1, const RCSNUM *n2, u_int depth)
u_int i;
size_t slen;
- slen = MIN(n1->rn_len, n2->rn_len);
+ slen = MINIMUM(n1->rn_len, n2->rn_len);
if (depth != 0 && slen > depth)
slen = depth;
diff --git a/usr.bin/rcs/rcsprog.c b/usr.bin/rcs/rcsprog.c
index c4b4729f8b3..0029cff4972 100644
--- a/usr.bin/rcs/rcsprog.c
+++ b/usr.bin/rcs/rcsprog.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rcsprog.c,v 1.154 2014/12/01 21:58:46 deraadt Exp $ */
+/* $OpenBSD: rcsprog.c,v 1.155 2015/01/16 06:40:11 deraadt Exp $ */
/*
* Copyright (c) 2005 Jean-Francois Brousseau <jfb@openbsd.org>
* All rights reserved.
@@ -181,7 +181,7 @@ rcs_main(int argc, char **argv)
int fd;
int i, j, ch, flags, kflag, lkmode;
const char *nflag, *oldfilename, *orange;
- char fpath[MAXPATHLEN];
+ char fpath[PATH_MAX];
char *logstr, *logmsg, *descfile;
char *alist, *comment, *elist, *lrev, *urev;
mode_t fmode;
@@ -371,7 +371,7 @@ rcs_main(int argc, char **argv)
if (rcsflags & CO_ACLAPPEND) {
RCSFILE *oldfile;
int ofd;
- char ofpath[MAXPATHLEN];
+ char ofpath[PATH_MAX];
ofd = rcs_choosefile(oldfilename, ofpath, sizeof(ofpath));
if (ofd < 0) {
diff --git a/usr.bin/rcs/rcsutil.c b/usr.bin/rcs/rcsutil.c
index f27cf467e3e..258e5ed76af 100644
--- a/usr.bin/rcs/rcsutil.c
+++ b/usr.bin/rcs/rcsutil.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rcsutil.c,v 1.42 2014/12/01 21:58:46 deraadt Exp $ */
+/* $OpenBSD: rcsutil.c,v 1.43 2015/01/16 06:40:11 deraadt Exp $ */
/*
* Copyright (c) 2005, 2006 Joris Vink <joris@openbsd.org>
* Copyright (c) 2006 Xavier Santolaria <xsa@openbsd.org>
@@ -154,8 +154,8 @@ rcs_choosefile(const char *filename, char *out, size_t len)
{
int fd;
struct stat sb;
- char *p, *ext, name[MAXPATHLEN], *next, *ptr, rcsdir[MAXPATHLEN],
- *suffixes, rcspath[MAXPATHLEN];
+ char *p, *ext, name[PATH_MAX], *next, *ptr, rcsdir[PATH_MAX],
+ *suffixes, rcspath[PATH_MAX];
/*
* If `filename' contains a directory, `rcspath' contains that
@@ -215,7 +215,7 @@ rcs_choosefile(const char *filename, char *out, size_t len)
*/
suffixes = xstrdup(rcs_suffixes);
for (next = suffixes; (ext = strsep(&next, "/")) != NULL;) {
- char fpath[MAXPATHLEN];
+ char fpath[PATH_MAX];
if ((p = strrchr(rcspath, ',')) != NULL) {
if (!strcmp(p, ext)) {
diff --git a/usr.bin/rcs/rlog.c b/usr.bin/rcs/rlog.c
index 9f4b8594767..bb9d1c2302f 100644
--- a/usr.bin/rcs/rlog.c
+++ b/usr.bin/rcs/rlog.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rlog.c,v 1.70 2014/11/28 15:09:50 otto Exp $ */
+/* $OpenBSD: rlog.c,v 1.71 2015/01/16 06:40:11 deraadt Exp $ */
/*
* Copyright (c) 2005, 2009 Joris Vink <joris@openbsd.org>
* Copyright (c) 2005, 2006 Xavier Santolaria <xsa@openbsd.org>
@@ -75,7 +75,7 @@ rlog_main(int argc, char **argv)
RCSFILE *file;
int Rflag;
int i, ch, fd, status;
- char fpath[MAXPATHLEN];
+ char fpath[PATH_MAX];
rcsnum_flags |= RCSNUM_NO_MAGIC;
hflag = Rflag = rflag = status = 0;
diff --git a/usr.bin/rcs/worklist.h b/usr.bin/rcs/worklist.h
index 40a9b125019..cf833e8580b 100644
--- a/usr.bin/rcs/worklist.h
+++ b/usr.bin/rcs/worklist.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: worklist.h,v 1.3 2010/07/23 08:31:19 ray Exp $ */
+/* $OpenBSD: worklist.h,v 1.4 2015/01/16 06:40:11 deraadt Exp $ */
/*
* Copyright (c) 2006 Joris Vink <joris@openbsd.org>
* All rights reserved.
@@ -27,10 +27,11 @@
#ifndef WORKLIST_H
#define WORKLIST_H
-#include <sys/param.h>
+#include <sys/types.h>
+#include <limits.h>
struct worklist {
- char wkl_path[MAXPATHLEN];
+ char wkl_path[PATH_MAX];
volatile SLIST_ENTRY(worklist) wkl_list;
};
diff --git a/usr.bin/rdist/client.c b/usr.bin/rdist/client.c
index 69225dec2ca..47dbad804c9 100644
--- a/usr.bin/rdist/client.c
+++ b/usr.bin/rdist/client.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: client.c,v 1.31 2014/07/12 03:48:04 guenther Exp $ */
+/* $OpenBSD: client.c,v 1.32 2015/01/16 06:40:11 deraadt Exp $ */
/*
* Copyright (c) 1983 Regents of the University of California.
@@ -347,9 +347,9 @@ linkinfo(struct stat *statp)
static int
sendhardlink(opt_t opts, struct linkbuf *lp, char *rname, int destdir)
{
- static char buff[MAXPATHLEN];
+ static char buff[PATH_MAX];
char *lname; /* name of file to link to */
- char ername[MAXPATHLEN*4], elname[MAXPATHLEN*4];
+ char ername[PATH_MAX*4], elname[PATH_MAX*4];
debugmsg(DM_MISC,
"sendhardlink: rname='%s' pathname='%s' src='%s' target='%s'\n",
@@ -382,7 +382,7 @@ sendfile(char *rname, opt_t opts, struct stat *stb, char *user,
{
int goterr, f;
off_t i;
- char ername[MAXPATHLEN*4];
+ char ername[PATH_MAX*4];
if (stb->st_nlink > 1) {
struct linkbuf *lp;
@@ -492,7 +492,7 @@ rmchk(opt_t opts)
struct stat stb;
int didupdate = 0;
int n;
- char targ[MAXPATHLEN*4];
+ char targ[PATH_MAX*4];
debugmsg(DM_CALL, "rmchk()\n");
@@ -584,7 +584,7 @@ senddir(char *rname, opt_t opts, struct stat *stb, char *user,
char *optarget, *cp;
int len;
int didupdate = 0;
- char ername[MAXPATHLEN*4];
+ char ername[PATH_MAX*4];
/*
* Send recvdir command in recvit() format.
@@ -620,7 +620,7 @@ senddir(char *rname, opt_t opts, struct stat *stb, char *user,
if (!strcmp(dp->d_name, ".") ||
!strcmp(dp->d_name, ".."))
continue;
- if (len + 1 + (int) strlen(dp->d_name) >= MAXPATHLEN - 1) {
+ if (len + 1 + (int) strlen(dp->d_name) >= PATH_MAX - 1) {
error("%s/%s: Name too long", target,
dp->d_name);
continue;
@@ -656,9 +656,9 @@ sendlink(char *rname, opt_t opts, struct stat *stb, char *user,
{
int f, n;
static char tbuf[BUFSIZ];
- char lbuf[MAXPATHLEN];
+ char lbuf[PATH_MAX];
u_char *s;
- char ername[MAXPATHLEN*4];
+ char ername[PATH_MAX*4];
debugmsg(DM_CALL, "sendlink(%s, %lx, stb, %d)\n", rname, opts, destdir);
@@ -777,7 +777,7 @@ update(char *rname, opt_t opts, struct stat *statp)
char *owner = NULL, *group = NULL;
int done, n;
u_char *cp;
- char ername[MAXPATHLEN*4];
+ char ername[PATH_MAX*4];
debugmsg(DM_CALL, "update(%s, 0x%lx, %p)\n", rname, opts, statp);
@@ -1041,7 +1041,7 @@ statupdate(int u, char *starget, opt_t opts, char *rname, int destdir,
struct stat *st, char *user, char *group)
{
int rv = 0;
- char ername[MAXPATHLEN*4];
+ char ername[PATH_MAX*4];
int lmode = st->st_mode & 07777;
if (u == US_CHMOG) {
@@ -1214,10 +1214,10 @@ cleanup(int dummy)
int
install(char *src, char *dest, int ddir, int destdir, opt_t opts)
{
- static char destcopy[MAXPATHLEN];
+ static char destcopy[PATH_MAX];
char *rname;
int didupdate = 0;
- char ername[MAXPATHLEN*4];
+ char ername[PATH_MAX*4];
debugmsg(DM_CALL,
"install(src=%s,dest=%s,ddir=%d,destdir=%d,opts=%ld) start\n",
diff --git a/usr.bin/rdist/common.c b/usr.bin/rdist/common.c
index 0780c51c6a5..34312c0e636 100644
--- a/usr.bin/rdist/common.c
+++ b/usr.bin/rdist/common.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: common.c,v 1.33 2014/07/12 03:32:00 guenther Exp $ */
+/* $OpenBSD: common.c,v 1.34 2015/01/16 06:40:11 deraadt Exp $ */
/*
* Copyright (c) 1983 Regents of the University of California.
@@ -44,7 +44,7 @@
/*
* Variables common to both client and server
*/
-char host[MAXHOSTNAMELEN]; /* Name of this host */
+char host[HOST_NAME_MAX+1]; /* Name of this host */
uid_t userid = (uid_t)-1; /* User's UID */
gid_t groupid = (gid_t)-1; /* User's GID */
char *homedir = NULL; /* User's $HOME */
diff --git a/usr.bin/rdist/defs.h b/usr.bin/rdist/defs.h
index 0fd21548cae..54099b986ac 100644
--- a/usr.bin/rdist/defs.h
+++ b/usr.bin/rdist/defs.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: defs.h,v 1.31 2014/07/12 03:48:04 guenther Exp $ */
+/* $OpenBSD: defs.h,v 1.32 2015/01/16 06:40:11 deraadt Exp $ */
#ifndef __DEFS_H__
#define __DEFS_H__
@@ -37,7 +37,6 @@
*/
#include <sys/types.h>
-#include <sys/param.h>
#include <sys/file.h>
#include <sys/time.h>
#include <sys/stat.h>
@@ -55,6 +54,7 @@
#include <string.h>
#include <syslog.h>
#include <unistd.h>
+#include <limits.h>
#ifndef __GNUC__
# ifndef __attribute__
diff --git a/usr.bin/rdist/message.c b/usr.bin/rdist/message.c
index 1e28bac9731..5ce2f0e5259 100644
--- a/usr.bin/rdist/message.c
+++ b/usr.bin/rdist/message.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: message.c,v 1.21 2014/07/05 06:18:58 guenther Exp $ */
+/* $OpenBSD: message.c,v 1.22 2015/01/16 06:40:11 deraadt Exp $ */
/*
* Copyright (c) 1983 Regents of the University of California.
@@ -473,7 +473,7 @@ msgsendnotify(MSGFACILITY *msgfac, int mtype, int flags, char *msgbuf)
void
checkhostname(void)
{
- static char mbuf[MAXHOSTNAMELEN];
+ static char mbuf[HOST_NAME_MAX+1];
char *cp;
if (!currenthost) {
diff --git a/usr.bin/rdistd/filesys-os.c b/usr.bin/rdistd/filesys-os.c
index 8558094a60a..1707afdfe23 100644
--- a/usr.bin/rdistd/filesys-os.c
+++ b/usr.bin/rdistd/filesys-os.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: filesys-os.c,v 1.11 2014/07/05 10:21:24 guenther Exp $ */
+/* $OpenBSD: filesys-os.c,v 1.12 2015/01/16 06:40:11 deraadt Exp $ */
/*
* Copyright (c) 1983 Regents of the University of California.
@@ -29,7 +29,7 @@
* SUCH DAMAGE.
*/
-#include <sys/param.h>
+#include <sys/types.h>
#include <sys/mount.h>
#include "defs.h"
@@ -71,7 +71,7 @@ mntent_t *
getmountent(void)
{
static mntent_t mntstruct;
- static char remote_dev[MAXHOSTNAMELEN+MAXPATHLEN+1];
+ static char remote_dev[HOST_NAME_MAX+1 + PATH_MAX + 1];
if (!entries_left)
return (NULL);
diff --git a/usr.bin/rdistd/filesys.c b/usr.bin/rdistd/filesys.c
index 8d413a416d3..fc25fb75b7e 100644
--- a/usr.bin/rdistd/filesys.c
+++ b/usr.bin/rdistd/filesys.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: filesys.c,v 1.16 2015/01/10 07:56:16 guenther Exp $ */
+/* $OpenBSD: filesys.c,v 1.17 2015/01/16 06:40:11 deraadt Exp $ */
/*
* Copyright (c) 1983 Regents of the University of California.
@@ -29,7 +29,7 @@
* SUCH DAMAGE.
*/
-#include <sys/param.h>
+#include <sys/types.h>
#include <sys/mount.h>
#include "defs.h"
@@ -49,8 +49,8 @@ jmp_buf env;
char *
find_file(char *pathname, struct stat *statbuf, int *isvalid)
{
- static char last_pathname[MAXPATHLEN];
- static char file[MAXPATHLEN + 3];
+ static char last_pathname[PATH_MAX];
+ static char file[PATH_MAX + 3];
static struct stat filestat;
char *p;
diff --git a/usr.bin/rdistd/server.c b/usr.bin/rdistd/server.c
index 47d47eb5128..d5973fadf49 100644
--- a/usr.bin/rdistd/server.c
+++ b/usr.bin/rdistd/server.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: server.c,v 1.33 2014/07/12 03:10:03 guenther Exp $ */
+/* $OpenBSD: server.c,v 1.34 2015/01/16 06:40:11 deraadt Exp $ */
/*
* Copyright (c) 1983 Regents of the University of California.
@@ -39,7 +39,7 @@
char tempname[sizeof _RDIST_TMP + 1]; /* Tmp file name */
char buf[BUFSIZ]; /* general purpose buffer */
-char target[MAXPATHLEN]; /* target/source directory name */
+char target[PATH_MAX]; /* target/source directory name */
char *ptarget; /* pointer to end of target name */
int catname = 0; /* cat name to target name */
char *sptarget[32]; /* stack of saved ptarget's for directories */
@@ -324,7 +324,7 @@ removefile(struct stat *statb, int silent)
(dp->d_name[1] == '.' && dp->d_name[2] == '\0')))
continue;
- if (len + 1 + (int)strlen(dp->d_name) >= MAXPATHLEN - 1) {
+ if (len + 1 + (int)strlen(dp->d_name) >= PATH_MAX - 1) {
if (!silent)
message(MT_REMOTE|MT_WARNING,
"%s/%s: Name too long",
@@ -387,7 +387,7 @@ doclean(char *cp)
char *optarget, *ep;
int len;
opt_t opts;
- char targ[MAXPATHLEN*4];
+ char targ[PATH_MAX*4];
opts = strtol(cp, &ep, 8);
if (*ep != CNULL) {
@@ -407,7 +407,7 @@ doclean(char *cp)
(dp->d_name[1] == '.' && dp->d_name[2] == '\0')))
continue;
- if (len + 1 + (int)strlen(dp->d_name) >= MAXPATHLEN - 1) {
+ if (len + 1 + (int)strlen(dp->d_name) >= PATH_MAX - 1) {
message(MT_REMOTE|MT_WARNING, "%s/%s: Name too long",
target, dp->d_name);
continue;
@@ -553,7 +553,7 @@ query(char *xname)
{
static struct stat stb;
int s = -1, stbvalid = 0;
- char name[MAXPATHLEN];
+ char name[PATH_MAX];
if (DECODE(name, xname) == -1) {
error("query: Cannot decode filename");
@@ -677,9 +677,9 @@ chkparent(char *name, opt_t opts)
static char *
savetarget(char *file, opt_t opts)
{
- static char savefile[MAXPATHLEN];
+ static char savefile[PATH_MAX];
- if (strlen(file) + sizeof(SAVE_SUFFIX) + 1 > MAXPATHLEN) {
+ if (strlen(file) + sizeof(SAVE_SUFFIX) + 1 > PATH_MAX) {
error("%s: Cannot save: Save name too long", file);
return(NULL);
}
@@ -1110,7 +1110,7 @@ recvdir(opt_t opts, int mode, char *owner, char *group)
static void
recvlink(char *new, opt_t opts, int mode, off_t size)
{
- char tbuf[MAXPATHLEN], dbuf[BUFSIZ];
+ char tbuf[PATH_MAX], dbuf[BUFSIZ];
struct stat stb;
char *optarget;
int uptodate;
@@ -1355,8 +1355,8 @@ recvit(char *cmd, int type)
off_t size;
time_t mtime, atime;
char *owner, *group, *file;
- char new[MAXPATHLEN];
- char fileb[MAXPATHLEN];
+ char new[PATH_MAX];
+ char fileb[PATH_MAX];
int64_t freespace = -1, freefiles = -1;
char *cp = cmd;
@@ -1541,7 +1541,7 @@ dochmog(char *cmd)
opt_t opts;
char *owner, *group, *file;
char *cp = cmd;
- char fileb[MAXPATHLEN];
+ char fileb[PATH_MAX];
/*
* Get rdist option flags
diff --git a/usr.bin/rpcgen/rpc_main.c b/usr.bin/rpcgen/rpc_main.c
index 92c9e5f938a..70027bac95d 100644
--- a/usr.bin/rpcgen/rpc_main.c
+++ b/usr.bin/rpcgen/rpc_main.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rpc_main.c,v 1.28 2014/11/18 20:54:28 krw Exp $ */
+/* $OpenBSD: rpc_main.c,v 1.29 2015/01/16 06:40:11 deraadt Exp $ */
/* $NetBSD: rpc_main.c,v 1.9 1996/02/19 11:12:43 pk Exp $ */
/*
@@ -39,12 +39,12 @@
#define RPCGEN_VERSION "199506"/* This program's version (year & month) */
#include <sys/types.h>
-#include <sys/param.h>
#include <sys/file.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
+#include <limits.h>
#include <ctype.h>
#include <sys/stat.h>
#include "rpc_parse.h"
@@ -77,7 +77,7 @@ static char *cmdname;
static char *svcclosetime = "120";
static char *CPP = "/usr/bin/cpp";
static char CPPFLAGS[] = "-C";
-static char pathbuf[MAXPATHLEN];
+static char pathbuf[PATH_MAX];
static char *allv[] = {
"rpcgen", "-s", "udp", "-s", "tcp",
};
diff --git a/usr.bin/rup/rup.c b/usr.bin/rup/rup.c
index 3200cfb01a0..6e61fc06a28 100644
--- a/usr.bin/rup/rup.c
+++ b/usr.bin/rup/rup.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rup.c,v 1.28 2014/11/26 18:34:51 millert Exp $ */
+/* $OpenBSD: rup.c,v 1.29 2015/01/16 06:40:11 deraadt Exp $ */
/*-
* Copyright (c) 1993, John Brezak
@@ -32,7 +32,6 @@
#include <stdlib.h>
#include <string.h>
#include <time.h>
-#include <sys/param.h>
#include <sys/socket.h>
#include <netdb.h>
#include <rpc/rpc.h>
diff --git a/usr.bin/rusers/rusers.c b/usr.bin/rusers/rusers.c
index 7d991526d4f..96077d82c5a 100644
--- a/usr.bin/rusers/rusers.c
+++ b/usr.bin/rusers/rusers.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rusers.c,v 1.33 2014/11/26 18:34:51 millert Exp $ */
+/* $OpenBSD: rusers.c,v 1.34 2015/01/16 06:40:11 deraadt Exp $ */
/*
* Copyright (c) 2001, 2003 Todd C. Miller <Todd.Miller@courtesan.com>
@@ -46,9 +46,9 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#include <sys/param.h>
#include <sys/ioctl.h>
#include <sys/socket.h>
+#include <sys/signal.h>
#include <rpc/rpc.h>
#include <rpc/pmap_prot.h>
#include <rpc/pmap_rmt.h>
@@ -65,6 +65,10 @@
#include <string.h>
#include <termios.h>
#include <unistd.h>
+#include <limits.h>
+
+#define MINIMUM(a, b) (((a) < (b)) ? (a) : (b))
+#define MAXIMUM(a, b) (((a) > (b)) ? (a) : (b))
/* Preferred formatting */
#define HOST_WIDTH 17
@@ -535,7 +539,7 @@ allhosts(void)
outlen[1] = xdr_getpos(&xdr);
xdr_destroy(&xdr);
- maxfd = MAX(sock[0], sock[1]) + 1;
+ maxfd = MAXIMUM(sock[0], sock[1]) + 1;
fds = (fd_set *)calloc(howmany(maxfd, NFDBITS), sizeof(fd_mask));
if (fds == NULL)
err(1, NULL);
@@ -653,16 +657,16 @@ print_entry(struct host_info *entry, int longfmt)
date[sizeof(date) - 1] = '\0';
fmt_idle(ut->ut_idle, idle_time, sizeof(idle_time));
len = termwidth -
- (MAX(strlen(ut->ut_user), NAME_WIDTH) + 1 +
+ (MAXIMUM(strlen(ut->ut_user), NAME_WIDTH) + 1 +
HOST_WIDTH + 1 + LINE_WIDTH + 1 + strlen(date) +
- 1 + MAX(8, strlen(idle_time)) + 1 + 2);
+ 1 + MAXIMUM(8, strlen(idle_time)) + 1 + 2);
if (len > 0 && ut->ut_host[0] != '\0')
snprintf(remote, sizeof(remote), "(%.*s)",
- MIN(len, RUSERS_MAXHOSTLEN), ut->ut_host);
+ MINIMUM(len, RUSERS_MAXHOSTLEN), ut->ut_host);
else
remote[0] = '\0';
- len = HOST_WIDTH - MIN(HOST_WIDTH, strlen(entry->host)) +
- LINE_WIDTH - MIN(LINE_WIDTH, strlen(ut->ut_line));
+ len = HOST_WIDTH - MINIMUM(HOST_WIDTH, strlen(entry->host)) +
+ LINE_WIDTH - MINIMUM(LINE_WIDTH, strlen(ut->ut_line));
printf("%-*s %.*s:%.*s%-*s %-12s %8s %s\n",
NAME_WIDTH, ut->ut_user, HOST_WIDTH, entry->host,
LINE_WIDTH, ut->ut_line, len, "", date,
diff --git a/usr.bin/rwall/rwall.c b/usr.bin/rwall/rwall.c
index 7c0abdabf04..29725f8d2dc 100644
--- a/usr.bin/rwall/rwall.c
+++ b/usr.bin/rwall/rwall.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rwall.c,v 1.12 2009/10/27 23:59:43 deraadt Exp $ */
+/* $OpenBSD: rwall.c,v 1.13 2015/01/16 06:40:11 deraadt Exp $ */
/*
* Copyright (c) 1993 Christopher G. Demetriou
@@ -39,11 +39,11 @@
#include <stdlib.h>
#include <string.h>
#include <time.h>
-#include <sys/param.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <pwd.h>
#include <unistd.h>
+#include <limits.h>
#include <paths.h>
#include <err.h>
@@ -109,7 +109,7 @@ makemsg(char *fname)
time_t now;
FILE *fp;
int fd;
- char *whom, hostname[MAXHOSTNAMELEN], lbuf[100], tmpname[MAXPATHLEN];
+ char *whom, hostname[HOST_NAME_MAX+1], lbuf[100], tmpname[PATH_MAX];
snprintf(tmpname, sizeof(tmpname), "%s/wall.XXXXXXXXXX", _PATH_TMP);
if ((fd = mkstemp(tmpname)) == -1 || !(fp = fdopen(fd, "r+")))
diff --git a/usr.bin/sdiff/sdiff.c b/usr.bin/sdiff/sdiff.c
index 3866d7bc8d6..93d0d4e904a 100644
--- a/usr.bin/sdiff/sdiff.c
+++ b/usr.bin/sdiff/sdiff.c
@@ -1,11 +1,10 @@
-/* $OpenBSD: sdiff.c,v 1.30 2013/11/26 21:08:12 deraadt Exp $ */
+/* $OpenBSD: sdiff.c,v 1.31 2015/01/16 06:40:11 deraadt Exp $ */
/*
* Written by Raymond Lai <ray@cyth.net>.
* Public domain.
*/
-#include <sys/param.h>
#include <sys/queue.h>
#include <sys/stat.h>
#include <sys/types.h>
diff --git a/usr.bin/sendbug/sendbug.c b/usr.bin/sendbug/sendbug.c
index 616202fdb68..8075f44ed31 100644
--- a/usr.bin/sendbug/sendbug.c
+++ b/usr.bin/sendbug/sendbug.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sendbug.c,v 1.68 2014/03/18 22:36:37 miod Exp $ */
+/* $OpenBSD: sendbug.c,v 1.69 2015/01/16 06:40:11 deraadt Exp $ */
/*
* Written by Ray Lai <ray@cyth.net>.
@@ -6,7 +6,6 @@
*/
#include <sys/types.h>
-#include <sys/param.h>
#include <sys/stat.h>
#include <sys/sysctl.h>
#include <sys/wait.h>
diff --git a/usr.bin/skeyaudit/skeyaudit.c b/usr.bin/skeyaudit/skeyaudit.c
index b50d9a8ef2b..381c271b6dc 100644
--- a/usr.bin/skeyaudit/skeyaudit.c
+++ b/usr.bin/skeyaudit/skeyaudit.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: skeyaudit.c,v 1.24 2008/11/12 16:13:46 sobrado Exp $ */
+/* $OpenBSD: skeyaudit.c,v 1.25 2015/01/16 06:40:11 deraadt Exp $ */
/*
* Copyright (c) 1997, 2000, 2003 Todd C. Miller <Todd.Miller@courtesan.com>
@@ -20,7 +20,6 @@
* Materiel Command, USAF, under agreement number F39502-99-1-0512.
*/
-#include <sys/param.h>
#include <sys/wait.h>
#include <err.h>
@@ -138,7 +137,7 @@ main(int argc, char **argv)
void
notify(struct passwd *pw, int seq, int interactive)
{
- static char hostname[MAXHOSTNAMELEN];
+ static char hostname[HOST_NAME_MAX+1];
pid_t pid;
FILE *out;
diff --git a/usr.bin/skeyinit/skeyinit.c b/usr.bin/skeyinit/skeyinit.c
index d94d72e0e97..96698358826 100644
--- a/usr.bin/skeyinit/skeyinit.c
+++ b/usr.bin/skeyinit/skeyinit.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: skeyinit.c,v 1.55 2014/05/20 01:25:23 guenther Exp $ */
+/* $OpenBSD: skeyinit.c,v 1.56 2015/01/16 06:40:11 deraadt Exp $ */
/* OpenBSD S/Key (skeyinit.c)
*
@@ -12,7 +12,6 @@
* S/Key initialization and seed update
*/
-#include <sys/param.h>
#include <sys/file.h>
#include <sys/resource.h>
#include <sys/stat.h>
@@ -29,6 +28,7 @@
#include <syslog.h>
#include <time.h>
#include <unistd.h>
+#include <limits.h>
#include <utmp.h>
#include <skey.h>
@@ -48,7 +48,7 @@ int
main(int argc, char **argv)
{
int rval, i, l, n, defaultsetup, rmkey, hexmode, enable, convert;
- char hostname[MAXHOSTNAMELEN];
+ char hostname[HOST_NAME_MAX+1];
char seed[SKEY_MAX_SEED_LEN + 1];
char buf[256], key[SKEY_BINKEY_SIZE], filename[PATH_MAX], *ht;
char lastc, me[UT_NAMESIZE + 1], *p, *auth_type;
diff --git a/usr.bin/sndiod/sndiod.c b/usr.bin/sndiod/sndiod.c
index 6f9ec02e079..b108ef2e7f8 100644
--- a/usr.bin/sndiod/sndiod.c
+++ b/usr.bin/sndiod/sndiod.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sndiod.c,v 1.6 2014/03/05 20:24:16 ratchov Exp $ */
+/* $OpenBSD: sndiod.c,v 1.7 2015/01/16 06:40:12 deraadt Exp $ */
/*
* Copyright (c) 2008-2012 Alexandre Ratchov <alex@caoua.org>
*
@@ -14,7 +14,6 @@
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
-#include <sys/param.h>
#include <sys/queue.h>
#include <sys/stat.h>
#include <sys/types.h>
diff --git a/usr.bin/sort/msort.c b/usr.bin/sort/msort.c
index e70de031f73..45fe75df0e4 100644
--- a/usr.bin/sort/msort.c
+++ b/usr.bin/sort/msort.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: msort.c,v 1.24 2013/11/13 15:07:27 deraadt Exp $ */
+/* $OpenBSD: msort.c,v 1.25 2015/01/16 06:40:12 deraadt Exp $ */
/*-
* Copyright (c) 1993
@@ -32,6 +32,8 @@
* SUCH DAMAGE.
*/
+#include <sys/param.h> /* ALIGN */
+
#include "sort.h"
#include "fsort.h"
diff --git a/usr.bin/sort/sort.h b/usr.bin/sort/sort.h
index 59baea59d50..e06618b10f4 100644
--- a/usr.bin/sort/sort.h
+++ b/usr.bin/sort/sort.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: sort.h,v 1.7 2007/08/21 20:29:25 millert Exp $ */
+/* $OpenBSD: sort.h,v 1.8 2015/01/16 06:40:12 deraadt Exp $ */
/*-
* Copyright (c) 1993
@@ -34,8 +34,6 @@
* @(#)sort.h 8.1 (Berkeley) 6/6/93
*/
-#include <sys/param.h>
-
#include <db.h>
#include <err.h>
#include <errno.h>
diff --git a/usr.bin/sort/tmp.c b/usr.bin/sort/tmp.c
index b772580b1a8..fd1f63be301 100644
--- a/usr.bin/sort/tmp.c
+++ b/usr.bin/sort/tmp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: tmp.c,v 1.9 2009/10/27 23:59:43 deraadt Exp $ */
+/* $OpenBSD: tmp.c,v 1.10 2015/01/16 06:40:12 deraadt Exp $ */
/*-
* Copyright (c) 1993
@@ -32,8 +32,6 @@
* SUCH DAMAGE.
*/
-#include <sys/param.h>
-
#include <err.h>
#include <errno.h>
#include <limits.h>
diff --git a/usr.bin/spell/spellprog.c b/usr.bin/spell/spellprog.c
index 8ed8337a108..ce086979641 100644
--- a/usr.bin/spell/spellprog.c
+++ b/usr.bin/spell/spellprog.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: spellprog.c,v 1.8 2014/05/20 01:25:23 guenther Exp $ */
+/* $OpenBSD: spellprog.c,v 1.9 2015/01/16 06:40:12 deraadt Exp $ */
/*
* Copyright (c) 1991, 1993
@@ -64,7 +64,6 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#include <sys/param.h>
#include <sys/mman.h>
#include <sys/stat.h>
diff --git a/usr.bin/split/split.c b/usr.bin/split/split.c
index 6231e8ffa1a..27a75d5c449 100644
--- a/usr.bin/split/split.c
+++ b/usr.bin/split/split.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: split.c,v 1.17 2009/10/27 23:59:43 deraadt Exp $ */
+/* $OpenBSD: split.c,v 1.18 2015/01/16 06:40:12 deraadt Exp $ */
/* $NetBSD: split.c,v 1.5 1995/08/31 22:22:05 jtc Exp $ */
/*
@@ -30,7 +30,7 @@
* SUCH DAMAGE.
*/
-#include <sys/param.h>
+#include <sys/param.h> /* MAXBSIZE */
#include <sys/types.h>
#include <ctype.h>
@@ -51,7 +51,7 @@ long numlines; /* Line count to split on. */
int file_open; /* If a file open. */
int ifd = -1, ofd = -1; /* Input/output file descriptors. */
char bfr[MAXBSIZE]; /* I/O buffer. */
-char fname[MAXPATHLEN]; /* File name prefix. */
+char fname[PATH_MAX]; /* File name prefix. */
regex_t rgx;
int pflag;
int sufflen = 2; /* File name suffix length. */
diff --git a/usr.bin/ssh/atomicio.c b/usr.bin/ssh/atomicio.c
index f1269678f54..4a391958aa5 100644
--- a/usr.bin/ssh/atomicio.c
+++ b/usr.bin/ssh/atomicio.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: atomicio.c,v 1.26 2010/09/22 22:58:51 djm Exp $ */
+/* $OpenBSD: atomicio.c,v 1.27 2015/01/16 06:40:12 deraadt Exp $ */
/*
* Copyright (c) 2006 Damien Miller. All rights reserved.
* Copyright (c) 2005 Anil Madhavapeddy. All rights reserved.
@@ -26,13 +26,13 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include <sys/param.h>
#include <sys/uio.h>
#include <errno.h>
#include <poll.h>
#include <string.h>
#include <unistd.h>
+#include <limits.h>
#include "atomicio.h"
diff --git a/usr.bin/ssh/misc.c b/usr.bin/ssh/misc.c
index 328473903f5..6110a6f8bd9 100644
--- a/usr.bin/ssh/misc.c
+++ b/usr.bin/ssh/misc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: misc.c,v 1.95 2014/10/24 02:01:20 lteo Exp $ */
+/* $OpenBSD: misc.c,v 1.96 2015/01/16 06:40:12 deraadt Exp $ */
/*
* Copyright (c) 2000 Markus Friedl. All rights reserved.
* Copyright (c) 2005,2006 Damien Miller. All rights reserved.
@@ -28,7 +28,6 @@
#include <sys/ioctl.h>
#include <sys/socket.h>
#include <sys/un.h>
-#include <sys/param.h>
#include <net/if.h>
#include <netinet/in.h>
@@ -41,6 +40,7 @@
#include <netdb.h>
#include <paths.h>
#include <pwd.h>
+#include <limits.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
@@ -534,7 +534,7 @@ tilde_expand_filename(const char *filename, uid_t uid)
if (path != NULL)
filename = path + 1;
- if (xasprintf(&ret, "%s%s%s", pw->pw_dir, sep, filename) >= MAXPATHLEN)
+ if (xasprintf(&ret, "%s%s%s", pw->pw_dir, sep, filename) >= PATH_MAX)
fatal("tilde_expand_filename: Path too long");
return (ret);
diff --git a/usr.bin/ssh/readconf.c b/usr.bin/ssh/readconf.c
index 34ff37e6787..eabfa3c739e 100644
--- a/usr.bin/ssh/readconf.c
+++ b/usr.bin/ssh/readconf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: readconf.c,v 1.227 2015/01/15 09:40:00 djm Exp $ */
+/* $OpenBSD: readconf.c,v 1.228 2015/01/16 06:40:12 deraadt Exp $ */
/*
* Author: Tatu Ylonen <ylo@cs.hut.fi>
* Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
@@ -31,6 +31,7 @@
#include <stdio.h>
#include <string.h>
#include <unistd.h>
+#include <limits.h>
#include <util.h>
#include <vis.h>
diff --git a/usr.bin/ssh/scp.c b/usr.bin/ssh/scp.c
index 52b0a20c5e9..52d02ebc8d8 100644
--- a/usr.bin/ssh/scp.c
+++ b/usr.bin/ssh/scp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: scp.c,v 1.180 2014/06/24 02:21:01 djm Exp $ */
+/* $OpenBSD: scp.c,v 1.181 2015/01/16 06:40:12 deraadt Exp $ */
/*
* scp - secure remote copy. This is basically patched BSD rcp which
* uses ssh to do the data transfer (instead of using rcmd).
@@ -71,7 +71,7 @@
*
*/
-#include <sys/param.h>
+#include <sys/param.h> /* roundup MAX */
#include <sys/types.h>
#include <sys/poll.h>
#include <sys/wait.h>
@@ -91,6 +91,7 @@
#include <string.h>
#include <time.h>
#include <unistd.h>
+#include <limits.h>
#include <vis.h>
#include "xmalloc.h"
@@ -728,7 +729,7 @@ source(int argc, char **argv)
off_t i, statbytes;
size_t amt, nr;
int fd = -1, haderr, indx;
- char *last, *name, buf[2048], encname[MAXPATHLEN];
+ char *last, *name, buf[2048], encname[PATH_MAX];
int len;
for (indx = 0; indx < argc; ++indx) {
@@ -837,7 +838,7 @@ rsource(char *name, struct stat *statp)
{
DIR *dirp;
struct dirent *dp;
- char *last, *vect[1], path[MAXPATHLEN];
+ char *last, *vect[1], path[PATH_MAX];
if (!(dirp = opendir(name))) {
run_err("%s: %s", name, strerror(errno));
diff --git a/usr.bin/ssh/servconf.c b/usr.bin/ssh/servconf.c
index f36cc9c352e..d6304fb2a80 100644
--- a/usr.bin/ssh/servconf.c
+++ b/usr.bin/ssh/servconf.c
@@ -1,5 +1,5 @@
-/* $OpenBSD: servconf.c,v 1.258 2015/01/13 07:39:19 djm Exp $ */
+/* $OpenBSD: servconf.c,v 1.259 2015/01/16 06:40:12 deraadt Exp $ */
/*
* Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
* All rights reserved
@@ -26,6 +26,7 @@
#include <string.h>
#include <signal.h>
#include <unistd.h>
+#include <limits.h>
#include <stdarg.h>
#include <errno.h>
#include <util.h>
@@ -529,7 +530,7 @@ parse_token(const char *cp, const char *filename,
char *
derelativise_path(const char *path)
{
- char *expanded, *ret, cwd[MAXPATHLEN];
+ char *expanded, *ret, cwd[PATH_MAX];
if (strcasecmp(path, "none") == 0)
return xstrdup("none");
diff --git a/usr.bin/ssh/session.c b/usr.bin/ssh/session.c
index 4025bfc03e2..aa7ae456b65 100644
--- a/usr.bin/ssh/session.c
+++ b/usr.bin/ssh/session.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: session.c,v 1.276 2015/01/14 20:05:27 djm Exp $ */
+/* $OpenBSD: session.c,v 1.277 2015/01/16 06:40:12 deraadt Exp $ */
/*
* Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
* All rights reserved
@@ -38,7 +38,6 @@
#include <sys/un.h>
#include <sys/stat.h>
#include <sys/socket.h>
-#include <sys/param.h>
#include <sys/queue.h>
#include <errno.h>
@@ -53,6 +52,7 @@
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
+#include <limits.h>
#include "xmalloc.h"
#include "ssh.h"
@@ -1151,7 +1151,7 @@ static void
safely_chroot(const char *path, uid_t uid)
{
const char *cp;
- char component[MAXPATHLEN];
+ char component[PATH_MAX];
struct stat st;
if (*path != '/')
diff --git a/usr.bin/ssh/ssh-add.c b/usr.bin/ssh/ssh-add.c
index 33b238dd582..9f1101a2c1c 100644
--- a/usr.bin/ssh/ssh-add.c
+++ b/usr.bin/ssh/ssh-add.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ssh-add.c,v 1.116 2015/01/14 20:05:27 djm Exp $ */
+/* $OpenBSD: ssh-add.c,v 1.117 2015/01/16 06:40:12 deraadt Exp $ */
/*
* Author: Tatu Ylonen <ylo@cs.hut.fi>
* Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
@@ -37,7 +37,6 @@
#include <sys/types.h>
#include <sys/stat.h>
-#include <sys/param.h>
#include <openssl/evp.h>
@@ -48,6 +47,7 @@
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
+#include <limits.h>
#include "xmalloc.h"
#include "ssh.h"
@@ -560,7 +560,7 @@ main(int argc, char **argv)
goto done;
}
if (argc == 0) {
- char buf[MAXPATHLEN];
+ char buf[PATH_MAX];
struct passwd *pw;
struct stat st;
int count = 0;
diff --git a/usr.bin/ssh/ssh-agent.c b/usr.bin/ssh/ssh-agent.c
index 30756c31148..e149098ad5d 100644
--- a/usr.bin/ssh/ssh-agent.c
+++ b/usr.bin/ssh/ssh-agent.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ssh-agent.c,v 1.195 2015/01/14 19:33:41 djm Exp $ */
+/* $OpenBSD: ssh-agent.c,v 1.196 2015/01/16 06:40:12 deraadt Exp $ */
/*
* Author: Tatu Ylonen <ylo@cs.hut.fi>
* Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
@@ -34,6 +34,7 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+#include <sys/param.h> /* MIN MAX */
#include <sys/types.h>
#include <sys/time.h>
#include <sys/queue.h>
@@ -41,7 +42,6 @@
#include <sys/socket.h>
#include <sys/stat.h>
#include <sys/un.h>
-#include <sys/param.h>
#ifdef WITH_OPENSSL
#include <openssl/evp.h>
@@ -54,6 +54,7 @@
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
+#include <limits.h>
#include <time.h>
#include <unistd.h>
@@ -120,8 +121,8 @@ time_t parent_alive_interval = 0;
pid_t cleanup_pid = 0;
/* pathname and directory for AUTH_SOCKET */
-char socket_name[MAXPATHLEN];
-char socket_dir[MAXPATHLEN];
+char socket_name[PATH_MAX];
+char socket_dir[PATH_MAX];
/* locking */
int locked = 0;
diff --git a/usr.bin/ssh/ssh-keygen.c b/usr.bin/ssh/ssh-keygen.c
index f90a600f876..d1337927b4b 100644
--- a/usr.bin/ssh/ssh-keygen.c
+++ b/usr.bin/ssh/ssh-keygen.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ssh-keygen.c,v 1.252 2015/01/15 09:40:00 djm Exp $ */
+/* $OpenBSD: ssh-keygen.c,v 1.253 2015/01/16 06:40:12 deraadt Exp $ */
/*
* Author: Tatu Ylonen <ylo@cs.hut.fi>
* Copyright (c) 1994 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
@@ -15,7 +15,6 @@
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/stat.h>
-#include <sys/param.h>
#include <openssl/evp.h>
#include <openssl/pem.h>
@@ -28,6 +27,7 @@
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
+#include <limits.h>
#include "xmalloc.h"
#include "sshkey.h"
@@ -1047,7 +1047,7 @@ do_known_hosts(struct passwd *pw, const char *name)
FILE *in, *out = stdout;
struct sshkey *pub;
char *cp, *cp2, *kp, *kp2;
- char line[16*1024], tmp[MAXPATHLEN], old[MAXPATHLEN];
+ char line[16*1024], tmp[PATH_MAX], old[PATH_MAX];
int c, skip = 0, inplace = 0, num = 0, invalid = 0, has_unhashed = 0;
int r, ca, revoked;
int found_key = 0;
@@ -2275,9 +2275,9 @@ usage(void)
int
main(int argc, char **argv)
{
- char dotsshdir[MAXPATHLEN], comment[1024], *passphrase1, *passphrase2;
+ char dotsshdir[PATH_MAX], comment[1024], *passphrase1, *passphrase2;
char *checkpoint = NULL;
- char out_file[MAXPATHLEN], *rr_hostname = NULL, *ep;
+ char out_file[PATH_MAX], *rr_hostname = NULL, *ep;
struct sshkey *private, *public;
struct passwd *pw;
struct stat st;
@@ -2490,7 +2490,7 @@ main(int argc, char **argv)
fatal("Output filename too long");
break;
case 'K':
- if (strlen(optarg) >= MAXPATHLEN)
+ if (strlen(optarg) >= PATH_MAX)
fatal("Checkpoint filename too long");
checkpoint = xstrdup(optarg);
break;
diff --git a/usr.bin/ssh/sshkey.c b/usr.bin/ssh/sshkey.c
index 8359bd5aaf3..0745fde7125 100644
--- a/usr.bin/ssh/sshkey.c
+++ b/usr.bin/ssh/sshkey.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sshkey.c,v 1.12 2015/01/14 10:46:28 djm Exp $ */
+/* $OpenBSD: sshkey.c,v 1.13 2015/01/16 06:40:12 deraadt Exp $ */
/*
* Copyright (c) 2000, 2001 Markus Friedl. All rights reserved.
* Copyright (c) 2008 Alexander von Gernler. All rights reserved.
@@ -25,7 +25,7 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include <sys/param.h>
+#include <sys/param.h> /* MIN MAX */
#include <sys/types.h>
#include <netinet/in.h>
@@ -41,6 +41,7 @@
#include <stdio.h>
#include <string.h>
#include <util.h>
+#include <limits.h>
#include <resolv.h>
#include "ssh2.h"
diff --git a/usr.bin/ssh/sshlogin.c b/usr.bin/ssh/sshlogin.c
index 0f646cf42e6..e39b1147599 100644
--- a/usr.bin/ssh/sshlogin.c
+++ b/usr.bin/ssh/sshlogin.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sshlogin.c,v 1.29 2014/07/15 15:54:14 millert Exp $ */
+/* $OpenBSD: sshlogin.c,v 1.30 2015/01/16 06:40:12 deraadt Exp $ */
/*
* Author: Tatu Ylonen <ylo@cs.hut.fi>
* Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
@@ -40,7 +40,7 @@
*/
#include <sys/types.h>
-#include <sys/param.h>
+#include <sys/param.h> /* MAXHOSTNAMELEN */
#include <sys/socket.h>
#include <errno.h>
diff --git a/usr.bin/ssh/uidswap.c b/usr.bin/ssh/uidswap.c
index dc8b191b49a..e9dee64578a 100644
--- a/usr.bin/ssh/uidswap.c
+++ b/usr.bin/ssh/uidswap.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: uidswap.c,v 1.36 2013/11/08 11:15:19 dtucker Exp $ */
+/* $OpenBSD: uidswap.c,v 1.37 2015/01/16 06:40:12 deraadt Exp $ */
/*
* Author: Tatu Ylonen <ylo@cs.hut.fi>
* Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
@@ -12,11 +12,11 @@
* called by a name other than "ssh" or "Secure Shell".
*/
-#include <sys/param.h>
#include <errno.h>
#include <pwd.h>
#include <string.h>
#include <unistd.h>
+#include <limits.h>
#include <stdarg.h>
#include <stdlib.h>
diff --git a/usr.bin/ssh/xmalloc.c b/usr.bin/ssh/xmalloc.c
index c6bd95973a6..a85acb7a566 100644
--- a/usr.bin/ssh/xmalloc.c
+++ b/usr.bin/ssh/xmalloc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: xmalloc.c,v 1.29 2014/01/04 17:50:55 tedu Exp $ */
+/* $OpenBSD: xmalloc.c,v 1.30 2015/01/16 06:40:12 deraadt Exp $ */
/*
* Author: Tatu Ylonen <ylo@cs.hut.fi>
* Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
@@ -13,11 +13,11 @@
* called by a name other than "ssh" or "Secure Shell".
*/
-#include <sys/param.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <limits.h>
#include "xmalloc.h"
#include "log.h"
diff --git a/usr.bin/su/su.c b/usr.bin/su/su.c
index b7f821990c2..b6869bccd62 100644
--- a/usr.bin/su/su.c
+++ b/usr.bin/su/su.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: su.c,v 1.65 2011/01/11 10:07:56 robert Exp $ */
+/* $OpenBSD: su.c,v 1.66 2015/01/16 06:40:13 deraadt Exp $ */
/*
* Copyright (c) 1988 The Regents of the University of California.
@@ -29,7 +29,6 @@
* SUCH DAMAGE.
*/
-#include <sys/param.h>
#include <sys/time.h>
#include <sys/resource.h>
@@ -44,6 +43,7 @@
#include <string.h>
#include <syslog.h>
#include <unistd.h>
+#include <limits.h>
#include <utmp.h>
#include <stdarg.h>
#include <bsd_auth.h>
@@ -65,7 +65,7 @@ main(int argc, char **argv)
char *user, *shell = NULL, *avshell, *username, **np;
char *class = NULL, *style = NULL, *p;
enum { UNSET, YES, NO } iscsh = UNSET;
- char avshellbuf[MAXPATHLEN];
+ char avshellbuf[PATH_MAX];
extern char **environ;
auth_session_t *as;
struct passwd *pwd;
@@ -395,7 +395,7 @@ chshell(const char *sh)
char *
ontty(void)
{
- static char buf[MAXPATHLEN + 4];
+ static char buf[PATH_MAX + 4];
char *p;
buf[0] = 0;
diff --git a/usr.bin/talk/get_names.c b/usr.bin/talk/get_names.c
index caf98634894..c4cd1d2858f 100644
--- a/usr.bin/talk/get_names.c
+++ b/usr.bin/talk/get_names.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: get_names.c,v 1.19 2010/08/12 23:31:29 tedu Exp $ */
+/* $OpenBSD: get_names.c,v 1.20 2015/01/16 06:40:13 deraadt Exp $ */
/* $NetBSD: get_names.c,v 1.4 1994/12/09 02:14:16 jtc Exp $ */
/*
@@ -31,10 +31,10 @@
*/
#include "talk.h"
-#include <sys/param.h>
#include <pwd.h>
#include <stdlib.h>
#include <unistd.h>
+#include <limits.h>
extern CTL_MSG msg;
@@ -44,7 +44,7 @@ extern CTL_MSG msg;
void
get_names(int argc, char *argv[])
{
- char hostname[MAXHOSTNAMELEN];
+ char hostname[HOST_NAME_MAX+1];
char *his_name, *my_name;
char *my_machine_name, *his_machine_name;
char *his_tty;
diff --git a/usr.bin/telnet/commands.c b/usr.bin/telnet/commands.c
index 2799f161f47..64c6e8cde8e 100644
--- a/usr.bin/telnet/commands.c
+++ b/usr.bin/telnet/commands.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: commands.c,v 1.70 2014/09/09 03:41:08 guenther Exp $ */
+/* $OpenBSD: commands.c,v 1.71 2015/01/16 06:40:13 deraadt Exp $ */
/* $NetBSD: commands.c,v 1.14 1996/03/24 22:03:48 jtk Exp $ */
/*
@@ -47,6 +47,7 @@
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
+#include <limits.h>
#ifdef SKEY
#include <sys/wait.h>
@@ -1544,7 +1545,7 @@ env_init(void)
if ((ep = env_find("DISPLAY"))
&& ((*ep->value == ':')
|| (strncmp(ep->value, "unix:", 5) == 0))) {
- char hbuf[MAXHOSTNAMELEN];
+ char hbuf[HOST_NAME_MAX+1];
char *cp2 = strchr(ep->value, ':');
gethostname(hbuf, sizeof hbuf);
@@ -1774,7 +1775,7 @@ cmdrc(char *m1, char *m2)
int gotmachine = 0;
int l1 = strlen(m1);
int l2 = strlen(m2);
- char m1save[MAXHOSTNAMELEN];
+ char m1save[HOST_NAME_MAX+1];
if (skiprc)
return;
diff --git a/usr.bin/tftp/main.c b/usr.bin/tftp/main.c
index debf8dfcca8..68a6d4b6f1a 100644
--- a/usr.bin/tftp/main.c
+++ b/usr.bin/tftp/main.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: main.c,v 1.34 2013/11/26 21:08:12 deraadt Exp $ */
+/* $OpenBSD: main.c,v 1.35 2015/01/16 06:40:13 deraadt Exp $ */
/* $NetBSD: main.c,v 1.6 1995/05/21 16:54:10 mycroft Exp $ */
/*
@@ -36,7 +36,6 @@
* This version includes many modifications by Jim Guyton <guyton@rand-unix>
*/
-#include <sys/param.h>
#include <sys/socket.h>
#include <sys/file.h>
@@ -54,6 +53,7 @@
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
+#include <limits.h>
#include "extern.h"
@@ -100,7 +100,7 @@ char *prompt = "tftp";
void intr(int);
int rexmtval = TIMEOUT;
int maxtimeout = 5 * TIMEOUT;
-char hostname[MAXHOSTNAMELEN];
+char hostname[HOST_NAME_MAX+1];
FILE *file = NULL;
volatile sig_atomic_t intrflag = 0;
char *ackbuf;
diff --git a/usr.bin/tic/progs.priv.h b/usr.bin/tic/progs.priv.h
index 0795db553e3..1499fabddf2 100644
--- a/usr.bin/tic/progs.priv.h
+++ b/usr.bin/tic/progs.priv.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: progs.priv.h,v 1.9 2010/01/12 23:22:14 nicm Exp $ */
+/* $OpenBSD: progs.priv.h,v 1.10 2015/01/16 06:40:13 deraadt Exp $ */
/****************************************************************************
* Copyright (c) 1998-2007,2008 Free Software Foundation, Inc. *
@@ -32,7 +32,7 @@
* Author: Thomas E. Dickey 1997-on *
****************************************************************************/
/*
- * $Id: progs.priv.h,v 1.9 2010/01/12 23:22:14 nicm Exp $
+ * $Id: progs.priv.h,v 1.10 2015/01/16 06:40:13 deraadt Exp $
*
* progs.priv.h
*
@@ -63,7 +63,7 @@
#if HAVE_LIMITS_H
# include <limits.h>
#elif HAVE_SYS_PARAM_H
-# include <sys/param.h>
+# include <sys/param.h> /* only if no limits.h */
#endif
#if HAVE_DIRENT_H
diff --git a/usr.bin/time/time.c b/usr.bin/time/time.c
index b6b77cfe84b..e18653d537d 100644
--- a/usr.bin/time/time.c
+++ b/usr.bin/time/time.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: time.c,v 1.19 2013/04/16 23:43:00 deraadt Exp $ */
+/* $OpenBSD: time.c,v 1.20 2015/01/16 06:40:13 deraadt Exp $ */
/* $NetBSD: time.c,v 1.7 1995/06/27 00:34:00 jtc Exp $ */
/*
@@ -30,7 +30,6 @@
* SUCH DAMAGE.
*/
-#include <sys/param.h>
#include <sys/time.h>
#include <sys/resource.h>
#include <sys/wait.h>
diff --git a/usr.bin/tmux/procname.c b/usr.bin/tmux/procname.c
index aeaf0fa49a3..3b6081c09c0 100644
--- a/usr.bin/tmux/procname.c
+++ b/usr.bin/tmux/procname.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: procname.c,v 1.13 2014/07/04 05:58:31 guenther Exp $ */
+/* $OpenBSD: procname.c,v 1.14 2015/01/16 06:40:13 deraadt Exp $ */
/*
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -16,7 +16,8 @@
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
-#include <sys/param.h>
+#include <sys/param.h> /* MAXCOMLEN */
+#include <sys/types.h>
#include <sys/proc.h>
#include <sys/sysctl.h>
#include <sys/stat.h>
diff --git a/usr.bin/top/machine.c b/usr.bin/top/machine.c
index 44d0e1ebe3a..fc87693b614 100644
--- a/usr.bin/top/machine.c
+++ b/usr.bin/top/machine.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: machine.c,v 1.80 2014/09/17 01:56:54 dlg Exp $ */
+/* $OpenBSD: machine.c,v 1.81 2015/01/16 06:40:13 deraadt Exp $ */
/*-
* Copyright (c) 1994 Thorsten Lockert <tholo@sigmasoft.com>
@@ -33,8 +33,9 @@
* Patch for new swapctl(2) by Tobias Weingartner <weingart@openbsd.org>
*/
+#include <sys/param.h> /* DEV_BSIZE MAXCOMLEN PZERO */
#include <sys/types.h>
-#include <sys/param.h>
+#include <sys/signal.h>
#include <sys/mount.h>
#include <sys/proc.h>
#include <sys/sched.h>
diff --git a/usr.bin/top/utils.c b/usr.bin/top/utils.c
index 3eaef986555..7e33cdead4a 100644
--- a/usr.bin/top/utils.c
+++ b/usr.bin/top/utils.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: utils.c,v 1.24 2013/04/02 06:04:50 guenther Exp $ */
+/* $OpenBSD: utils.c,v 1.25 2015/01/16 06:40:13 deraadt Exp $ */
/*
* Top users/processes display for Unix
@@ -32,13 +32,14 @@
* This file contains various handy utilities used by top.
*/
-#include <sys/param.h>
+#include <sys/types.h>
#include <sys/sysctl.h>
#include <err.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdint.h>
+#include <limits.h>
#include "top.h"
#include "machine.h"
diff --git a/usr.bin/tput/tput.c b/usr.bin/tput/tput.c
index 84bafe6e787..fbe7f672fab 100644
--- a/usr.bin/tput/tput.c
+++ b/usr.bin/tput/tput.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: tput.c,v 1.20 2014/10/08 04:10:47 doug Exp $ */
+/* $OpenBSD: tput.c,v 1.21 2015/01/16 06:40:13 deraadt Exp $ */
/*
* Copyright (c) 1999 Todd C. Miller <Todd.Miller@courtesan.com>
@@ -44,8 +44,6 @@
* SUCH DAMAGE.
*/
-#include <sys/param.h>
-
#include <ctype.h>
#include <err.h>
#include <curses.h>
@@ -54,8 +52,11 @@
#include <stdlib.h>
#include <termios.h>
#include <unistd.h>
+#include <limits.h>
#include <string.h>
+#define MAXIMUM(a, b) (((a) > (b)) ? (a) : (b))
+
#include <sys/wait.h>
static void init(void);
@@ -229,7 +230,7 @@ process(char *cap, char *str, char **argv)
}
}
}
- arg_need = MAX(arg_need, popcount);
+ arg_need = MAXIMUM(arg_need, popcount);
if (arg_need > 9)
errx(2, "too many arguments (%d) for capability `%s'",
arg_need, cap);
diff --git a/usr.bin/uname/uname.c b/usr.bin/uname/uname.c
index 674ff10c135..d9b1821946c 100644
--- a/usr.bin/uname/uname.c
+++ b/usr.bin/uname/uname.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: uname.c,v 1.12 2011/10/21 14:48:02 ajacoutot Exp $ */
+/* $OpenBSD: uname.c,v 1.13 2015/01/16 06:40:13 deraadt Exp $ */
/*
* Copyright (c) 1994 Winning Strategies, Inc.
@@ -31,7 +31,7 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include <sys/param.h>
+#include <sys/param.h> /* MACHINE_ARCH */
#include <stdio.h>
#include <stdlib.h>
#include <locale.h>
diff --git a/usr.bin/uudecode/uudecode.c b/usr.bin/uudecode/uudecode.c
index 2b03e6ef615..65801e1093b 100644
--- a/usr.bin/uudecode/uudecode.c
+++ b/usr.bin/uudecode/uudecode.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: uudecode.c,v 1.19 2014/05/20 01:25:23 guenther Exp $ */
+/* $OpenBSD: uudecode.c,v 1.20 2015/01/16 06:40:13 deraadt Exp $ */
/* $FreeBSD: uudecode.c,v 1.49 2003/05/03 19:44:46 obrien Exp $ */
/*-
@@ -35,7 +35,6 @@
* Used with uuencode.
*/
-#include <sys/param.h>
#include <sys/socket.h>
#include <sys/stat.h>
@@ -51,6 +50,7 @@
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
+#include <limits.h>
static const char *infile, *outfile;
static FILE *infp, *outfp;
@@ -182,7 +182,7 @@ decode2(void)
void *handle;
struct passwd *pw;
struct stat st;
- char buf[MAXPATHLEN];
+ char buf[PATH_MAX];
base64 = 0;
/* search for header line */
@@ -334,7 +334,7 @@ uu_decode(void)
{
int i, ch;
char *p;
- char buf[MAXPATHLEN];
+ char buf[PATH_MAX];
/* for each input line */
for (;;) {
@@ -412,8 +412,8 @@ static int
base64_decode(void)
{
int n;
- char inbuf[MAXPATHLEN];
- unsigned char outbuf[MAXPATHLEN * 4];
+ char inbuf[PATH_MAX];
+ unsigned char outbuf[PATH_MAX * 4];
for (;;) {
switch (get_line(inbuf, sizeof(inbuf))) {
diff --git a/usr.bin/uuencode/uuencode.c b/usr.bin/uuencode/uuencode.c
index ccce77bf7a5..6e203fb456c 100644
--- a/usr.bin/uuencode/uuencode.c
+++ b/usr.bin/uuencode/uuencode.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: uuencode.c,v 1.10 2009/10/27 23:59:46 deraadt Exp $ */
+/* $OpenBSD: uuencode.c,v 1.11 2015/01/16 06:40:13 deraadt Exp $ */
/* $FreeBSD: uuencode.c,v 1.18 2004/01/22 07:23:35 grehan Exp $ */
/*-
@@ -34,7 +34,6 @@
* Encode a file so it can be mailed to a remote system.
*/
-#include <sys/param.h>
#include <sys/socket.h>
#include <sys/stat.h>
diff --git a/usr.bin/vacation/vacation.c b/usr.bin/vacation/vacation.c
index 4f3e185effe..44611c1b8f9 100644
--- a/usr.bin/vacation/vacation.c
+++ b/usr.bin/vacation/vacation.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: vacation.c,v 1.34 2013/11/26 19:25:39 deraadt Exp $ */
+/* $OpenBSD: vacation.c,v 1.35 2015/01/16 06:40:13 deraadt Exp $ */
/* $NetBSD: vacation.c,v 1.7 1995/04/29 05:58:27 cgd Exp $ */
/*
@@ -36,7 +36,6 @@
** Berkeley, California
*/
-#include <sys/param.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <pwd.h>
diff --git a/usr.bin/vi/common/exf.c b/usr.bin/vi/common/exf.c
index c7aefb308ae..044e3cf01e0 100644
--- a/usr.bin/vi/common/exf.c
+++ b/usr.bin/vi/common/exf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: exf.c,v 1.32 2014/11/14 20:23:56 tedu Exp $ */
+/* $OpenBSD: exf.c,v 1.33 2015/01/16 06:40:14 deraadt Exp $ */
/*-
* Copyright (c) 1992, 1993, 1994
@@ -11,7 +11,6 @@
#include "config.h"
-#include <sys/param.h>
#include <sys/queue.h>
#include <sys/stat.h>
@@ -123,7 +122,7 @@ file_init(SCR *sp, FREF *frp, char *rcv_name, int flags)
struct stat sb;
size_t psize;
int fd, exists, open_err, readonly;
- char *oname, tname[MAXPATHLEN];
+ char *oname, tname[PATH_MAX];
open_err = readonly = 0;
@@ -450,7 +449,7 @@ file_spath(SCR *sp, FREF *frp, struct stat *sbp, int *existsp)
CHAR_T savech;
size_t len;
int found;
- char *name, *p, *t, path[MAXPATHLEN];
+ char *name, *p, *t, path[PATH_MAX];
/*
* If the name is NULL or an explicit reference (i.e., the first
@@ -738,7 +737,7 @@ file_write(SCR *sp, MARK *fm, MARK *tm, char *name, int flags)
size_t len;
u_long nlno, nch;
int fd, nf, noname, oflags, rval;
- char *p, *s, *t, buf[MAXPATHLEN + 64];
+ char *p, *s, *t, buf[PATH_MAX + 64];
const char *msgstr;
ep = sp->ep;
diff --git a/usr.bin/vi/common/key.c b/usr.bin/vi/common/key.c
index dd3101c9bd1..63421dd75d1 100644
--- a/usr.bin/vi/common/key.c
+++ b/usr.bin/vi/common/key.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: key.c,v 1.13 2014/11/12 04:28:41 bentley Exp $ */
+/* $OpenBSD: key.c,v 1.14 2015/01/16 06:40:14 deraadt Exp $ */
/*-
* Copyright (c) 1991, 1993, 1994
@@ -11,7 +11,6 @@
#include "config.h"
-#include <sys/param.h>
#include <sys/queue.h>
#include <sys/time.h>
@@ -28,6 +27,8 @@
#include "common.h"
#include "../vi/vi.h"
+#define MAXIMUM(a, b) (((a) > (b)) ? (a) : (b))
+
static int v_event_append(SCR *, EVENT *);
static int v_event_grow(SCR *, int);
static int v_key_cmp(const void *, const void *);
@@ -344,7 +345,7 @@ v_event_push(SCR *sp, EVENT *p_evp, CHAR_T *p_s, size_t nitems, u_int flags)
*/
#define TERM_PUSH_SHIFT 30
total = gp->i_cnt + gp->i_next + nitems + TERM_PUSH_SHIFT;
- if (total >= gp->i_nelem && v_event_grow(sp, MAX(total, 64)))
+ if (total >= gp->i_nelem && v_event_grow(sp, MAXIMUM(total, 64)))
return (1);
if (gp->i_cnt)
MEMMOVE(gp->i_event + TERM_PUSH_SHIFT + nitems,
@@ -383,7 +384,7 @@ v_event_append(SCR *sp, EVENT *argp)
gp = sp->gp;
if (gp->i_event == NULL ||
nevents > gp->i_nelem - (gp->i_next + gp->i_cnt))
- v_event_grow(sp, MAX(nevents, 64));
+ v_event_grow(sp, MAXIMUM(nevents, 64));
evp = gp->i_event + gp->i_next + gp->i_cnt;
gp->i_cnt += nevents;
diff --git a/usr.bin/vi/common/msg.c b/usr.bin/vi/common/msg.c
index 8ea5b983307..147311b173e 100644
--- a/usr.bin/vi/common/msg.c
+++ b/usr.bin/vi/common/msg.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: msg.c,v 1.21 2014/11/12 16:29:04 millert Exp $ */
+/* $OpenBSD: msg.c,v 1.22 2015/01/16 06:40:14 deraadt Exp $ */
/*-
* Copyright (c) 1991, 1993, 1994
@@ -11,7 +11,6 @@
#include "config.h"
-#include <sys/param.h>
#include <sys/queue.h>
#include <sys/stat.h>
#include <sys/time.h>
@@ -519,7 +518,7 @@ msg_open(SCR *sp, char *file)
DB *db;
DBT data, key;
recno_t msgno;
- char *p, *t, buf[MAXPATHLEN];
+ char *p, *t, buf[PATH_MAX];
if ((p = strrchr(file, '/')) != NULL && p[1] == '\0' &&
(((t = getenv("LC_MESSAGES")) != NULL && t[0] != '\0') ||
diff --git a/usr.bin/vi/common/recover.c b/usr.bin/vi/common/recover.c
index b66dfd225ba..6c95cd1479b 100644
--- a/usr.bin/vi/common/recover.c
+++ b/usr.bin/vi/common/recover.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: recover.c,v 1.19 2014/11/14 20:27:03 tedu Exp $ */
+/* $OpenBSD: recover.c,v 1.20 2015/01/16 06:40:14 deraadt Exp $ */
/*-
* Copyright (c) 1993, 1994
@@ -11,7 +11,6 @@
#include "config.h"
-#include <sys/param.h>
#include <sys/queue.h>
#include <sys/stat.h>
@@ -123,7 +122,7 @@ rcv_tmp(SCR *sp, EXF *ep, char *name)
{
struct stat sb;
int fd;
- char *dp, *p, path[MAXPATHLEN];
+ char *dp, *p, path[PATH_MAX];
/*
* !!!
@@ -327,9 +326,9 @@ rcv_mailfile(SCR *sp, int issync, char *cp_path)
time_t now;
uid_t uid;
int fd;
- char *dp, *p, *t, buf[4096], mpath[MAXPATHLEN];
+ char *dp, *p, *t, buf[4096], mpath[PATH_MAX];
char *t1, *t2, *t3;
- char host[MAXHOSTNAMELEN];
+ char host[HOST_NAME_MAX+1];
gp = sp->gp;
if ((pw = getpwuid(uid = getuid())) == NULL) {
@@ -475,7 +474,7 @@ rcv_list(SCR *sp)
DIR *dirp;
FILE *fp;
int found;
- char *p, *t, file[MAXPATHLEN], path[MAXPATHLEN];
+ char *p, *t, file[PATH_MAX], path[PATH_MAX];
/* Open the recovery directory for reading. */
if (opts_empty(sp, O_RECDIR, 0))
@@ -579,7 +578,7 @@ rcv_read(SCR *sp, FREF *frp)
time_t rec_mtime;
int fd, found, locked, requested, sv_fd;
char *name, *p, *t, *rp, *recp, *pathp;
- char file[MAXPATHLEN], path[MAXPATHLEN], recpath[MAXPATHLEN];
+ char file[PATH_MAX], path[PATH_MAX], recpath[PATH_MAX];
if (opts_empty(sp, O_RECDIR, 0))
return (1);
@@ -828,7 +827,7 @@ static void
rcv_email(SCR *sp, char *fname)
{
struct stat sb;
- char buf[MAXPATHLEN * 2 + 20];
+ char buf[PATH_MAX * 2 + 20];
if (_PATH_SENDMAIL[0] != '/' || stat(_PATH_SENDMAIL, &sb))
msgq_str(sp, M_SYSERR,
diff --git a/usr.bin/vi/common/seq.c b/usr.bin/vi/common/seq.c
index 183b11fe517..9eb933fdc85 100644
--- a/usr.bin/vi/common/seq.c
+++ b/usr.bin/vi/common/seq.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: seq.c,v 1.9 2014/11/12 04:28:41 bentley Exp $ */
+/* $OpenBSD: seq.c,v 1.10 2015/01/16 06:40:14 deraadt Exp $ */
/*-
* Copyright (c) 1992, 1993, 1994
@@ -11,7 +11,6 @@
#include "config.h"
-#include <sys/param.h>
#include <sys/queue.h>
#include <bitstring.h>
@@ -24,6 +23,8 @@
#include "common.h"
+#define MINIMUM(a, b) (((a) < (b)) ? (a) : (b))
+
/*
* seq_set --
* Internal version to enter a sequence.
@@ -195,7 +196,7 @@ seq_find(SCR *sp, SEQ **lastqp, EVENT *e_input, CHAR_T *c_input, size_t ilen,
if (qp->input[0] < c_input[0] ||
qp->stype != stype || F_ISSET(qp, SEQ_FUNCMAP))
continue;
- diff = memcmp(qp->input, c_input, MIN(qp->ilen, ilen));
+ diff = memcmp(qp->input, c_input, MINIMUM(qp->ilen, ilen));
} else {
if (qp->input[0] > e_input->e_c)
break;
@@ -203,7 +204,7 @@ seq_find(SCR *sp, SEQ **lastqp, EVENT *e_input, CHAR_T *c_input, size_t ilen,
qp->stype != stype || F_ISSET(qp, SEQ_FUNCMAP))
continue;
diff =
- e_memcmp(qp->input, e_input, MIN(qp->ilen, ilen));
+ e_memcmp(qp->input, e_input, MINIMUM(qp->ilen, ilen));
}
if (diff > 0)
break;
diff --git a/usr.bin/vi/common/util.c b/usr.bin/vi/common/util.c
index d69bbbc0bae..c02210a2645 100644
--- a/usr.bin/vi/common/util.c
+++ b/usr.bin/vi/common/util.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: util.c,v 1.9 2014/11/12 04:28:41 bentley Exp $ */
+/* $OpenBSD: util.c,v 1.10 2015/01/16 06:40:14 deraadt Exp $ */
/*-
* Copyright (c) 1991, 1993, 1994
@@ -11,7 +11,6 @@
#include "config.h"
-#include <sys/param.h>
#include <sys/queue.h>
#include <bitstring.h>
@@ -24,6 +23,8 @@
#include "common.h"
+#define MAXIMUM(a, b) (((a) > (b)) ? (a) : (b))
+
/*
* binc --
* Increase the size of a buffer.
@@ -39,7 +40,7 @@ binc(SCR *sp, void *bp, size_t *bsizep, size_t min)
if (min && *bsizep >= min)
return (bp);
- csize = *bsizep + MAX(min, 256);
+ csize = *bsizep + MAXIMUM(min, 256);
REALLOC(sp, bp, void *, csize);
if (bp == NULL) {
diff --git a/usr.bin/vi/ex/ex_cd.c b/usr.bin/vi/ex/ex_cd.c
index 305fb82b4f8..b7532630bbb 100644
--- a/usr.bin/vi/ex/ex_cd.c
+++ b/usr.bin/vi/ex/ex_cd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ex_cd.c,v 1.10 2014/11/12 04:28:41 bentley Exp $ */
+/* $OpenBSD: ex_cd.c,v 1.11 2015/01/16 06:40:14 deraadt Exp $ */
/*-
* Copyright (c) 1992, 1993, 1994
@@ -11,7 +11,6 @@
#include "config.h"
-#include <sys/param.h>
#include <sys/queue.h>
#include <bitstring.h>
@@ -38,7 +37,7 @@ ex_cd(SCR *sp, EXCMD *cmdp)
ARGS *ap;
CHAR_T savech;
char *dir, *p, *t; /* XXX: END OF THE STACK, DON'T TRUST GETCWD. */
- char buf[MAXPATHLEN * 2];
+ char buf[PATH_MAX * 2];
/*
* !!!
diff --git a/usr.bin/vi/ex/ex_cscope.c b/usr.bin/vi/ex/ex_cscope.c
index 757b741ca69..0bca4cbb2cd 100644
--- a/usr.bin/vi/ex/ex_cscope.c
+++ b/usr.bin/vi/ex/ex_cscope.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ex_cscope.c,v 1.23 2014/11/14 20:27:03 tedu Exp $ */
+/* $OpenBSD: ex_cscope.c,v 1.24 2015/01/16 06:40:14 deraadt Exp $ */
/*-
* Copyright (c) 1994, 1996
@@ -11,7 +11,6 @@
#include "config.h"
-#include <sys/param.h>
#include <sys/queue.h>
#include <sys/stat.h>
#include <sys/time.h>
@@ -190,7 +189,7 @@ cscope_add(SCR *sp, EXCMD *cmdp, char *dname)
CSC *csc;
size_t len;
int cur_argc;
- char *dbname, path[MAXPATHLEN];
+ char *dbname, path[PATH_MAX];
exp = EXP(sp);
@@ -283,7 +282,7 @@ get_paths(SCR *sp, CSC *csc)
struct stat sb;
int fd, nentries;
size_t len;
- char *p, **pathp, buf[MAXPATHLEN * 2];
+ char *p, **pathp, buf[PATH_MAX * 2];
/*
* EXTENSION #2:
@@ -354,7 +353,7 @@ static int
run_cscope(SCR *sp, CSC *csc, char *dbname)
{
int to_cs[2], from_cs[2];
- char cmd[MAXPATHLEN * 2];
+ char cmd[PATH_MAX * 2];
/*
* Cscope reads from to_cs[0] and writes to from_cs[1]; vi reads from
@@ -752,7 +751,7 @@ csc_file(SCR *sp, CSC *csc, char *name, char **dirp, size_t *dlenp,
int *isolderp)
{
struct stat sb;
- char **pp, buf[MAXPATHLEN];
+ char **pp, buf[PATH_MAX];
/*
* Check for the file in all of the listed paths. If we don't
diff --git a/usr.bin/vi/ex/ex_filter.c b/usr.bin/vi/ex/ex_filter.c
index bfdf8cfeea8..0beac24b385 100644
--- a/usr.bin/vi/ex/ex_filter.c
+++ b/usr.bin/vi/ex/ex_filter.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ex_filter.c,v 1.12 2014/11/12 04:28:41 bentley Exp $ */
+/* $OpenBSD: ex_filter.c,v 1.13 2015/01/16 06:40:14 deraadt Exp $ */
/*-
* Copyright (c) 1991, 1993, 1994
@@ -11,7 +11,6 @@
#include "config.h"
-#include <sys/param.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/queue.h>
@@ -46,7 +45,7 @@ ex_filter(SCR *sp, EXCMD *cmdp, MARK *fm, MARK *tm, MARK *rp, char *cmd,
pid_t parent_writer_pid, utility_pid;
recno_t nread;
int input[2], output[2], fd, rval;
- char *name, tname[MAXPATHLEN];
+ char *name, tname[PATH_MAX];
rval = 0;
diff --git a/usr.bin/vi/ex/ex_init.c b/usr.bin/vi/ex/ex_init.c
index f850b118cc7..86effa05ac7 100644
--- a/usr.bin/vi/ex/ex_init.c
+++ b/usr.bin/vi/ex/ex_init.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ex_init.c,v 1.13 2014/11/12 16:29:04 millert Exp $ */
+/* $OpenBSD: ex_init.c,v 1.14 2015/01/16 06:40:14 deraadt Exp $ */
/*-
* Copyright (c) 1992, 1993, 1994
@@ -11,7 +11,6 @@
#include "config.h"
-#include <sys/param.h>
#include <sys/queue.h>
#include <sys/stat.h>
@@ -135,7 +134,7 @@ int
ex_exrc(SCR *sp)
{
struct stat hsb, lsb;
- char *p, path[MAXPATHLEN];
+ char *p, path[PATH_MAX];
int fd;
/*
@@ -344,7 +343,7 @@ exrc_isok(SCR *sp, struct stat *sbp, int *fdp, char *path, int rootown,
enum { ROOTOWN, OWN, WRITER } etype;
uid_t euid;
int nf1, nf2;
- char *a, *b, buf[MAXPATHLEN];
+ char *a, *b, buf[PATH_MAX];
if ((*fdp = open(path, O_RDONLY, 0)) < 0) {
if (errno == ENOENT)
diff --git a/usr.bin/vi/ex/ex_shell.c b/usr.bin/vi/ex/ex_shell.c
index 43188804798..6a4888b820e 100644
--- a/usr.bin/vi/ex/ex_shell.c
+++ b/usr.bin/vi/ex/ex_shell.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ex_shell.c,v 1.13 2014/11/12 04:28:41 bentley Exp $ */
+/* $OpenBSD: ex_shell.c,v 1.14 2015/01/16 06:40:14 deraadt Exp $ */
/*-
* Copyright (c) 1992, 1993, 1994
@@ -11,7 +11,6 @@
#include "config.h"
-#include <sys/param.h>
#include <sys/queue.h>
#include <sys/wait.h>
@@ -26,6 +25,8 @@
#include "../common/common.h"
+#define MINIMUM(a, b) (((a) < (b)) ? (a) : (b))
+
/*
* ex_shell -- :sh[ell]
* Invoke the program named in the SHELL environment variable
@@ -37,7 +38,7 @@ int
ex_shell(SCR *sp, EXCMD *cmdp)
{
int rval;
- char buf[MAXPATHLEN];
+ char buf[PATH_MAX];
/* We'll need a shell. */
if (opts_empty(sp, O_SHELL, 0))
@@ -166,7 +167,7 @@ proc_wait(SCR *sp, pid_t pid, const char *cmd, int silent, int okpipe)
p = msg_print(sp, cmd, &nf);
len = strlen(p);
msgq(sp, M_ERR, "%.*s%s: received signal: %s%s",
- MIN(len, 20), p, len > 20 ? " ..." : "",
+ MINIMUM(len, 20), p, len > 20 ? " ..." : "",
strsignal(WTERMSIG(pstat)),
WCOREDUMP(pstat) ? "; core dumped" : "");
if (nf)
@@ -188,7 +189,7 @@ proc_wait(SCR *sp, pid_t pid, const char *cmd, int silent, int okpipe)
p = msg_print(sp, cmd, &nf);
len = strlen(p);
msgq(sp, M_ERR, "%.*s%s: exited with status %d",
- MIN(len, 20), p, len > 20 ? " ..." : "",
+ MINIMUM(len, 20), p, len > 20 ? " ..." : "",
WEXITSTATUS(pstat));
if (nf)
FREE_SPACE(sp, p, 0);
diff --git a/usr.bin/vi/ex/ex_subst.c b/usr.bin/vi/ex/ex_subst.c
index eff4ed755a2..cdbf5fd7141 100644
--- a/usr.bin/vi/ex/ex_subst.c
+++ b/usr.bin/vi/ex/ex_subst.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ex_subst.c,v 1.21 2014/11/12 04:28:41 bentley Exp $ */
+/* $OpenBSD: ex_subst.c,v 1.22 2015/01/16 06:40:14 deraadt Exp $ */
/*-
* Copyright (c) 1992, 1993, 1994
@@ -11,7 +11,6 @@
#include "config.h"
-#include <sys/param.h>
#include <sys/queue.h>
#include <sys/time.h>
@@ -27,6 +26,8 @@
#include "../common/common.h"
#include "../vi/vi.h"
+#define MAXIMUM(a, b) (((a) > (b)) ? (a) : (b))
+
#define SUB_FIRST 0x01 /* The 'r' flag isn't reasonable. */
#define SUB_MUSTSETR 0x02 /* The 'r' flag is required. */
@@ -312,7 +313,7 @@ ex_subtilde(SCR *sp, EXCMD *cmdp)
#define BUILD(sp, l, len) { \
if (lbclen + (len) > lblen) { \
- lblen += MAX(lbclen + (len), 256); \
+ lblen += MAXIMUM(lbclen + (len), 256); \
REALLOC((sp), lb, char *, lblen); \
if (lb == NULL) { \
lbclen = 0; \
@@ -325,7 +326,7 @@ ex_subtilde(SCR *sp, EXCMD *cmdp)
#define NEEDSP(sp, len, pnt) { \
if (lbclen + (len) > lblen) { \
- lblen += MAX(lbclen + (len), 256); \
+ lblen += MAXIMUM(lbclen + (len), 256); \
REALLOC((sp), lb, char *, lblen); \
if (lb == NULL) { \
lbclen = 0; \
diff --git a/usr.bin/vi/ex/ex_tag.c b/usr.bin/vi/ex/ex_tag.c
index ae3f8ab69a5..9dda01b4900 100644
--- a/usr.bin/vi/ex/ex_tag.c
+++ b/usr.bin/vi/ex/ex_tag.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ex_tag.c,v 1.20 2014/11/12 16:29:04 millert Exp $ */
+/* $OpenBSD: ex_tag.c,v 1.21 2015/01/16 06:40:14 deraadt Exp $ */
/*-
* Copyright (c) 1992, 1993, 1994
@@ -14,7 +14,6 @@
#include "config.h"
-#include <sys/param.h>
#include <sys/mman.h>
#include <sys/queue.h>
#include <sys/stat.h>
@@ -1124,7 +1123,7 @@ static void
ctag_file(SCR *sp, TAGF *tfp, char *name, char **dirp, size_t *dlenp)
{
struct stat sb;
- char *p, buf[MAXPATHLEN];
+ char *p, buf[PATH_MAX];
/*
* !!!
diff --git a/usr.bin/vi/vi/v_scroll.c b/usr.bin/vi/vi/v_scroll.c
index 5ecdb944834..6bd2a876571 100644
--- a/usr.bin/vi/vi/v_scroll.c
+++ b/usr.bin/vi/vi/v_scroll.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: v_scroll.c,v 1.9 2014/11/12 04:28:41 bentley Exp $ */
+/* $OpenBSD: v_scroll.c,v 1.10 2015/01/16 06:40:14 deraadt Exp $ */
/*-
* Copyright (c) 1992, 1993, 1994
@@ -11,7 +11,6 @@
#include "config.h"
-#include <sys/param.h>
#include <sys/queue.h>
#include <sys/time.h>
@@ -23,6 +22,8 @@
#include "../common/common.h"
#include "vi.h"
+#define MINIMUM(a, b) (((a) < (b)) ? (a) : (b))
+
static void goto_adjust(VICMD *);
/*
@@ -345,7 +346,7 @@ v_pagedown(SCR *sp, VICMD *vp)
* least one line.
*/
offset = (F_ISSET(vp, VC_C1SET) ? vp->count : 1) * (IS_SPLIT(sp) ?
- MIN(sp->t_maxrows, O_VAL(sp, O_WINDOW)) : O_VAL(sp, O_WINDOW));
+ MINIMUM(sp->t_maxrows, O_VAL(sp, O_WINDOW)) : O_VAL(sp, O_WINDOW));
offset = offset <= 2 ? 1 : offset - 2;
if (vs_sm_scroll(sp, &vp->m_stop, offset, CNTRL_F))
return (1);
@@ -396,7 +397,7 @@ v_pageup(SCR *sp, VICMD *vp)
* least one line.
*/
offset = (F_ISSET(vp, VC_C1SET) ? vp->count : 1) * (IS_SPLIT(sp) ?
- MIN(sp->t_maxrows, O_VAL(sp, O_WINDOW)) : O_VAL(sp, O_WINDOW));
+ MINIMUM(sp->t_maxrows, O_VAL(sp, O_WINDOW)) : O_VAL(sp, O_WINDOW));
offset = offset <= 2 ? 1 : offset - 2;
if (vs_sm_scroll(sp, &vp->m_stop, offset, CNTRL_B))
return (1);
diff --git a/usr.bin/vi/vi/v_txt.c b/usr.bin/vi/vi/v_txt.c
index c74b20a8c80..6296c128d2e 100644
--- a/usr.bin/vi/vi/v_txt.c
+++ b/usr.bin/vi/vi/v_txt.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: v_txt.c,v 1.27 2014/11/12 04:28:41 bentley Exp $ */
+/* $OpenBSD: v_txt.c,v 1.28 2015/01/16 06:40:14 deraadt Exp $ */
/*-
* Copyright (c) 1993, 1994
@@ -11,7 +11,6 @@
#include "config.h"
-#include <sys/param.h>
#include <sys/queue.h>
#include <sys/stat.h>
#include <sys/time.h>
@@ -28,6 +27,8 @@
#include "../common/common.h"
#include "vi.h"
+#define MINIMUM(a, b) (((a) < (b)) ? (a) : (b))
+
static int txt_abbrev(SCR *, TEXT *, CHAR_T *, int, int *, int *);
static void txt_ai_resolve(SCR *, TEXT *, int *);
static TEXT *txt_backup(SCR *, TEXTH *, TEXT *, u_int32_t *);
@@ -2862,7 +2863,7 @@ txt_Rresolve(SCR *sp, TEXTH *tiqh, TEXT *tp, const size_t orig_len)
* okay, the user just extended the file.
*/
if (input_len < orig_len) {
- retain = MIN(tp->owrite, orig_len - input_len);
+ retain = MINIMUM(tp->owrite, orig_len - input_len);
if (db_get(sp,
TAILQ_FIRST(tiqh)->lno, DBG_FATAL | DBG_NOCACHE, &p, NULL))
return;
diff --git a/usr.bin/vmstat/dkstats.c b/usr.bin/vmstat/dkstats.c
index 6d97256b3b6..880caf627c0 100644
--- a/usr.bin/vmstat/dkstats.c
+++ b/usr.bin/vmstat/dkstats.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: dkstats.c,v 1.36 2014/09/15 19:08:22 miod Exp $ */
+/* $OpenBSD: dkstats.c,v 1.37 2015/01/16 06:40:14 deraadt Exp $ */
/* $NetBSD: dkstats.c,v 1.1 1996/05/10 23:19:27 thorpej Exp $ */
/*
@@ -33,7 +33,6 @@
* SUCH DAMAGE.
*/
-#include <sys/param.h>
#include <sys/time.h>
#include <sys/disk.h>
#include <sys/sched.h>
diff --git a/usr.bin/vmstat/vmstat.c b/usr.bin/vmstat/vmstat.c
index fd65ac9dc09..c034ba267b8 100644
--- a/usr.bin/vmstat/vmstat.c
+++ b/usr.bin/vmstat/vmstat.c
@@ -1,5 +1,5 @@
/* $NetBSD: vmstat.c,v 1.29.4.1 1996/06/05 00:21:05 cgd Exp $ */
-/* $OpenBSD: vmstat.c,v 1.135 2014/12/19 20:18:15 tedu Exp $ */
+/* $OpenBSD: vmstat.c,v 1.136 2015/01/16 06:40:14 deraadt Exp $ */
/*
* Copyright (c) 1980, 1986, 1991, 1993
@@ -30,7 +30,7 @@
* SUCH DAMAGE.
*/
-#include <sys/param.h>
+#include <sys/param.h> /* MAXCOMLEN */
#include <sys/time.h>
#include <sys/proc.h>
#include <sys/namei.h>
diff --git a/usr.bin/w/proc_compare.c b/usr.bin/w/proc_compare.c
index a2b280f9551..77be7a9e389 100644
--- a/usr.bin/w/proc_compare.c
+++ b/usr.bin/w/proc_compare.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: proc_compare.c,v 1.14 2014/07/04 05:58:31 guenther Exp $ */
+/* $OpenBSD: proc_compare.c,v 1.15 2015/01/16 06:40:14 deraadt Exp $ */
/*-
* Copyright (c) 1990, 1993
@@ -29,7 +29,7 @@
* SUCH DAMAGE.
*/
-#include <sys/param.h>
+#include <sys/param.h> /* MAXCOMLEN */
#include <sys/proc.h>
#include <sys/sysctl.h>
#include <sys/time.h>
diff --git a/usr.bin/w/w.c b/usr.bin/w/w.c
index 2847004aa45..08f6b951528 100644
--- a/usr.bin/w/w.c
+++ b/usr.bin/w/w.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: w.c,v 1.56 2014/07/08 23:24:28 deraadt Exp $ */
+/* $OpenBSD: w.c,v 1.57 2015/01/16 06:40:14 deraadt Exp $ */
/*-
* Copyright (c) 1980, 1991, 1993, 1994
@@ -35,10 +35,11 @@
* This program is similar to the systat command on Tenex/Tops 10/20
*
*/
-#include <sys/param.h>
+#include <sys/param.h> /* MAXCOMLEN */
#include <sys/time.h>
#include <sys/stat.h>
#include <sys/sysctl.h>
+#include <sys/signal.h>
#include <sys/proc.h>
#include <sys/ioctl.h>
#include <sys/socket.h>
@@ -77,7 +78,7 @@ int header = 1; /* true if -h flag: don't print heading */
int nflag = 1; /* true if -n flag: don't convert addrs */
int sortidle; /* sort by idle time */
char *sel_user; /* login of particular user selected */
-char domain[MAXHOSTNAMELEN];
+char domain[HOST_NAME_MAX+1];
#define NAME_WIDTH 8
#define HOST_WIDTH 16
@@ -110,7 +111,7 @@ main(int argc, char *argv[])
struct in_addr addr;
int ch, i, nentries, nusers, wcmd;
char *memf, *nlistf, *p, *x;
- char buf[MAXHOSTNAMELEN], errbuf[_POSIX2_LINE_MAX];
+ char buf[HOST_NAME_MAX+1], errbuf[_POSIX2_LINE_MAX];
/* Are we w(1) or uptime(1)? */
p = __progname;
diff --git a/usr.bin/wall/wall.c b/usr.bin/wall/wall.c
index cdb65aa979a..b44d1cffa5c 100644
--- a/usr.bin/wall/wall.c
+++ b/usr.bin/wall/wall.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: wall.c,v 1.25 2009/10/27 23:59:49 deraadt Exp $ */
+/* $OpenBSD: wall.c,v 1.26 2015/01/16 06:40:14 deraadt Exp $ */
/* $NetBSD: wall.c,v 1.6 1994/11/17 07:17:58 jtc Exp $ */
/*
@@ -35,7 +35,6 @@
* is entitled "Mechanisms for Broadcast and Selective Broadcast".
*/
-#include <sys/param.h>
#include <sys/stat.h>
#include <sys/time.h>
#include <sys/uio.h>
@@ -47,6 +46,7 @@
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
+#include <limits.h>
#include <utmp.h>
#include <vis.h>
#include <err.h>
@@ -148,7 +148,7 @@ makemsg(char *fname)
time_t now;
FILE *fp;
int fd;
- char *p, *whom, hostname[MAXHOSTNAMELEN], lbuf[100], tmpname[MAXPATHLEN];
+ char *p, *whom, hostname[HOST_NAME_MAX+1], lbuf[100], tmpname[PATH_MAX];
char tmpbuf[5];
char *ttynam;
diff --git a/usr.bin/wc/wc.c b/usr.bin/wc/wc.c
index 5387cd03200..5f1d66f8942 100644
--- a/usr.bin/wc/wc.c
+++ b/usr.bin/wc/wc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: wc.c,v 1.16 2013/11/27 13:32:02 okan Exp $ */
+/* $OpenBSD: wc.c,v 1.17 2015/01/16 06:40:14 deraadt Exp $ */
/*
* Copyright (c) 1980, 1987, 1991, 1993
@@ -29,15 +29,15 @@
* SUCH DAMAGE.
*/
+#include <sys/param.h> /* MAXBSIZE */
+#include <sys/stat.h>
+#include <sys/file.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <locale.h>
#include <ctype.h>
#include <err.h>
-#include <sys/param.h>
-#include <sys/stat.h>
-#include <sys/file.h>
#include <unistd.h>
#include <util.h>
diff --git a/usr.bin/which/which.c b/usr.bin/which/which.c
index 419b32fe35c..1f2bb65fe0b 100644
--- a/usr.bin/which/which.c
+++ b/usr.bin/which/which.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: which.c,v 1.19 2014/05/20 01:25:23 guenther Exp $ */
+/* $OpenBSD: which.c,v 1.20 2015/01/16 06:40:14 deraadt Exp $ */
/*
* Copyright (c) 1997 Todd C. Miller <Todd.Miller@courtesan.com>
@@ -16,7 +16,6 @@
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
-#include <sys/param.h>
#include <sys/stat.h>
#include <sys/sysctl.h>
@@ -28,6 +27,7 @@
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
+#include <limits.h>
#define PROG_WHICH 1
#define PROG_WHEREIS 2
@@ -94,7 +94,7 @@ main(int argc, char *argv[])
int
findprog(char *prog, char *path, int progmode, int allmatches)
{
- char *p, filename[MAXPATHLEN];
+ char *p, filename[PATH_MAX];
int proglen, plen, rval = 0;
struct stat sbuf;
char *pathcpy;
diff --git a/usr.bin/write/write.c b/usr.bin/write/write.c
index 321bb42a5c0..be3bc10b964 100644
--- a/usr.bin/write/write.c
+++ b/usr.bin/write/write.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: write.c,v 1.27 2013/04/16 19:24:55 deraadt Exp $ */
+/* $OpenBSD: write.c,v 1.28 2015/01/16 06:40:14 deraadt Exp $ */
/* $NetBSD: write.c,v 1.5 1995/08/31 21:48:32 jtc Exp $ */
/*
@@ -33,7 +33,6 @@
* SUCH DAMAGE.
*/
-#include <sys/param.h>
#include <sys/stat.h>
#include <ctype.h>
#include <stdio.h>
@@ -45,6 +44,7 @@
#include <paths.h>
#include <pwd.h>
#include <unistd.h>
+#include <limits.h>
#include <utmp.h>
#include <err.h>
#include <vis.h>
@@ -59,7 +59,7 @@ int utmp_chk(char *, char *);
int
main(int argc, char *argv[])
{
- char tty[MAXPATHLEN], *mytty, *cp;
+ char tty[PATH_MAX], *mytty, *cp;
int msgsok, myttyfd;
time_t atime;
uid_t myuid;
@@ -204,7 +204,7 @@ int
term_chk(char *tty, int *msgsokP, time_t *atimeP, int showerror)
{
struct stat s;
- char path[MAXPATHLEN];
+ char path[PATH_MAX];
(void)snprintf(path, sizeof(path), "%s%s", _PATH_DEV, tty);
if (stat(path, &s) < 0) {
@@ -226,7 +226,7 @@ do_write(char *tty, char *mytty, uid_t myuid)
char *login, *nows;
struct passwd *pwd;
time_t now;
- char path[MAXPATHLEN], host[MAXHOSTNAMELEN], line[512];
+ char path[PATH_MAX], host[HOST_NAME_MAX+1], line[512];
gid_t gid;
/* Determine our login name before the we reopen() stdout */
diff --git a/usr.bin/x99token/x99token.c b/usr.bin/x99token/x99token.c
index 9cb268b3c4b..533fa79534c 100644
--- a/usr.bin/x99token/x99token.c
+++ b/usr.bin/x99token/x99token.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: x99token.c,v 1.9 2013/11/27 00:13:22 deraadt Exp $ */
+/* $OpenBSD: x99token.c,v 1.10 2015/01/16 06:40:14 deraadt Exp $ */
/*
* X9.9 calculator
@@ -7,7 +7,7 @@
*
* Donated to the Public Domain by Paul Borman
*/
-#include <sys/param.h>
+
#include <sys/stat.h>
#include <ctype.h>
@@ -18,6 +18,7 @@
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
+#include <limits.h>
#include <openssl/des.h>
#define KEYFILE ".keyfile.des"
@@ -36,7 +37,7 @@ main(int argc, char **argv)
char buf[256];
DES_key_schedule ks;
DES_cblock key;
- char _keyfile[MAXPATHLEN];
+ char _keyfile[PATH_MAX];
char *keyfile = 0;
FILE *fp;
int init = 0;
diff --git a/usr.bin/xargs/xargs.c b/usr.bin/xargs/xargs.c
index 3684c43a6b3..dded1c6a11b 100644
--- a/usr.bin/xargs/xargs.c
+++ b/usr.bin/xargs/xargs.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: xargs.c,v 1.27 2010/03/25 01:03:57 schwarze Exp $ */
+/* $OpenBSD: xargs.c,v 1.28 2015/01/16 06:40:14 deraadt Exp $ */
/* $FreeBSD: xargs.c,v 1.51 2003/05/03 19:09:11 obrien Exp $ */
/*-
@@ -35,7 +35,6 @@
* $xMach: xargs.c,v 1.6 2002/02/23 05:27:47 tim Exp $
*/
-#include <sys/param.h>
#include <sys/wait.h>
#include <ctype.h>
diff --git a/usr.bin/xinstall/xinstall.c b/usr.bin/xinstall/xinstall.c
index 68f6ec1222d..7b89632c832 100644
--- a/usr.bin/xinstall/xinstall.c
+++ b/usr.bin/xinstall/xinstall.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: xinstall.c,v 1.57 2014/05/20 01:25:23 guenther Exp $ */
+/* $OpenBSD: xinstall.c,v 1.58 2015/01/16 06:40:15 deraadt Exp $ */
/* $NetBSD: xinstall.c,v 1.9 1995/12/20 10:25:17 jonathan Exp $ */
/*
@@ -30,7 +30,7 @@
* SUCH DAMAGE.
*/
-#include <sys/param.h>
+#include <sys/param.h> /* MAXBSIZE */
#include <sys/wait.h>
#include <sys/mman.h>
#include <sys/stat.h>
@@ -46,11 +46,14 @@
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
+#include <limits.h>
#include <sysexits.h>
#include <utime.h>
#include "pathnames.h"
+#define MINIMUM(a, b) (((a) < (b)) ? (a) : (b))
+
#define DIRECTORY 0x01 /* Tell install it's a directory. */
#define SETFLAGS 0x02 /* Tell install to set flags. */
#define NOCHANGEBITS (UF_IMMUTABLE | UF_APPEND | SF_IMMUTABLE | SF_APPEND)
@@ -60,7 +63,7 @@ struct passwd *pp;
struct group *gp;
int dobackup, docompare, dodir, dopreserve, dostrip, safecopy;
int mode = S_IRWXU|S_IRGRP|S_IXGRP|S_IROTH|S_IXOTH;
-char pathbuf[MAXPATHLEN], tempfile[MAXPATHLEN];
+char pathbuf[PATH_MAX], tempfile[PATH_MAX];
char *suffix = BACKUP_SUFFIX;
uid_t uid;
gid_t gid;
@@ -372,8 +375,8 @@ install(char *from_name, char *to_name, u_long fset, u_int flags)
if (to_sb.st_flags & (NOCHANGEBITS))
(void)chflags(to_name, to_sb.st_flags & ~(NOCHANGEBITS));
if (dobackup) {
- char backup[MAXPATHLEN];
- (void)snprintf(backup, MAXPATHLEN, "%s%s", to_name,
+ char backup[PATH_MAX];
+ (void)snprintf(backup, PATH_MAX, "%s%s", to_name,
suffix);
/* It is ok for the target file not to exist. */
if (rename(to_name, backup) < 0 && errno != ENOENT) {
@@ -498,7 +501,7 @@ compare(int from_fd, const char *from_name, size_t from_len, int to_fd,
from_off = to_off = (off_t)0;
remainder = from_len;
do {
- length = MIN(remainder, 8 * 1048576);
+ length = MINIMUM(remainder, 8 * 1048576);
remainder -= length;
if ((p1 = mmap(NULL, length, PROT_READ, MAP_PRIVATE,
@@ -632,7 +635,7 @@ create_tempfile(char *path, char *temp, size_t tsize)
int
create_newfile(char *path, struct stat *sbp)
{
- char backup[MAXPATHLEN];
+ char backup[PATH_MAX];
/*
* Unlink now... avoid ETXTBSY errors later. Try and turn
@@ -643,7 +646,7 @@ create_newfile(char *path, struct stat *sbp)
(void)chflags(path, sbp->st_flags & ~(NOCHANGEBITS));
if (dobackup) {
- (void)snprintf(backup, MAXPATHLEN, "%s%s", path, suffix);
+ (void)snprintf(backup, PATH_MAX, "%s%s", path, suffix);
/* It is ok for the target file not to exist. */
if (rename(path, backup) < 0 && errno != ENOENT)
err(EX_OSERR, "rename: %s to %s (errno %d)", path, backup, errno);
@@ -729,7 +732,7 @@ file_write(int fd, char *str, size_t cnt, int *rem, int *isempt, int sz)
* only examine up to the end of the current file block or
* remaining characters to write, whatever is smaller
*/
- wcnt = MIN(cnt, *rem);
+ wcnt = MINIMUM(cnt, *rem);
cnt -= wcnt;
*rem -= wcnt;
if (*isempt) {
diff --git a/usr.bin/ypcat/ypcat.c b/usr.bin/ypcat/ypcat.c
index 1355cf1a606..147b7c3963f 100644
--- a/usr.bin/ypcat/ypcat.c
+++ b/usr.bin/ypcat/ypcat.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ypcat.c,v 1.14 2009/10/27 23:59:50 deraadt Exp $ */
+/* $OpenBSD: ypcat.c,v 1.15 2015/01/16 06:40:15 deraadt Exp $ */
/*
* Copyright (c) 1992, 1993, 1996 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 <unistd.h>
diff --git a/usr.bin/ypmatch/ypmatch.c b/usr.bin/ypmatch/ypmatch.c
index 1503633eb7e..d1b445a941c 100644
--- a/usr.bin/ypmatch/ypmatch.c
+++ b/usr.bin/ypmatch/ypmatch.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ypmatch.c,v 1.14 2009/10/27 23:59:50 deraadt Exp $ */
+/* $OpenBSD: ypmatch.c,v 1.15 2015/01/16 06:40:15 deraadt Exp $ */
/* $NetBSD: ypmatch.c,v 1.8 1996/05/07 01:24:52 jtc Exp $ */
/*
@@ -27,7 +27,6 @@
* SUCH DAMAGE.
*/
-#include <sys/param.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <stdio.h>
diff --git a/usr.bin/ypwhich/ypwhich.c b/usr.bin/ypwhich/ypwhich.c
index 961d87656ec..e773c6c207a 100644
--- a/usr.bin/ypwhich/ypwhich.c
+++ b/usr.bin/ypwhich/ypwhich.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ypwhich.c,v 1.21 2013/11/15 22:20:04 millert Exp $ */
+/* $OpenBSD: ypwhich.c,v 1.22 2015/01/16 06:40:15 deraadt Exp $ */
/* $NetBSD: ypwhich.c,v 1.6 1996/05/13 02:43:48 thorpej Exp $ */
/*
@@ -27,7 +27,6 @@
* SUCH DAMAGE.
*/
-#include <sys/param.h>
#include <sys/types.h>
#include <sys/socket.h>