diff options
author | Joel Knight <joel@cvs.openbsd.org> | 2012-05-28 20:55:41 +0000 |
---|---|---|
committer | Joel Knight <joel@cvs.openbsd.org> | 2012-05-28 20:55:41 +0000 |
commit | 0318623ea5e73c19426dd575773ed902966ef2b9 (patch) | |
tree | c842ed25661f16d1db9bf893ece011e1f74a0ec8 /usr.sbin/snmpd | |
parent | 4c29e05b74e3c6115915a1e27bc29e124a18ef29 (diff) |
Plug a couple more fd leaks. As part of the fix, make all the *init
functions return void.
ok krw@
Diffstat (limited to 'usr.sbin/snmpd')
-rw-r--r-- | usr.sbin/snmpd/kroute.c | 20 | ||||
-rw-r--r-- | usr.sbin/snmpd/pf.c | 8 | ||||
-rw-r--r-- | usr.sbin/snmpd/snmpd.c | 5 | ||||
-rw-r--r-- | usr.sbin/snmpd/snmpd.h | 6 |
4 files changed, 16 insertions, 23 deletions
diff --git a/usr.sbin/snmpd/kroute.c b/usr.sbin/snmpd/kroute.c index d5e3b100cf6..728488751c7 100644 --- a/usr.sbin/snmpd/kroute.c +++ b/usr.sbin/snmpd/kroute.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kroute.c,v 1.17 2011/04/21 14:55:22 sthen Exp $ */ +/* $OpenBSD: kroute.c,v 1.18 2012/05/28 20:55:40 joel Exp $ */ /* * Copyright (c) 2007, 2008 Reyk Floeter <reyk@vantronix.net> @@ -141,21 +141,17 @@ RB_HEAD(ka_tree, kif_addr) kat; RB_PROTOTYPE(ka_tree, kif_addr, node, ka_compare) RB_GENERATE(ka_tree, kif_addr, node, ka_compare) -int +void kr_init(void) { int opt = 0, rcvbuf, default_rcvbuf; socklen_t optlen; - if ((kr_state.ks_ifd = socket(AF_INET, SOCK_DGRAM, 0)) == -1) { - log_warn("kr_init: ioctl socket"); - return (-1); - } + if ((kr_state.ks_ifd = socket(AF_INET, SOCK_DGRAM, 0)) == -1) + fatal("kr_init: ioctl socket"); - if ((kr_state.ks_fd = socket(AF_ROUTE, SOCK_RAW, 0)) == -1) { - log_warn("kr_init: route socket"); - return (-1); - } + if ((kr_state.ks_fd = socket(AF_ROUTE, SOCK_RAW, 0)) == -1) + fatal("kr_init: route socket"); /* not interested in my own messages */ if (setsockopt(kr_state.ks_fd, SOL_SOCKET, SO_USELOOPBACK, @@ -185,9 +181,9 @@ kr_init(void) RB_INIT(&kat); if (fetchifs(0) == -1) - return (-1); + fatalx("kr_init fetchifs"); if (fetchtable() == -1) - return (-1); + fatalx("kr_init fetchtable"); event_set(&kr_state.ks_ev, kr_state.ks_fd, EV_READ | EV_PERSIST, dispatch_rtmsg, NULL); diff --git a/usr.sbin/snmpd/pf.c b/usr.sbin/snmpd/pf.c index 9b38a29f86f..9700a496937 100644 --- a/usr.sbin/snmpd/pf.c +++ b/usr.sbin/snmpd/pf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pf.c,v 1.3 2012/05/26 14:45:55 joel Exp $ */ +/* $OpenBSD: pf.c,v 1.4 2012/05/28 20:55:40 joel Exp $ */ /* * Copyright (c) 2012 Joel Knight <joel@openbsd.org> @@ -59,13 +59,11 @@ size_t buf_esize[PFRB_MAX] = { 0, sizeof(struct pfi_kif), sizeof(struct pfioc_trans_e) }; -int +void pf_init(void) { if ((devpf = open("/dev/pf", O_RDONLY)) == -1) - return (1); - - return (0); + fatal("pf_init"); } int diff --git a/usr.sbin/snmpd/snmpd.c b/usr.sbin/snmpd/snmpd.c index 1c8d1c2897b..b1d70834846 100644 --- a/usr.sbin/snmpd/snmpd.c +++ b/usr.sbin/snmpd/snmpd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: snmpd.c,v 1.10 2012/02/23 03:54:38 joel Exp $ */ +/* $OpenBSD: snmpd.c,v 1.11 2012/05/28 20:55:40 joel Exp $ */ /* * Copyright (c) 2007, 2008 Reyk Floeter <reyk@vantronix.net> @@ -174,8 +174,7 @@ main(int argc, char *argv[]) log_info("startup"); - if (pf_init()) - fatal("cannot open /dev/pf"); + pf_init(); if (socketpair(AF_UNIX, SOCK_STREAM, PF_UNSPEC, pipe_parent2snmpe) == -1) diff --git a/usr.sbin/snmpd/snmpd.h b/usr.sbin/snmpd/snmpd.h index 6b67ddd1eb6..3e2a7cd53af 100644 --- a/usr.sbin/snmpd/snmpd.h +++ b/usr.sbin/snmpd/snmpd.h @@ -1,4 +1,4 @@ -/* $OpenBSD: snmpd.h,v 1.34 2012/04/08 02:57:40 deraadt Exp $ */ +/* $OpenBSD: snmpd.h,v 1.35 2012/05/28 20:55:40 joel Exp $ */ /* * Copyright (c) 2007, 2008 Reyk Floeter <reyk@vantronix.net> @@ -363,7 +363,7 @@ int imsg_compose_event(struct imsgev *, enum imsg_type, u_int32_t, pid_t, int, void *, u_int16_t); /* kroute.c */ -int kr_init(void); +void kr_init(void); void kr_shutdown(void); u_int kr_ifnumber(void); @@ -410,7 +410,7 @@ void mps_decodeinaddr(struct ber_oid *, struct in_addr *, int); struct ber_oid *mps_table(struct oid *, struct ber_oid *, struct ber_oid *); /* pf.c */ -int pf_init(void); +void pf_init(void); int pf_get_stats(struct pf_status *); int pfr_get_astats(struct pfr_table *, struct pfr_astats *, int *, int); |