summaryrefslogtreecommitdiff
path: root/sbin/pfctl
diff options
context:
space:
mode:
Diffstat (limited to 'sbin/pfctl')
-rw-r--r--sbin/pfctl/parse.y12
-rw-r--r--sbin/pfctl/pfctl.c26
-rw-r--r--sbin/pfctl/pfctl_osfp.c16
-rw-r--r--sbin/pfctl/pfctl_parser.c3
-rw-r--r--sbin/pfctl/pfctl_table.c3
5 files changed, 28 insertions, 32 deletions
diff --git a/sbin/pfctl/parse.y b/sbin/pfctl/parse.y
index 083c2ddbb73..bf2dbbce540 100644
--- a/sbin/pfctl/parse.y
+++ b/sbin/pfctl/parse.y
@@ -1,4 +1,4 @@
-/* $OpenBSD: parse.y,v 1.643 2014/12/19 13:04:07 reyk Exp $ */
+/* $OpenBSD: parse.y,v 1.644 2015/01/16 06:40:00 deraadt Exp $ */
/*
* Copyright (c) 2001 Markus Friedl. All rights reserved.
@@ -903,23 +903,23 @@ loadrule : LOAD ANCHOR string FROM string {
struct loadanchors *loadanchor;
if (strlen(pf->anchor->name) + 1 +
- strlen($3) >= MAXPATHLEN) {
+ strlen($3) >= PATH_MAX) {
yyerror("anchorname %s too long, max %u\n",
- $3, MAXPATHLEN - 1);
+ $3, PATH_MAX - 1);
free($3);
YYERROR;
}
loadanchor = calloc(1, sizeof(struct loadanchors));
if (loadanchor == NULL)
err(1, "loadrule: calloc");
- if ((loadanchor->anchorname = malloc(MAXPATHLEN)) ==
+ if ((loadanchor->anchorname = malloc(PATH_MAX)) ==
NULL)
err(1, "loadrule: malloc");
if (pf->anchor->name[0])
- snprintf(loadanchor->anchorname, MAXPATHLEN,
+ snprintf(loadanchor->anchorname, PATH_MAX,
"%s/%s", pf->anchor->name, $3);
else
- strlcpy(loadanchor->anchorname, $3, MAXPATHLEN);
+ strlcpy(loadanchor->anchorname, $3, PATH_MAX);
if ((loadanchor->filename = strdup($5)) == NULL)
err(1, "loadrule: strdup");
diff --git a/sbin/pfctl/pfctl.c b/sbin/pfctl/pfctl.c
index 34fde7eb159..bccb8e24b80 100644
--- a/sbin/pfctl/pfctl.c
+++ b/sbin/pfctl/pfctl.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pfctl.c,v 1.328 2014/12/10 13:59:29 bluhm Exp $ */
+/* $OpenBSD: pfctl.c,v 1.329 2015/01/16 06:40:00 deraadt Exp $ */
/*
* Copyright (c) 2001 Daniel Hartmeier
@@ -749,14 +749,14 @@ pfctl_show_rules(int dev, char *path, int opts, enum pfctl_show format,
memset(&pr, 0, sizeof(pr));
if (anchorname[0] == '/') {
- if ((npath = calloc(1, MAXPATHLEN)) == NULL)
+ if ((npath = calloc(1, PATH_MAX)) == NULL)
errx(1, "pfctl_rules: calloc");
- strlcpy(npath, anchorname, MAXPATHLEN);
+ strlcpy(npath, anchorname, PATH_MAX);
} else {
if (path[0])
- snprintf(&path[len], MAXPATHLEN - len, "/%s", anchorname);
+ snprintf(&path[len], PATH_MAX - len, "/%s", anchorname);
else
- snprintf(&path[len], MAXPATHLEN - len, "%s", anchorname);
+ snprintf(&path[len], PATH_MAX - len, "%s", anchorname);
npath = path;
}
@@ -1330,9 +1330,9 @@ pfctl_load_ruleset(struct pfctl *pf, char *path, struct pf_ruleset *rs,
pf->anchor = rs->anchor;
if (path[0])
- snprintf(&path[len], MAXPATHLEN - len, "/%s", pf->anchor->name);
+ snprintf(&path[len], PATH_MAX - len, "/%s", pf->anchor->name);
else
- snprintf(&path[len], MAXPATHLEN - len, "%s", pf->anchor->name);
+ snprintf(&path[len], PATH_MAX - len, "%s", pf->anchor->name);
if (depth) {
if (TAILQ_FIRST(rs->rules.active.ptr) != NULL) {
@@ -1396,10 +1396,10 @@ pfctl_load_rule(struct pfctl *pf, char *path, struct pf_rule *r, int depth)
if (r->anchor) {
if (r->anchor->match) {
if (path[0])
- snprintf(&path[len], MAXPATHLEN - len,
+ snprintf(&path[len], PATH_MAX - len,
"/%s", r->anchor->name);
else
- snprintf(&path[len], MAXPATHLEN - len,
+ snprintf(&path[len], PATH_MAX - len,
"%s", r->anchor->name);
name = r->anchor->name;
} else
@@ -1455,7 +1455,7 @@ pfctl_rules(int dev, char *filename, int opts, int optimize,
memset(&pf, 0, sizeof(pf));
memset(&trs, 0, sizeof(trs));
- if ((path = calloc(1, MAXPATHLEN)) == NULL)
+ if ((path = calloc(1, PATH_MAX)) == NULL)
ERRX("pfctl_rules: calloc");
if (strlcpy(trs.pfrt_anchor, anchorname,
sizeof(trs.pfrt_anchor)) >= sizeof(trs.pfrt_anchor))
@@ -1980,7 +1980,7 @@ pfctl_show_anchors(int dev, int opts, char *anchorname)
}
mnr = pr.nr;
for (nr = 0; nr < mnr; ++nr) {
- char sub[MAXPATHLEN];
+ char sub[PATH_MAX];
pr.nr = nr;
if (ioctl(dev, DIOCGETRULESET, &pr))
@@ -2097,7 +2097,7 @@ main(int argc, char *argv[])
int opts = 0;
int optimize = PF_OPTIMIZE_BASIC;
int level;
- char anchorname[MAXPATHLEN];
+ char anchorname[PATH_MAX];
int anchor_wildcard = 0;
char *path;
char *lfile = NULL, *sfile = NULL;
@@ -2252,7 +2252,7 @@ main(int argc, char *argv[])
/* NOTREACHED */
}
- if ((path = calloc(1, MAXPATHLEN)) == NULL)
+ if ((path = calloc(1, PATH_MAX)) == NULL)
errx(1, "pfctl: calloc");
memset(anchorname, 0, sizeof(anchorname));
if (anchoropt != NULL) {
diff --git a/sbin/pfctl/pfctl_osfp.c b/sbin/pfctl/pfctl_osfp.c
index 44d43ef43d2..2a151469127 100644
--- a/sbin/pfctl/pfctl_osfp.c
+++ b/sbin/pfctl/pfctl_osfp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pfctl_osfp.c,v 1.20 2014/10/25 03:18:13 lteo Exp $ */
+/* $OpenBSD: pfctl_osfp.c,v 1.21 2015/01/16 06:40:00 deraadt Exp $ */
/*
* Copyright (c) 2003 Mike Frantzen <frantzen@openbsd.org>
@@ -36,13 +36,7 @@
#include "pfctl_parser.h"
#include "pfctl.h"
-#ifndef MIN
-# define MIN(a,b) (((a) < (b)) ? (a) : (b))
-#endif /* MIN */
-#ifndef MAX
-# define MAX(a,b) (((a) > (b)) ? (a) : (b))
-#endif /* MAX */
-
+#define MAXIMUM(a, b) (((a) > (b)) ? (a) : (b))
#if 0
# define DEBUG(fp, str, v...) \
@@ -665,7 +659,7 @@ import_fingerprint(struct pf_osfp_ioctl *fp)
nm_class = fingerprint_name_entry(&classes, fp->fp_os.fp_class_nm);
if (nm_class->nm_num == 0) {
nm_class->nm_num = class;
- class_count = MAX(class_count, class);
+ class_count = MAXIMUM(class_count, class);
}
nm_version = fingerprint_name_entry(&nm_class->nm_sublist,
@@ -673,7 +667,7 @@ import_fingerprint(struct pf_osfp_ioctl *fp)
if (nm_version) {
if (nm_version->nm_num == 0) {
nm_version->nm_num = version;
- nm_class->nm_sublist_num = MAX(nm_class->nm_sublist_num,
+ nm_class->nm_sublist_num = MAXIMUM(nm_class->nm_sublist_num,
version);
}
nm_subtype = fingerprint_name_entry(&nm_version->nm_sublist,
@@ -682,7 +676,7 @@ import_fingerprint(struct pf_osfp_ioctl *fp)
if (nm_subtype->nm_num == 0) {
nm_subtype->nm_num = subtype;
nm_version->nm_sublist_num =
- MAX(nm_version->nm_sublist_num, subtype);
+ MAXIMUM(nm_version->nm_sublist_num, subtype);
}
}
}
diff --git a/sbin/pfctl/pfctl_parser.c b/sbin/pfctl/pfctl_parser.c
index ca7780b95bf..3aacf1223c9 100644
--- a/sbin/pfctl/pfctl_parser.c
+++ b/sbin/pfctl/pfctl_parser.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pfctl_parser.c,v 1.300 2014/10/27 21:51:32 mikeb Exp $ */
+/* $OpenBSD: pfctl_parser.c,v 1.301 2015/01/16 06:40:00 deraadt Exp $ */
/*
* Copyright (c) 2001 Daniel Hartmeier
@@ -54,6 +54,7 @@
#include <err.h>
#include <ifaddrs.h>
#include <unistd.h>
+#include <limits.h>
#define SYSLOG_NAMES
#include <syslog.h>
diff --git a/sbin/pfctl/pfctl_table.c b/sbin/pfctl/pfctl_table.c
index afe4d7f9075..e6b7c7565ab 100644
--- a/sbin/pfctl/pfctl_table.c
+++ b/sbin/pfctl/pfctl_table.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pfctl_table.c,v 1.72 2013/07/05 13:07:57 blambert Exp $ */
+/* $OpenBSD: pfctl_table.c,v 1.73 2015/01/16 06:40:00 deraadt Exp $ */
/*
* Copyright (c) 2002 Cedric Berger
@@ -47,6 +47,7 @@
#include <stdlib.h>
#include <string.h>
#include <time.h>
+#include <limits.h>
#include "pfctl_parser.h"
#include "pfctl.h"