summaryrefslogtreecommitdiff
path: root/sbin/pfctl/pfctl_parser.c
diff options
context:
space:
mode:
authorRyan Thomas McBride <mcbride@cvs.openbsd.org>2010-01-12 15:49:44 +0000
committerRyan Thomas McBride <mcbride@cvs.openbsd.org>2010-01-12 15:49:44 +0000
commitd598931b67822202a100f06ed27ae9a84b40d77a (patch)
treeec71849a7ee5ba8b9101353cffe1eb34033c6ecb /sbin/pfctl/pfctl_parser.c
parent25ac25f3237a2d19eb3cc06362754d510f61237a (diff)
Unbreak 10/8 and friends.
Diffstat (limited to 'sbin/pfctl/pfctl_parser.c')
-rw-r--r--sbin/pfctl/pfctl_parser.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/sbin/pfctl/pfctl_parser.c b/sbin/pfctl/pfctl_parser.c
index 4b56aa11ad8..a4c9df8b370 100644
--- a/sbin/pfctl/pfctl_parser.c
+++ b/sbin/pfctl/pfctl_parser.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pfctl_parser.c,v 1.257 2010/01/12 14:44:26 mcbride Exp $ */
+/* $OpenBSD: pfctl_parser.c,v 1.258 2010/01/12 15:49:43 mcbride Exp $ */
/*
* Copyright (c) 2001 Daniel Hartmeier
@@ -1399,7 +1399,7 @@ host(const char *s)
{
struct node_host *h = NULL, *n;
int mask = -1, v4mask = 32, v6mask = 128, cont = 1;
- char *p, *q, *ps, *if_name;
+ char *p, *q, *r, *ps, *if_name;
if ((ps = strdup(s)) == NULL)
err(1, "host: strdup");
@@ -1408,7 +1408,10 @@ host(const char *s)
if_name[0] = '\0';
if_name++;
}
+
if ((p = strrchr(ps, '/')) != NULL) {
+ if ((r = strdup(ps)) == NULL)
+ err(1, "host: strdup");
mask = strtol(p+1, &q, 0);
if (!q || *q || mask > 128 || q == (p+1)) {
fprintf(stderr, "invalid netmask '%s'\n", p);
@@ -1416,15 +1419,18 @@ host(const char *s)
}
p[0] = '\0';
v4mask = v6mask = mask;
- }
+ } else
+ r = ps;
/* interface with this name exists? */
if (cont && (h = host_if(ps, mask)) != NULL)
cont = 0;
/* IPv4 address? */
- if (cont && (h = host_v4(ps, mask)) != NULL)
+ if (cont && (h = host_v4(r, mask)) != NULL)
cont = 0;
+ if (r != ps)
+ free(r);
/* IPv6 address? */
if (cont && (h = host_v6(ps, v6mask)) != NULL)