diff options
author | Henning Brauer <henning@cvs.openbsd.org> | 2002-11-07 17:47:34 +0000 |
---|---|---|
committer | Henning Brauer <henning@cvs.openbsd.org> | 2002-11-07 17:47:34 +0000 |
commit | 506b0703f01d3988bb192476b167947af1d35407 (patch) | |
tree | d177b5f0b8099c0f4f78e3d0a4132f71ab6ecc55 /sbin/pfctl | |
parent | 921ebf7436ec0e7de1b52b155b6769cc8ea581fb (diff) |
move the ifa_exists block a bit up in host()
inspired by mpech@ pointing out a missing free(buf). so handle the
it-is-an-interface case where we don't need the buf before allocating memory.
Diffstat (limited to 'sbin/pfctl')
-rw-r--r-- | sbin/pfctl/parse.y | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/sbin/pfctl/parse.y b/sbin/pfctl/parse.y index 8c5075ada68..cca8648869a 100644 --- a/sbin/pfctl/parse.y +++ b/sbin/pfctl/parse.y @@ -1,4 +1,4 @@ -/* $OpenBSD: parse.y,v 1.181 2002/11/04 22:46:28 henning Exp $ */ +/* $OpenBSD: parse.y,v 1.182 2002/11/07 17:47:33 henning Exp $ */ /* * Copyright (c) 2001 Markus Friedl. All rights reserved. @@ -2916,6 +2916,14 @@ host(char *s, int mask) int bits, error, v4mask, v6mask; char *buf; + if (ifa_exists(s) || !strncmp(s, "self", IFNAMSIZ)) { + /* interface with this name exists */ + h = ifa_lookup(s, PFCTL_IFLOOKUP_HOST); + if (h != NULL && mask > -1) + set_ipmask(h, mask); + return (h); + } + if (mask == -1) { if (asprintf(&buf, "%s", s) == -1) err(1, "host: malloc"); @@ -2930,14 +2938,6 @@ host(char *s, int mask) return (NULL); } - if (ifa_exists(s) || !strncmp(s, "self", IFNAMSIZ)) { - /* interface with this name exists */ - h = ifa_lookup(s, PFCTL_IFLOOKUP_HOST); - if (h != NULL && mask > -1) - set_ipmask(h, mask); - return (h); - } - memset(&ina, 0, sizeof(struct in_addr)); if ((bits = inet_net_pton(AF_INET, buf, &ina, sizeof(&ina))) > -1) { h = calloc(1, sizeof(struct node_host)); |