summaryrefslogtreecommitdiff
path: root/sbin/pflogd
diff options
context:
space:
mode:
authorLawrence Teo <lteo@cvs.openbsd.org>2012-11-06 02:50:48 +0000
committerLawrence Teo <lteo@cvs.openbsd.org>2012-11-06 02:50:48 +0000
commitaa2184490ccb49220bb0345ef2ec5733aa382bdc (patch)
tree55d2f9231febd47b82b74902680c939e5a90e094 /sbin/pflogd
parent6849461451065e29fc0110f1e7ca1e598f15db3a (diff)
Ensure that if_exists() always closes its socket before returning.
Also fix a bug where the return value of if_exists() was not checked correctly if the interface disappears while pflogd is running. ok beck henning
Diffstat (limited to 'sbin/pflogd')
-rw-r--r--sbin/pflogd/pflogd.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/sbin/pflogd/pflogd.c b/sbin/pflogd/pflogd.c
index 0d42955e6e4..6888a28310c 100644
--- a/sbin/pflogd/pflogd.c
+++ b/sbin/pflogd/pflogd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pflogd.c,v 1.48 2012/03/05 11:50:16 henning Exp $ */
+/* $OpenBSD: pflogd.c,v 1.49 2012/11/06 02:50:47 lteo Exp $ */
/*
* Copyright (c) 2001 Theo de Raadt
@@ -203,7 +203,7 @@ set_pcap_filter(void)
int
if_exists(char *ifname)
{
- int s;
+ int s, ret = 1;
struct ifreq ifr;
struct if_data ifrdat;
@@ -215,11 +215,11 @@ if_exists(char *ifname)
errx(1, "main ifr_name: strlcpy");
ifr.ifr_data = (caddr_t)&ifrdat;
if (ioctl(s, SIOCGIFDATA, (caddr_t)&ifr) == -1)
- return (0);
+ ret = 0;
if (close(s))
err(1, "close");
- return (1);
+ return (ret);
}
int
@@ -690,7 +690,7 @@ main(int argc, char **argv)
np = pcap_dispatch(hpcap, PCAP_NUM_PKTS,
phandler, (u_char *)dpcap);
if (np < 0) {
- if (!if_exists(interface) == -1) {
+ if (!if_exists(interface)) {
logmsg(LOG_NOTICE, "interface %s went away",
interface);
ret = -1;