From d54f1ade2567f1c6dc26b339312d1336d564a152 Mon Sep 17 00:00:00 2001 From: Claudio Jeker Date: Thu, 21 Nov 2024 13:38:16 +0000 Subject: Convert simple stuff in usr.sbin over to new imsgbuf_init behaviour OK tb@ --- usr.sbin/bgpctl/bgpctl.c | 5 +++-- usr.sbin/bgpd/bgpd.c | 12 ++++++++---- usr.sbin/bgpd/control.c | 9 +++++++-- usr.sbin/bgpd/rde.c | 9 ++++++--- usr.sbin/bgpd/rtr.c | 9 ++++++--- usr.sbin/bgpd/session.c | 9 ++++++--- usr.sbin/dhcp6leasectl/dhcp6leasectl.c | 5 +++-- usr.sbin/dhcpleasectl/dhcpleasectl.c | 5 +++-- usr.sbin/dvmrpctl/dvmrpctl.c | 5 +++-- usr.sbin/dvmrpd/control.c | 10 ++++++++-- usr.sbin/dvmrpd/dvmrpd.c | 7 ++++--- usr.sbin/dvmrpd/dvmrpe.c | 8 +++++--- usr.sbin/dvmrpd/rde.c | 8 +++++--- usr.sbin/eigrpctl/eigrpctl.c | 5 +++-- usr.sbin/eigrpd/control.c | 9 +++++++-- usr.sbin/eigrpd/eigrpd.c | 10 +++++++--- usr.sbin/eigrpd/eigrpe.c | 9 ++++++--- usr.sbin/eigrpd/rde.c | 9 ++++++--- usr.sbin/ikectl/ikectl.c | 5 +++-- usr.sbin/ldapctl/ldapctl.c | 5 +++-- usr.sbin/ldpctl/ldpctl.c | 5 +++-- usr.sbin/ldpd/control.c | 10 ++++++++-- usr.sbin/ldpd/lde.c | 9 ++++++--- usr.sbin/ldpd/ldpd.c | 10 +++++++--- usr.sbin/ldpd/ldpe.c | 9 ++++++--- usr.sbin/ntpd/constraint.c | 8 +++++--- usr.sbin/ntpd/control.c | 9 +++++++-- usr.sbin/ntpd/ntp.c | 8 +++++--- usr.sbin/ntpd/ntp_dns.c | 5 +++-- usr.sbin/ntpd/ntpd.c | 8 +++++--- usr.sbin/ospf6ctl/ospf6ctl.c | 5 +++-- usr.sbin/ospf6d/control.c | 9 +++++++-- usr.sbin/ospf6d/ospf6d.c | 9 ++++++--- usr.sbin/ospf6d/ospfe.c | 9 ++++++--- usr.sbin/ospf6d/rde.c | 8 +++++--- usr.sbin/ospfctl/ospfctl.c | 5 +++-- usr.sbin/ospfd/control.c | 9 +++++++-- usr.sbin/ospfd/ospfd.c | 9 ++++++--- usr.sbin/ospfd/ospfe.c | 9 ++++++--- usr.sbin/ospfd/rde.c | 8 +++++--- usr.sbin/ractl/ractl.c | 5 +++-- usr.sbin/rad/control.c | 9 +++++++-- usr.sbin/rad/engine.c | 9 ++++++--- usr.sbin/rad/frontend.c | 9 ++++++--- usr.sbin/rad/rad.c | 10 +++++++--- usr.sbin/relayctl/relayctl.c | 5 +++-- usr.sbin/ripctl/ripctl.c | 5 +++-- usr.sbin/ripd/control.c | 9 +++++++-- usr.sbin/ripd/rde.c | 8 +++++--- usr.sbin/ripd/ripd.c | 8 +++++--- usr.sbin/ripd/ripe.c | 8 +++++--- usr.sbin/slaacctl/slaacctl.c | 5 +++-- usr.sbin/unwindctl/unwindctl.c | 5 +++-- usr.sbin/ypldap/ldapclient.c | 8 +++++--- usr.sbin/ypldap/ypldap.c | 5 +++-- usr.sbin/ypldap/ypldap_dns.c | 5 +++-- 56 files changed, 285 insertions(+), 142 deletions(-) diff --git a/usr.sbin/bgpctl/bgpctl.c b/usr.sbin/bgpctl/bgpctl.c index 3bac478540d..cc0aa5e7ac3 100644 --- a/usr.sbin/bgpctl/bgpctl.c +++ b/usr.sbin/bgpctl/bgpctl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bgpctl.c,v 1.310 2024/11/21 13:26:25 claudio Exp $ */ +/* $OpenBSD: bgpctl.c,v 1.311 2024/11/21 13:38:14 claudio Exp $ */ /* * Copyright (c) 2003 Henning Brauer @@ -176,7 +176,8 @@ main(int argc, char *argv[]) if ((imsgbuf = malloc(sizeof(struct imsgbuf))) == NULL) err(1, NULL); - imsgbuf_init(imsgbuf, fd); + if (imsgbuf_init(imsgbuf, fd) == -1) + err(1, NULL); done = 0; switch (res->action) { diff --git a/usr.sbin/bgpd/bgpd.c b/usr.sbin/bgpd/bgpd.c index 6e5836a10e5..a9ebed12a9c 100644 --- a/usr.sbin/bgpd/bgpd.c +++ b/usr.sbin/bgpd/bgpd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bgpd.c,v 1.276 2024/11/21 13:22:21 claudio Exp $ */ +/* $OpenBSD: bgpd.c,v 1.277 2024/11/21 13:38:14 claudio Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer @@ -276,9 +276,13 @@ main(int argc, char *argv[]) (ibuf_rde = malloc(sizeof(struct imsgbuf))) == NULL || (ibuf_rtr = malloc(sizeof(struct imsgbuf))) == NULL) fatal(NULL); - imsgbuf_init(ibuf_se, pipe_m2s[0]); - imsgbuf_init(ibuf_rde, pipe_m2r[0]); - imsgbuf_init(ibuf_rtr, pipe_m2roa[0]); + if (imsgbuf_init(ibuf_se, pipe_m2s[0]) == -1 || + imsgbuf_init(ibuf_rde, pipe_m2r[0]) == -1 || + imsgbuf_init(ibuf_rtr, pipe_m2roa[0]) == -1) + fatal(NULL); + imsgbuf_allow_fdpass(ibuf_se); + imsgbuf_allow_fdpass(ibuf_rde); + imsgbuf_allow_fdpass(ibuf_rtr); mrt_init(ibuf_rde, ibuf_se); if (kr_init(&rfd, conf->fib_priority) == -1) quit = 1; diff --git a/usr.sbin/bgpd/control.c b/usr.sbin/bgpd/control.c index 783fed2362e..1f97ee731de 100644 --- a/usr.sbin/bgpd/control.c +++ b/usr.sbin/bgpd/control.c @@ -1,4 +1,4 @@ -/* $OpenBSD: control.c,v 1.130 2024/11/21 13:33:41 claudio Exp $ */ +/* $OpenBSD: control.c,v 1.131 2024/11/21 13:38:14 claudio Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer @@ -180,7 +180,12 @@ control_accept(int listenfd, int restricted) return (0); } - imsgbuf_init(&ctl_conn->imsgbuf, connfd); + if (imsgbuf_init(&ctl_conn->imsgbuf, connfd) == -1) { + log_warn("control_accept"); + close(connfd); + free(ctl_conn); + return (0); + } ctl_conn->restricted = restricted; TAILQ_INSERT_TAIL(&ctl_conns, ctl_conn, entry); diff --git a/usr.sbin/bgpd/rde.c b/usr.sbin/bgpd/rde.c index 3dafcd68d7f..816249ab844 100644 --- a/usr.sbin/bgpd/rde.c +++ b/usr.sbin/bgpd/rde.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rde.c,v 1.639 2024/11/21 13:29:52 claudio Exp $ */ +/* $OpenBSD: rde.c,v 1.640 2024/11/21 13:38:14 claudio Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer @@ -201,7 +201,9 @@ rde_main(int debug, int verbose) if ((ibuf_main = malloc(sizeof(struct imsgbuf))) == NULL) fatal(NULL); - imsgbuf_init(ibuf_main, 3); + if (imsgbuf_init(ibuf_main, 3) == -1) + fatal(NULL); + imsgbuf_allow_fdpass(ibuf_main); /* initialize the RIB structures */ if ((out_rules = calloc(1, sizeof(struct filter_head))) == NULL) @@ -842,7 +844,8 @@ rde_dispatch_imsg_parent(struct imsgbuf *imsgbuf) } if ((i = malloc(sizeof(struct imsgbuf))) == NULL) fatal(NULL); - imsgbuf_init(i, fd); + if (imsgbuf_init(i, fd) == -1) + fatal(NULL); switch (imsg_get_type(&imsg)) { case IMSG_SOCKET_CONN: if (ibuf_se) { diff --git a/usr.sbin/bgpd/rtr.c b/usr.sbin/bgpd/rtr.c index 1a53d77edd7..b01e32bd74d 100644 --- a/usr.sbin/bgpd/rtr.c +++ b/usr.sbin/bgpd/rtr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rtr.c,v 1.26 2024/11/21 13:17:57 claudio Exp $ */ +/* $OpenBSD: rtr.c,v 1.27 2024/11/21 13:38:14 claudio Exp $ */ /* * Copyright (c) 2020 Claudio Jeker @@ -219,7 +219,9 @@ rtr_main(int debug, int verbose) if ((ibuf_main = malloc(sizeof(struct imsgbuf))) == NULL) fatal(NULL); - imsgbuf_init(ibuf_main, 3); + if (imsgbuf_init(ibuf_main, 3) == -1) + fatal(NULL); + imsgbuf_allow_fdpass(ibuf_main); conf = new_config(); log_info("rtr engine ready"); @@ -336,7 +338,8 @@ rtr_dispatch_imsg_parent(struct imsgbuf *imsgbuf) } if ((ibuf_rde = malloc(sizeof(struct imsgbuf))) == NULL) fatal(NULL); - imsgbuf_init(ibuf_rde, fd); + if (imsgbuf_init(ibuf_rde, fd) == -1) + fatal(NULL); break; case IMSG_SOCKET_SETUP: if ((fd = imsg_get_fd(&imsg)) == -1) { diff --git a/usr.sbin/bgpd/session.c b/usr.sbin/bgpd/session.c index 2429feef868..43a9eb2da2d 100644 --- a/usr.sbin/bgpd/session.c +++ b/usr.sbin/bgpd/session.c @@ -1,4 +1,4 @@ -/* $OpenBSD: session.c,v 1.497 2024/11/21 13:34:30 claudio Exp $ */ +/* $OpenBSD: session.c,v 1.498 2024/11/21 13:38:14 claudio Exp $ */ /* * Copyright (c) 2003, 2004, 2005 Henning Brauer @@ -240,7 +240,9 @@ session_main(int debug, int verbose) if ((ibuf_main = malloc(sizeof(struct imsgbuf))) == NULL) fatal(NULL); - imsgbuf_init(ibuf_main, 3); + if (imsgbuf_init(ibuf_main, 3) == -1) + fatal(NULL); + imsgbuf_allow_fdpass(ibuf_main); LIST_INIT(&mrthead); listener_cnt = 0; @@ -2845,7 +2847,8 @@ session_dispatch_imsg(struct imsgbuf *imsgbuf, int idx, u_int *listener_cnt) } if ((i = malloc(sizeof(struct imsgbuf))) == NULL) fatal(NULL); - imsgbuf_init(i, fd); + if (imsgbuf_init(i, fd) == -1) + fatal(NULL); if (imsg_get_type(&imsg) == IMSG_SOCKET_CONN) { if (ibuf_rde) { log_warnx("Unexpected imsg connection " diff --git a/usr.sbin/dhcp6leasectl/dhcp6leasectl.c b/usr.sbin/dhcp6leasectl/dhcp6leasectl.c index 4a2f10385c2..e752a7ab197 100644 --- a/usr.sbin/dhcp6leasectl/dhcp6leasectl.c +++ b/usr.sbin/dhcp6leasectl/dhcp6leasectl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dhcp6leasectl.c,v 1.5 2024/11/21 13:26:25 claudio Exp $ */ +/* $OpenBSD: dhcp6leasectl.c,v 1.6 2024/11/21 13:38:14 claudio Exp $ */ /* * Copyright (c) 2021, 2024 Florian Obser @@ -122,7 +122,8 @@ main(int argc, char *argv[]) if ((ibuf = malloc(sizeof(struct imsgbuf))) == NULL) err(1, NULL); - imsgbuf_init(ibuf, ctl_sock); + if (imsgbuf_init(ibuf, ctl_sock) == -1) + err(1, NULL); if (!lFlag) { imsg_compose(ibuf, IMSG_CTL_SEND_REQUEST, 0, 0, -1, diff --git a/usr.sbin/dhcpleasectl/dhcpleasectl.c b/usr.sbin/dhcpleasectl/dhcpleasectl.c index 3f679f1a9f4..b31e3b55345 100644 --- a/usr.sbin/dhcpleasectl/dhcpleasectl.c +++ b/usr.sbin/dhcpleasectl/dhcpleasectl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dhcpleasectl.c,v 1.12 2024/11/21 13:26:25 claudio Exp $ */ +/* $OpenBSD: dhcpleasectl.c,v 1.13 2024/11/21 13:38:14 claudio Exp $ */ /* * Copyright (c) 2021 Florian Obser @@ -156,7 +156,8 @@ main(int argc, char *argv[]) if ((ibuf = malloc(sizeof(struct imsgbuf))) == NULL) err(1, NULL); - imsgbuf_init(ibuf, ctl_sock); + if (imsgbuf_init(ibuf, ctl_sock) == -1) + err(1, NULL); if (!lFlag) { imsg_compose(ibuf, IMSG_CTL_SEND_REQUEST, 0, 0, -1, diff --git a/usr.sbin/dvmrpctl/dvmrpctl.c b/usr.sbin/dvmrpctl/dvmrpctl.c index ed56c011f8f..d603fb71d5b 100644 --- a/usr.sbin/dvmrpctl/dvmrpctl.c +++ b/usr.sbin/dvmrpctl/dvmrpctl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dvmrpctl.c,v 1.20 2024/11/21 13:26:25 claudio Exp $ */ +/* $OpenBSD: dvmrpctl.c,v 1.21 2024/11/21 13:38:14 claudio Exp $ */ /* * Copyright (c) 2005 Claudio Jeker @@ -100,7 +100,8 @@ main(int argc, char *argv[]) if ((ibuf = malloc(sizeof(struct imsgbuf))) == NULL) fatal(NULL); - imsgbuf_init(ibuf, ctl_sock); + if (imsgbuf_init(ibuf, ctl_sock) == -1) + fatal(NULL); done = 0; /* process user request */ diff --git a/usr.sbin/dvmrpd/control.c b/usr.sbin/dvmrpd/control.c index 3287410740b..53926253b40 100644 --- a/usr.sbin/dvmrpd/control.c +++ b/usr.sbin/dvmrpd/control.c @@ -1,4 +1,4 @@ -/* $OpenBSD: control.c,v 1.30 2024/11/21 13:21:34 claudio Exp $ */ +/* $OpenBSD: control.c,v 1.31 2024/11/21 13:38:14 claudio Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer @@ -152,7 +152,13 @@ control_accept(int listenfd, short event, void *bula) return; } - imsgbuf_init(&c->iev.ibuf, connfd); + if (imsgbuf_init(&c->iev.ibuf, connfd) == -1) { + log_warn("control_accept"); + close(connfd); + free(c); + return; + } + c->iev.handler = control_dispatch_imsg; c->iev.events = EV_READ; event_set(&c->iev.ev, c->iev.ibuf.fd, c->iev.events, diff --git a/usr.sbin/dvmrpd/dvmrpd.c b/usr.sbin/dvmrpd/dvmrpd.c index 518b2aca682..8aa4cc5ff61 100644 --- a/usr.sbin/dvmrpd/dvmrpd.c +++ b/usr.sbin/dvmrpd/dvmrpd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dvmrpd.c,v 1.33 2024/11/21 13:21:34 claudio Exp $ */ +/* $OpenBSD: dvmrpd.c,v 1.34 2024/11/21 13:38:14 claudio Exp $ */ /* * Copyright (c) 2005 Claudio Jeker @@ -234,8 +234,9 @@ main(int argc, char *argv[]) if ((iev_dvmrpe = malloc(sizeof(struct imsgev))) == NULL || (iev_rde = malloc(sizeof(struct imsgev))) == NULL) fatal(NULL); - imsgbuf_init(&iev_dvmrpe->ibuf, pipe_parent2dvmrpe[0]); - imsgbuf_init(&iev_rde->ibuf, pipe_parent2rde[0]); + if (imsgbuf_init(&iev_dvmrpe->ibuf, pipe_parent2dvmrpe[0]) == -1 || + imsgbuf_init(&iev_rde->ibuf, pipe_parent2rde[0]) == -1) + fatal(NULL); iev_dvmrpe->handler = main_dispatch_dvmrpe; iev_rde->handler = main_dispatch_rde; diff --git a/usr.sbin/dvmrpd/dvmrpe.c b/usr.sbin/dvmrpd/dvmrpe.c index 48573ba86a9..5b8862f95b9 100644 --- a/usr.sbin/dvmrpd/dvmrpe.c +++ b/usr.sbin/dvmrpd/dvmrpe.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dvmrpe.c,v 1.29 2024/11/21 13:21:34 claudio Exp $ */ +/* $OpenBSD: dvmrpe.c,v 1.30 2024/11/21 13:38:14 claudio Exp $ */ /* * Copyright (c) 2005 Claudio Jeker @@ -143,10 +143,12 @@ dvmrpe(struct dvmrpd_conf *xconf, int pipe_parent2dvmrpe[2], if ((iev_rde = malloc(sizeof(struct imsgev))) == NULL || (iev_main = malloc(sizeof(struct imsgev))) == NULL) fatal(NULL); - imsgbuf_init(&iev_rde->ibuf, pipe_dvmrpe2rde[0]); + if (imsgbuf_init(&iev_rde->ibuf, pipe_dvmrpe2rde[0]) == -1) + fatal(NULL); iev_rde->handler = dvmrpe_dispatch_rde; - imsgbuf_init(&iev_main->ibuf, pipe_parent2dvmrpe[1]); + if (imsgbuf_init(&iev_main->ibuf, pipe_parent2dvmrpe[1]) == -1) + fatal(NULL); iev_main->handler = dvmrpe_dispatch_main; /* setup event handler */ diff --git a/usr.sbin/dvmrpd/rde.c b/usr.sbin/dvmrpd/rde.c index 0eafee6028a..3929cf5e8fd 100644 --- a/usr.sbin/dvmrpd/rde.c +++ b/usr.sbin/dvmrpd/rde.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rde.c,v 1.38 2024/11/21 13:21:34 claudio Exp $ */ +/* $OpenBSD: rde.c,v 1.39 2024/11/21 13:38:14 claudio Exp $ */ /* * Copyright (c) 2004, 2005 Claudio Jeker @@ -123,10 +123,12 @@ rde(struct dvmrpd_conf *xconf, int pipe_parent2rde[2], int pipe_dvmrpe2rde[2], (iev_main = malloc(sizeof(struct imsgev))) == NULL) fatal(NULL); - imsgbuf_init(&iev_dvmrpe->ibuf, pipe_dvmrpe2rde[1]); + if (imsgbuf_init(&iev_dvmrpe->ibuf, pipe_dvmrpe2rde[1]) == -1) + fatal(NULL); iev_dvmrpe->handler = rde_dispatch_imsg; - imsgbuf_init(&iev_main->ibuf, pipe_parent2rde[1]); + if (imsgbuf_init(&iev_main->ibuf, pipe_parent2rde[1]) == -1) + fatal(NULL); iev_main->handler = rde_dispatch_imsg; /* setup event handler */ diff --git a/usr.sbin/eigrpctl/eigrpctl.c b/usr.sbin/eigrpctl/eigrpctl.c index cec884ef8c9..521ccb9485c 100644 --- a/usr.sbin/eigrpctl/eigrpctl.c +++ b/usr.sbin/eigrpctl/eigrpctl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: eigrpctl.c,v 1.13 2024/11/21 13:26:25 claudio Exp $ */ +/* $OpenBSD: eigrpctl.c,v 1.14 2024/11/21 13:38:14 claudio Exp $ */ /* * Copyright (c) 2015 Renato Westphal @@ -121,7 +121,8 @@ main(int argc, char *argv[]) if ((ibuf = malloc(sizeof(struct imsgbuf))) == NULL) err(1, NULL); - imsgbuf_init(ibuf, ctl_sock); + if (imsgbuf_init(ibuf, ctl_sock) == -1) + err(1, NULL); done = 0; /* process user request */ diff --git a/usr.sbin/eigrpd/control.c b/usr.sbin/eigrpd/control.c index ad56b64c155..f525c80d532 100644 --- a/usr.sbin/eigrpd/control.c +++ b/usr.sbin/eigrpd/control.c @@ -1,4 +1,4 @@ -/* $OpenBSD: control.c,v 1.15 2024/11/21 13:21:34 claudio Exp $ */ +/* $OpenBSD: control.c,v 1.16 2024/11/21 13:38:14 claudio Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer @@ -144,7 +144,12 @@ control_accept(int listenfd, short event, void *bula) return; } - imsgbuf_init(&c->iev.ibuf, connfd); + if (imsgbuf_init(&c->iev.ibuf, connfd) == -1) { + log_warn("%s: imsgbuf_init", __func__); + close(connfd); + free(c); + return; + } c->iev.handler = control_dispatch_imsg; c->iev.events = EV_READ; event_set(&c->iev.ev, c->iev.ibuf.fd, c->iev.events, diff --git a/usr.sbin/eigrpd/eigrpd.c b/usr.sbin/eigrpd/eigrpd.c index 03b2b99ca50..d9946bb9389 100644 --- a/usr.sbin/eigrpd/eigrpd.c +++ b/usr.sbin/eigrpd/eigrpd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: eigrpd.c,v 1.35 2024/11/21 13:21:34 claudio Exp $ */ +/* $OpenBSD: eigrpd.c,v 1.36 2024/11/21 13:38:14 claudio Exp $ */ /* * Copyright (c) 2015 Renato Westphal @@ -240,9 +240,13 @@ main(int argc, char *argv[]) if ((iev_eigrpe = malloc(sizeof(struct imsgev))) == NULL || (iev_rde = malloc(sizeof(struct imsgev))) == NULL) fatal(NULL); - imsgbuf_init(&iev_eigrpe->ibuf, pipe_parent2eigrpe[0]); + if (imsgbuf_init(&iev_eigrpe->ibuf, pipe_parent2eigrpe[0]) == -1) + fatal(NULL); + imsgbuf_allow_fdpass(&iev_eigrpe->ibuf); iev_eigrpe->handler = main_dispatch_eigrpe; - imsgbuf_init(&iev_rde->ibuf, pipe_parent2rde[0]); + if (imsgbuf_init(&iev_rde->ibuf, pipe_parent2rde[0]) == -1) + fatal(NULL); + imsgbuf_allow_fdpass(&iev_rde->ibuf); iev_rde->handler = main_dispatch_rde; /* setup event handler */ diff --git a/usr.sbin/eigrpd/eigrpe.c b/usr.sbin/eigrpd/eigrpe.c index f4232109018..b5dedb798ee 100644 --- a/usr.sbin/eigrpd/eigrpe.c +++ b/usr.sbin/eigrpd/eigrpe.c @@ -1,4 +1,4 @@ -/* $OpenBSD: eigrpe.c,v 1.46 2024/11/21 13:21:34 claudio Exp $ */ +/* $OpenBSD: eigrpe.c,v 1.47 2024/11/21 13:38:14 claudio Exp $ */ /* * Copyright (c) 2015 Renato Westphal @@ -146,7 +146,9 @@ eigrpe(int debug, int verbose, char *sockname) /* setup pipe and event handler to the parent process */ if ((iev_main = malloc(sizeof(struct imsgev))) == NULL) fatal(NULL); - imsgbuf_init(&iev_main->ibuf, 3); + if (imsgbuf_init(&iev_main->ibuf, 3) == -1) + fatal(NULL); + imsgbuf_allow_fdpass(&iev_main->ibuf); iev_main->handler = eigrpe_dispatch_main; iev_main->events = EV_READ; event_set(&iev_main->ev, iev_main->ibuf.fd, iev_main->events, @@ -300,7 +302,8 @@ eigrpe_dispatch_main(int fd, short event, void *bula) iev_rde = malloc(sizeof(struct imsgev)); if (iev_rde == NULL) fatal(NULL); - imsgbuf_init(&iev_rde->ibuf, fd); + if (imsgbuf_init(&iev_rde->ibuf, fd) == -1) + fatal(NULL); iev_rde->handler = eigrpe_dispatch_rde; iev_rde->events = EV_READ; event_set(&iev_rde->ev, iev_rde->ibuf.fd, diff --git a/usr.sbin/eigrpd/rde.c b/usr.sbin/eigrpd/rde.c index 5bcfd383c05..c931f7efd6e 100644 --- a/usr.sbin/eigrpd/rde.c +++ b/usr.sbin/eigrpd/rde.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rde.c,v 1.31 2024/11/21 13:21:34 claudio Exp $ */ +/* $OpenBSD: rde.c,v 1.32 2024/11/21 13:38:14 claudio Exp $ */ /* * Copyright (c) 2015 Renato Westphal @@ -112,7 +112,9 @@ rde(int debug, int verbose) /* setup pipe and event handler to the parent process */ if ((iev_main = malloc(sizeof(struct imsgev))) == NULL) fatal(NULL); - imsgbuf_init(&iev_main->ibuf, 3); + if (imsgbuf_init(&iev_main->ibuf, 3) == -1) + fatal(NULL); + imsgbuf_allow_fdpass(&iev_main->ibuf); iev_main->handler = rde_dispatch_parent; iev_main->events = EV_READ; event_set(&iev_main->ev, iev_main->ibuf.fd, iev_main->events, @@ -367,7 +369,8 @@ rde_dispatch_parent(int fd, short event, void *bula) iev_eigrpe = malloc(sizeof(struct imsgev)); if (iev_eigrpe == NULL) fatal(NULL); - imsgbuf_init(&iev_eigrpe->ibuf, fd); + if (imsgbuf_init(&iev_eigrpe->ibuf, fd) == -1) + fatal(NULL); iev_eigrpe->handler = rde_dispatch_imsg; iev_eigrpe->events = EV_READ; event_set(&iev_eigrpe->ev, iev_eigrpe->ibuf.fd, diff --git a/usr.sbin/ikectl/ikectl.c b/usr.sbin/ikectl/ikectl.c index 71c58fdcd2f..7da99540766 100644 --- a/usr.sbin/ikectl/ikectl.c +++ b/usr.sbin/ikectl/ikectl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ikectl.c,v 1.35 2024/11/21 13:26:25 claudio Exp $ */ +/* $OpenBSD: ikectl.c,v 1.36 2024/11/21 13:38:14 claudio Exp $ */ /* * Copyright (c) 2007-2013 Reyk Floeter @@ -250,7 +250,8 @@ main(int argc, char *argv[]) else if ((ibuf = malloc(sizeof(struct imsgbuf))) == NULL) err(1, "malloc"); - imsgbuf_init(ibuf, ctl_sock); + if (imsgbuf_init(ibuf, ctl_sock) == -1) + err(1, "imsgbuf_init"); /* process user request */ switch (res->action) { diff --git a/usr.sbin/ldapctl/ldapctl.c b/usr.sbin/ldapctl/ldapctl.c index d8d2d688c04..51a33c1fc71 100644 --- a/usr.sbin/ldapctl/ldapctl.c +++ b/usr.sbin/ldapctl/ldapctl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ldapctl.c,v 1.20 2024/11/21 13:26:25 claudio Exp $ */ +/* $OpenBSD: ldapctl.c,v 1.21 2024/11/21 13:38:14 claudio Exp $ */ /* * Copyright (c) 2009, 2010 Martin Hedenfalk @@ -328,7 +328,8 @@ main(int argc, char *argv[]) if (connect(ctl_sock, (struct sockaddr *)&sun, sizeof(sun)) == -1) err(1, "connect: %s", sock); - imsgbuf_init(&ibuf, ctl_sock); + if (imsgbuf_init(&ibuf, ctl_sock) == -1) + err(1, "imsgbuf_init"); done = 0; if (pledge("stdio", NULL) == -1) diff --git a/usr.sbin/ldpctl/ldpctl.c b/usr.sbin/ldpctl/ldpctl.c index 5319bcf9aeb..64bf4e792da 100644 --- a/usr.sbin/ldpctl/ldpctl.c +++ b/usr.sbin/ldpctl/ldpctl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ldpctl.c,v 1.36 2024/11/21 13:26:25 claudio Exp $ +/* $OpenBSD: ldpctl.c,v 1.37 2024/11/21 13:38:14 claudio Exp $ * * Copyright (c) 2009 Michele Marchetto * Copyright (c) 2005 Claudio Jeker @@ -101,7 +101,8 @@ main(int argc, char *argv[]) if ((ibuf = malloc(sizeof(struct imsgbuf))) == NULL) err(1, NULL); - imsgbuf_init(ibuf, ctl_sock); + if (imsgbuf_init(ibuf, ctl_sock) == -1) + err(1, NULL); done = 0; /* process user request */ diff --git a/usr.sbin/ldpd/control.c b/usr.sbin/ldpd/control.c index aaad9d2576f..1cbe8a9ef4b 100644 --- a/usr.sbin/ldpd/control.c +++ b/usr.sbin/ldpd/control.c @@ -1,4 +1,4 @@ -/* $OpenBSD: control.c,v 1.37 2024/11/21 13:21:34 claudio Exp $ */ +/* $OpenBSD: control.c,v 1.38 2024/11/21 13:38:14 claudio Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer @@ -133,7 +133,13 @@ control_accept(int listenfd, short event, void *bula) return; } - imsgbuf_init(&c->iev.ibuf, connfd); + if (imsgbuf_init(&c->iev.ibuf, connfd) == -1) { + log_warn(__func__); + close(connfd); + free(c); + return; + } + c->iev.handler = control_dispatch_imsg; c->iev.events = EV_READ; event_set(&c->iev.ev, c->iev.ibuf.fd, c->iev.events, diff --git a/usr.sbin/ldpd/lde.c b/usr.sbin/ldpd/lde.c index de7b65e43a7..0cd4a74559a 100644 --- a/usr.sbin/ldpd/lde.c +++ b/usr.sbin/ldpd/lde.c @@ -1,4 +1,4 @@ -/* $OpenBSD: lde.c,v 1.83 2024/11/21 13:21:34 claudio Exp $ */ +/* $OpenBSD: lde.c,v 1.84 2024/11/21 13:38:14 claudio Exp $ */ /* * Copyright (c) 2013, 2016 Renato Westphal @@ -128,7 +128,9 @@ lde(int debug, int verbose) /* setup pipe and event handler to the parent process */ if ((iev_main = malloc(sizeof(struct imsgev))) == NULL) fatal(NULL); - imsgbuf_init(&iev_main->ibuf, 3); + if (imsgbuf_init(&iev_main->ibuf, 3) == -1) + fatal(NULL); + imsgbuf_allow_fdpass(&iev_main->ibuf); iev_main->handler = lde_dispatch_parent; iev_main->events = EV_READ; event_set(&iev_main->ev, iev_main->ibuf.fd, iev_main->events, @@ -464,7 +466,8 @@ lde_dispatch_parent(int fd, short event, void *bula) if ((iev_ldpe = malloc(sizeof(struct imsgev))) == NULL) fatal(NULL); - imsgbuf_init(&iev_ldpe->ibuf, fd); + if (imsgbuf_init(&iev_ldpe->ibuf, fd) == -1) + fatal(NULL); iev_ldpe->handler = lde_dispatch_imsg; iev_ldpe->events = EV_READ; event_set(&iev_ldpe->ev, iev_ldpe->ibuf.fd, diff --git a/usr.sbin/ldpd/ldpd.c b/usr.sbin/ldpd/ldpd.c index 095194a7b3e..4032c021fde 100644 --- a/usr.sbin/ldpd/ldpd.c +++ b/usr.sbin/ldpd/ldpd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ldpd.c,v 1.78 2024/11/21 13:29:28 claudio Exp $ */ +/* $OpenBSD: ldpd.c,v 1.79 2024/11/21 13:38:14 claudio Exp $ */ /* * Copyright (c) 2013, 2016 Renato Westphal @@ -242,9 +242,13 @@ main(int argc, char *argv[]) if ((iev_ldpe = malloc(sizeof(struct imsgev))) == NULL || (iev_lde = malloc(sizeof(struct imsgev))) == NULL) fatal(NULL); - imsgbuf_init(&iev_ldpe->ibuf, pipe_parent2ldpe[0]); + if (imsgbuf_init(&iev_ldpe->ibuf, pipe_parent2ldpe[0]) == -1) + fatal(NULL); + imsgbuf_allow_fdpass(&iev_ldpe->ibuf); iev_ldpe->handler = main_dispatch_ldpe; - imsgbuf_init(&iev_lde->ibuf, pipe_parent2lde[0]); + if (imsgbuf_init(&iev_lde->ibuf, pipe_parent2lde[0]) == -1) + fatal(NULL); + imsgbuf_allow_fdpass(&iev_lde->ibuf); iev_lde->handler = main_dispatch_lde; /* setup event handler */ diff --git a/usr.sbin/ldpd/ldpe.c b/usr.sbin/ldpd/ldpe.c index cf5bc0710f4..4bdef8447f5 100644 --- a/usr.sbin/ldpd/ldpe.c +++ b/usr.sbin/ldpd/ldpe.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ldpe.c,v 1.87 2024/11/21 13:21:34 claudio Exp $ */ +/* $OpenBSD: ldpe.c,v 1.88 2024/11/21 13:38:14 claudio Exp $ */ /* * Copyright (c) 2013, 2016 Renato Westphal @@ -123,7 +123,9 @@ ldpe(int debug, int verbose, char *sockname) /* setup pipe and event handler to the parent process */ if ((iev_main = malloc(sizeof(struct imsgev))) == NULL) fatal(NULL); - imsgbuf_init(&iev_main->ibuf, 3); + if (imsgbuf_init(&iev_main->ibuf, 3) == -1) + fatal(NULL); + imsgbuf_allow_fdpass(&iev_main->ibuf); iev_main->handler = ldpe_dispatch_main; iev_main->events = EV_READ; event_set(&iev_main->ev, iev_main->ibuf.fd, iev_main->events, @@ -306,7 +308,8 @@ ldpe_dispatch_main(int fd, short event, void *bula) if ((iev_lde = malloc(sizeof(struct imsgev))) == NULL) fatal(NULL); - imsgbuf_init(&iev_lde->ibuf, fd); + if (imsgbuf_init(&iev_lde->ibuf, fd) == -1) + fatal(NULL); iev_lde->handler = ldpe_dispatch_lde; iev_lde->events = EV_READ; event_set(&iev_lde->ev, iev_lde->ibuf.fd, diff --git a/usr.sbin/ntpd/constraint.c b/usr.sbin/ntpd/constraint.c index 993541f9381..7ecbc18920f 100644 --- a/usr.sbin/ntpd/constraint.c +++ b/usr.sbin/ntpd/constraint.c @@ -1,4 +1,4 @@ -/* $OpenBSD: constraint.c,v 1.59 2024/11/21 13:25:01 claudio Exp $ */ +/* $OpenBSD: constraint.c,v 1.60 2024/11/21 13:38:14 claudio Exp $ */ /* * Copyright (c) 2015 Reyk Floeter @@ -270,7 +270,8 @@ priv_constraint_msg(u_int32_t id, u_int8_t *data, size_t len, int argc, /* Prepare and send constraint data to child. */ cstr->fd = pipes[0]; - imsgbuf_init(&cstr->ibuf, cstr->fd); + if (imsgbuf_init(&cstr->ibuf, cstr->fd) == -1) + fatal("imsgbuf_init"); if (imsg_compose(&cstr->ibuf, IMSG_CONSTRAINT_QUERY, id, 0, -1, data, len) == -1) fatal("%s: imsg_compose", __func__); @@ -400,7 +401,8 @@ priv_constraint_child(const char *pw_dir, uid_t pw_uid, gid_t pw_gid) fatal("pledge"); cstr.fd = CONSTRAINT_PASSFD; - imsgbuf_init(&cstr.ibuf, cstr.fd); + if (imsgbuf_init(&cstr.ibuf, cstr.fd) == -1) + fatal("imsgbuf_init"); priv_constraint_readquery(&cstr, &am, &data); /* diff --git a/usr.sbin/ntpd/control.c b/usr.sbin/ntpd/control.c index c9697fccf81..85057e2118f 100644 --- a/usr.sbin/ntpd/control.c +++ b/usr.sbin/ntpd/control.c @@ -1,4 +1,4 @@ -/* $OpenBSD: control.c,v 1.26 2024/11/21 13:24:39 claudio Exp $ */ +/* $OpenBSD: control.c,v 1.27 2024/11/21 13:38:14 claudio Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer @@ -149,7 +149,12 @@ control_accept(int listenfd) return (0); } - imsgbuf_init(&ctl_conn->ibuf, connfd); + if (imsgbuf_init(&ctl_conn->ibuf, connfd) == -1) { + log_warn("control_accept"); + close(connfd); + free(ctl_conn); + return (0); + } TAILQ_INSERT_TAIL(&ctl_conns, ctl_conn, entry); diff --git a/usr.sbin/ntpd/ntp.c b/usr.sbin/ntpd/ntp.c index 9198698946b..5047baed25e 100644 --- a/usr.sbin/ntpd/ntp.c +++ b/usr.sbin/ntpd/ntp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ntp.c,v 1.180 2024/11/21 13:24:39 claudio Exp $ */ +/* $OpenBSD: ntp.c,v 1.181 2024/11/21 13:38:14 claudio Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer @@ -159,10 +159,12 @@ ntp_main(struct ntpd_conf *nconf, struct passwd *pw, int argc, char **argv) if ((ibuf_main = malloc(sizeof(struct imsgbuf))) == NULL) fatal(NULL); - imsgbuf_init(ibuf_main, PARENT_SOCK_FILENO); + if (imsgbuf_init(ibuf_main, PARENT_SOCK_FILENO) == -1) + fatal(NULL); if ((ibuf_dns = malloc(sizeof(struct imsgbuf))) == NULL) fatal(NULL); - imsgbuf_init(ibuf_dns, pipe_dns[0]); + if (imsgbuf_init(ibuf_dns, pipe_dns[0]) == -1) + fatal(NULL); constraint_cnt = 0; conf->constraint_median = 0; diff --git a/usr.sbin/ntpd/ntp_dns.c b/usr.sbin/ntpd/ntp_dns.c index 6441471f95f..1c709ff17a7 100644 --- a/usr.sbin/ntpd/ntp_dns.c +++ b/usr.sbin/ntpd/ntp_dns.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ntp_dns.c,v 1.35 2024/11/21 13:24:39 claudio Exp $ */ +/* $OpenBSD: ntp_dns.c,v 1.36 2024/11/21 13:38:14 claudio Exp $ */ /* * Copyright (c) 2003-2008 Henning Brauer @@ -94,7 +94,8 @@ ntp_dns(struct ntpd_conf *nconf, struct passwd *pw) if ((ibuf_dns = malloc(sizeof(struct imsgbuf))) == NULL) fatal(NULL); - imsgbuf_init(ibuf_dns, PARENT_SOCK_FILENO); + if (imsgbuf_init(ibuf_dns, PARENT_SOCK_FILENO) == -1) + fatal(NULL); if (pledge("stdio dns", NULL) == -1) err(1, "pledge"); diff --git a/usr.sbin/ntpd/ntpd.c b/usr.sbin/ntpd/ntpd.c index 0a99fee9316..ed10c7f1806 100644 --- a/usr.sbin/ntpd/ntpd.c +++ b/usr.sbin/ntpd/ntpd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ntpd.c,v 1.141 2024/11/21 13:26:25 claudio Exp $ */ +/* $OpenBSD: ntpd.c,v 1.142 2024/11/21 13:38:14 claudio Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer @@ -274,7 +274,8 @@ main(int argc, char *argv[]) if ((ibuf = malloc(sizeof(struct imsgbuf))) == NULL) fatal(NULL); - imsgbuf_init(ibuf, pipe_chld[0]); + if (imsgbuf_init(ibuf, pipe_chld[0]) == -1) + fatal(NULL); constraint_cnt = 0; @@ -670,7 +671,8 @@ ctl_main(int argc, char *argv[]) if ((ibuf_ctl = malloc(sizeof(struct imsgbuf))) == NULL) err(1, NULL); - imsgbuf_init(ibuf_ctl, fd); + if (imsgbuf_init(ibuf_ctl, fd) == -1) + err(1, NULL); switch (action) { case CTL_SHOW_STATUS: diff --git a/usr.sbin/ospf6ctl/ospf6ctl.c b/usr.sbin/ospf6ctl/ospf6ctl.c index 6f8cc882f58..feeeaef81d5 100644 --- a/usr.sbin/ospf6ctl/ospf6ctl.c +++ b/usr.sbin/ospf6ctl/ospf6ctl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ospf6ctl.c,v 1.58 2024/11/21 13:26:25 claudio Exp $ */ +/* $OpenBSD: ospf6ctl.c,v 1.59 2024/11/21 13:38:14 claudio Exp $ */ /* * Copyright (c) 2005 Claudio Jeker @@ -132,7 +132,8 @@ main(int argc, char *argv[]) if ((ibuf = malloc(sizeof(struct imsgbuf))) == NULL) err(1, NULL); - imsgbuf_init(ibuf, ctl_sock); + if (imsgbuf_init(ibuf, ctl_sock) == -1) + err(1, NULL); done = 0; /* process user request */ diff --git a/usr.sbin/ospf6d/control.c b/usr.sbin/ospf6d/control.c index f762f890154..9c345c46eb8 100644 --- a/usr.sbin/ospf6d/control.c +++ b/usr.sbin/ospf6d/control.c @@ -1,4 +1,4 @@ -/* $OpenBSD: control.c,v 1.37 2024/11/21 13:21:34 claudio Exp $ */ +/* $OpenBSD: control.c,v 1.38 2024/11/21 13:38:14 claudio Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer @@ -176,7 +176,12 @@ control_accept(int listenfd, short event, void *bula) return; } - imsgbuf_init(&c->iev.ibuf, connfd); + if (imsgbuf_init(&c->iev.ibuf, connfd) == -1) { + log_warn("imsgbuf_init"); + close(connfd); + free(c); + return; + } c->iev.handler = control_dispatch_imsg; c->iev.events = EV_READ; event_set(&c->iev.ev, c->iev.ibuf.fd, c->iev.events, diff --git a/usr.sbin/ospf6d/ospf6d.c b/usr.sbin/ospf6d/ospf6d.c index 1b5c7a83424..8861abb0e3e 100644 --- a/usr.sbin/ospf6d/ospf6d.c +++ b/usr.sbin/ospf6d/ospf6d.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ospf6d.c,v 1.60 2024/11/21 13:21:34 claudio Exp $ */ +/* $OpenBSD: ospf6d.c,v 1.61 2024/11/21 13:38:14 claudio Exp $ */ /* * Copyright (c) 2005 Claudio Jeker @@ -254,9 +254,12 @@ main(int argc, char *argv[]) if ((iev_ospfe = malloc(sizeof(struct imsgev))) == NULL || (iev_rde = malloc(sizeof(struct imsgev))) == NULL) fatal(NULL); - imsgbuf_init(&iev_ospfe->ibuf, pipe_parent2ospfe[0]); + if (imsgbuf_init(&iev_ospfe->ibuf, pipe_parent2ospfe[0]) == -1) + fatal(NULL); + imsgbuf_allow_fdpass(&iev_ospfe->ibuf); iev_ospfe->handler = main_dispatch_ospfe; - imsgbuf_init(&iev_rde->ibuf, pipe_parent2rde[0]); + if (imsgbuf_init(&iev_rde->ibuf, pipe_parent2rde[0]) == -1) + fatal(NULL); iev_rde->handler = main_dispatch_rde; /* setup event handler */ diff --git a/usr.sbin/ospf6d/ospfe.c b/usr.sbin/ospf6d/ospfe.c index d9ec27c8f72..872b8a233b3 100644 --- a/usr.sbin/ospf6d/ospfe.c +++ b/usr.sbin/ospf6d/ospfe.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ospfe.c,v 1.77 2024/11/21 13:21:34 claudio Exp $ */ +/* $OpenBSD: ospfe.c,v 1.78 2024/11/21 13:38:14 claudio Exp $ */ /* * Copyright (c) 2005 Claudio Jeker @@ -155,9 +155,12 @@ ospfe(struct ospfd_conf *xconf, int pipe_parent2ospfe[2], int pipe_ospfe2rde[2], if ((iev_rde = malloc(sizeof(struct imsgev))) == NULL || (iev_main = malloc(sizeof(struct imsgev))) == NULL) fatal(NULL); - imsgbuf_init(&iev_rde->ibuf, pipe_ospfe2rde[0]); + if (imsgbuf_init(&iev_rde->ibuf, pipe_ospfe2rde[0]) == -1) + fatal(NULL); iev_rde->handler = ospfe_dispatch_rde; - imsgbuf_init(&iev_main->ibuf, pipe_parent2ospfe[1]); + if (imsgbuf_init(&iev_main->ibuf, pipe_parent2ospfe[1]) == -1) + fatal(NULL); + imsgbuf_allow_fdpass(&iev_main->ibuf); iev_main->handler = ospfe_dispatch_main; /* setup event handler */ diff --git a/usr.sbin/ospf6d/rde.c b/usr.sbin/ospf6d/rde.c index 4118c579944..d6041198ebb 100644 --- a/usr.sbin/ospf6d/rde.c +++ b/usr.sbin/ospf6d/rde.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rde.c,v 1.96 2024/11/21 13:21:34 claudio Exp $ */ +/* $OpenBSD: rde.c,v 1.97 2024/11/21 13:38:14 claudio Exp $ */ /* * Copyright (c) 2004, 2005 Claudio Jeker @@ -179,9 +179,11 @@ rde(struct ospfd_conf *xconf, int pipe_parent2rde[2], int pipe_ospfe2rde[2], if ((iev_ospfe = malloc(sizeof(struct imsgev))) == NULL || (iev_main = malloc(sizeof(struct imsgev))) == NULL) fatal(NULL); - imsgbuf_init(&iev_ospfe->ibuf, pipe_ospfe2rde[1]); + if (imsgbuf_init(&iev_ospfe->ibuf, pipe_ospfe2rde[1]) == -1) + fatal(NULL); iev_ospfe->handler = rde_dispatch_imsg; - imsgbuf_init(&iev_main->ibuf, pipe_parent2rde[1]); + if (imsgbuf_init(&iev_main->ibuf, pipe_parent2rde[1]) == -1) + fatal(NULL); iev_main->handler = rde_dispatch_parent; /* setup event handler */ diff --git a/usr.sbin/ospfctl/ospfctl.c b/usr.sbin/ospfctl/ospfctl.c index ef6255a40e0..7fdd8f237e5 100644 --- a/usr.sbin/ospfctl/ospfctl.c +++ b/usr.sbin/ospfctl/ospfctl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ospfctl.c,v 1.72 2024/11/21 13:26:25 claudio Exp $ */ +/* $OpenBSD: ospfctl.c,v 1.73 2024/11/21 13:38:14 claudio Exp $ */ /* * Copyright (c) 2005 Claudio Jeker @@ -106,7 +106,8 @@ main(int argc, char *argv[]) if ((ibuf = malloc(sizeof(struct imsgbuf))) == NULL) err(1, NULL); - imsgbuf_init(ibuf, ctl_sock); + if (imsgbuf_init(ibuf, ctl_sock) == -1) + err(1, NULL); done = 0; /* process user request */ diff --git a/usr.sbin/ospfd/control.c b/usr.sbin/ospfd/control.c index 482af7f017c..43393e85fb0 100644 --- a/usr.sbin/ospfd/control.c +++ b/usr.sbin/ospfd/control.c @@ -1,4 +1,4 @@ -/* $OpenBSD: control.c,v 1.53 2024/11/21 13:21:34 claudio Exp $ */ +/* $OpenBSD: control.c,v 1.54 2024/11/21 13:38:14 claudio Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer @@ -176,7 +176,12 @@ control_accept(int listenfd, short event, void *bula) return; } - imsgbuf_init(&c->iev.ibuf, connfd); + if (imsgbuf_init(&c->iev.ibuf, connfd) == -1) { + log_warn("imsgbuf_init"); + close(connfd); + free(c); + return; + } c->iev.handler = control_dispatch_imsg; c->iev.events = EV_READ; event_set(&c->iev.ev, c->iev.ibuf.fd, c->iev.events, diff --git a/usr.sbin/ospfd/ospfd.c b/usr.sbin/ospfd/ospfd.c index 0afbbb5f15c..44afbbc8ed1 100644 --- a/usr.sbin/ospfd/ospfd.c +++ b/usr.sbin/ospfd/ospfd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ospfd.c,v 1.123 2024/11/21 13:21:34 claudio Exp $ */ +/* $OpenBSD: ospfd.c,v 1.124 2024/11/21 13:38:14 claudio Exp $ */ /* * Copyright (c) 2005 Claudio Jeker @@ -260,9 +260,12 @@ main(int argc, char *argv[]) if ((iev_ospfe = malloc(sizeof(struct imsgev))) == NULL || (iev_rde = malloc(sizeof(struct imsgev))) == NULL) fatal(NULL); - imsgbuf_init(&iev_ospfe->ibuf, pipe_parent2ospfe[0]); + if (imsgbuf_init(&iev_ospfe->ibuf, pipe_parent2ospfe[0]) == -1) + fatal(NULL); + imsgbuf_allow_fdpass(&iev_ospfe->ibuf); iev_ospfe->handler = main_dispatch_ospfe; - imsgbuf_init(&iev_rde->ibuf, pipe_parent2rde[0]); + if (imsgbuf_init(&iev_rde->ibuf, pipe_parent2rde[0]) == -1) + fatal(NULL); iev_rde->handler = main_dispatch_rde; /* setup event handler */ diff --git a/usr.sbin/ospfd/ospfe.c b/usr.sbin/ospfd/ospfe.c index 3796d153669..c7983a9ef6f 100644 --- a/usr.sbin/ospfd/ospfe.c +++ b/usr.sbin/ospfd/ospfe.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ospfe.c,v 1.119 2024/11/21 13:21:34 claudio Exp $ */ +/* $OpenBSD: ospfe.c,v 1.120 2024/11/21 13:38:14 claudio Exp $ */ /* * Copyright (c) 2005 Claudio Jeker @@ -155,9 +155,12 @@ ospfe(struct ospfd_conf *xconf, int pipe_parent2ospfe[2], int pipe_ospfe2rde[2], if ((iev_rde = malloc(sizeof(struct imsgev))) == NULL || (iev_main = malloc(sizeof(struct imsgev))) == NULL) fatal(NULL); - imsgbuf_init(&iev_rde->ibuf, pipe_ospfe2rde[0]); + if (imsgbuf_init(&iev_rde->ibuf, pipe_ospfe2rde[0]) == -1) + fatal(NULL); iev_rde->handler = ospfe_dispatch_rde; - imsgbuf_init(&iev_main->ibuf, pipe_parent2ospfe[1]); + if (imsgbuf_init(&iev_main->ibuf, pipe_parent2ospfe[1]) == -1) + fatal(NULL); + imsgbuf_allow_fdpass(&iev_main->ibuf); iev_main->handler = ospfe_dispatch_main; /* setup event handler */ diff --git a/usr.sbin/ospfd/rde.c b/usr.sbin/ospfd/rde.c index b4dd8648ca9..c438f3c7571 100644 --- a/usr.sbin/ospfd/rde.c +++ b/usr.sbin/ospfd/rde.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rde.c,v 1.117 2024/11/21 13:21:34 claudio Exp $ */ +/* $OpenBSD: rde.c,v 1.118 2024/11/21 13:38:14 claudio Exp $ */ /* * Copyright (c) 2004, 2005 Claudio Jeker @@ -161,9 +161,11 @@ rde(struct ospfd_conf *xconf, int pipe_parent2rde[2], int pipe_ospfe2rde[2], if ((iev_ospfe = malloc(sizeof(struct imsgev))) == NULL || (iev_main = malloc(sizeof(struct imsgev))) == NULL) fatal(NULL); - imsgbuf_init(&iev_ospfe->ibuf, pipe_ospfe2rde[1]); + if (imsgbuf_init(&iev_ospfe->ibuf, pipe_ospfe2rde[1]) == -1) + fatal(NULL); iev_ospfe->handler = rde_dispatch_imsg; - imsgbuf_init(&iev_main->ibuf, pipe_parent2rde[1]); + if (imsgbuf_init(&iev_main->ibuf, pipe_parent2rde[1]) == -1) + fatal(NULL); iev_main->handler = rde_dispatch_parent; /* setup event handler */ diff --git a/usr.sbin/ractl/ractl.c b/usr.sbin/ractl/ractl.c index 6d4f6d6daf3..7b9baa90d01 100644 --- a/usr.sbin/ractl/ractl.c +++ b/usr.sbin/ractl/ractl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ractl.c,v 1.7 2024/11/21 13:26:25 claudio Exp $ */ +/* $OpenBSD: ractl.c,v 1.8 2024/11/21 13:38:14 claudio Exp $ */ /* * Copyright (c) 2005 Claudio Jeker @@ -100,7 +100,8 @@ main(int argc, char *argv[]) if ((ibuf = malloc(sizeof(struct imsgbuf))) == NULL) err(1, NULL); - imsgbuf_init(ibuf, ctl_sock); + if (imsgbuf_init(ibuf, ctl_sock) == -1) + err(1, NULL); done = 0; /* Process user request. */ diff --git a/usr.sbin/rad/control.c b/usr.sbin/rad/control.c index 43f1a49af73..3c1ea1a6b86 100644 --- a/usr.sbin/rad/control.c +++ b/usr.sbin/rad/control.c @@ -1,4 +1,4 @@ -/* $OpenBSD: control.c,v 1.13 2024/11/21 13:21:34 claudio Exp $ */ +/* $OpenBSD: control.c,v 1.14 2024/11/21 13:38:15 claudio Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer @@ -155,7 +155,12 @@ control_accept(int listenfd, short event, void *bula) return; } - imsgbuf_init(&c->iev.ibuf, connfd); + if (imsgbuf_init(&c->iev.ibuf, connfd) == -1) { + log_warn("%s: imsgbuf_init", __func__); + close(connfd); + free(c); + return; + } c->iev.handler = control_dispatch_imsg; c->iev.events = EV_READ; event_set(&c->iev.ev, c->iev.ibuf.fd, c->iev.events, diff --git a/usr.sbin/rad/engine.c b/usr.sbin/rad/engine.c index f3b6c7756e4..cc18b5537bb 100644 --- a/usr.sbin/rad/engine.c +++ b/usr.sbin/rad/engine.c @@ -1,4 +1,4 @@ -/* $OpenBSD: engine.c,v 1.27 2024/11/21 13:21:34 claudio Exp $ */ +/* $OpenBSD: engine.c,v 1.28 2024/11/21 13:38:15 claudio Exp $ */ /* * Copyright (c) 2018 Florian Obser @@ -134,7 +134,9 @@ engine(int debug, int verbose) if ((iev_main = malloc(sizeof(struct imsgev))) == NULL) fatal(NULL); - imsgbuf_init(&iev_main->ibuf, 3); + if (imsgbuf_init(&iev_main->ibuf, 3) == -1) + fatal(NULL); + imsgbuf_allow_fdpass(&iev_main->ibuf); iev_main->handler = engine_dispatch_main; /* Setup event handlers. */ @@ -316,7 +318,8 @@ engine_dispatch_main(int fd, short event, void *bula) if (iev_frontend == NULL) fatal(NULL); - imsgbuf_init(&iev_frontend->ibuf, fd); + if (imsgbuf_init(&iev_frontend->ibuf, fd) == -1) + fatal(NULL); iev_frontend->handler = engine_dispatch_frontend; iev_frontend->events = EV_READ; diff --git a/usr.sbin/rad/frontend.c b/usr.sbin/rad/frontend.c index fc4cf5f919b..6687f17f9d0 100644 --- a/usr.sbin/rad/frontend.c +++ b/usr.sbin/rad/frontend.c @@ -1,4 +1,4 @@ -/* $OpenBSD: frontend.c,v 1.54 2024/11/21 13:21:34 claudio Exp $ */ +/* $OpenBSD: frontend.c,v 1.55 2024/11/21 13:38:15 claudio Exp $ */ /* * Copyright (c) 2018 Florian Obser @@ -240,7 +240,9 @@ frontend(int debug, int verbose) /* Setup pipe and event handler to the parent process. */ if ((iev_main = malloc(sizeof(struct imsgev))) == NULL) fatal(NULL); - imsgbuf_init(&iev_main->ibuf, 3); + if (imsgbuf_init(&iev_main->ibuf, 3) == -1) + fatal(NULL); + imsgbuf_allow_fdpass(&iev_main->ibuf); iev_main->handler = frontend_dispatch_main; iev_main->events = EV_READ; event_set(&iev_main->ev, iev_main->ibuf.fd, iev_main->events, @@ -357,7 +359,8 @@ frontend_dispatch_main(int fd, short event, void *bula) if (iev_engine == NULL) fatal(NULL); - imsgbuf_init(&iev_engine->ibuf, fd); + if (imsgbuf_init(&iev_engine->ibuf, fd) == -1) + fatal(NULL); iev_engine->handler = frontend_dispatch_engine; iev_engine->events = EV_READ; diff --git a/usr.sbin/rad/rad.c b/usr.sbin/rad/rad.c index 11c7d154585..ae073db1758 100644 --- a/usr.sbin/rad/rad.c +++ b/usr.sbin/rad/rad.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rad.c,v 1.37 2024/11/21 13:21:34 claudio Exp $ */ +/* $OpenBSD: rad.c,v 1.38 2024/11/21 13:38:15 claudio Exp $ */ /* * Copyright (c) 2018 Florian Obser @@ -240,9 +240,13 @@ main(int argc, char *argv[]) if ((iev_frontend = malloc(sizeof(struct imsgev))) == NULL || (iev_engine = malloc(sizeof(struct imsgev))) == NULL) fatal(NULL); - imsgbuf_init(&iev_frontend->ibuf, pipe_main2frontend[0]); + if (imsgbuf_init(&iev_frontend->ibuf, pipe_main2frontend[0]) == -1) + fatal(NULL); + imsgbuf_allow_fdpass(&iev_frontend->ibuf); iev_frontend->handler = main_dispatch_frontend; - imsgbuf_init(&iev_engine->ibuf, pipe_main2engine[0]); + if (imsgbuf_init(&iev_engine->ibuf, pipe_main2engine[0]) == -1) + fatal(NULL); + imsgbuf_allow_fdpass(&iev_engine->ibuf); iev_engine->handler = main_dispatch_engine; /* Setup event handlers for pipes to engine & frontend. */ diff --git a/usr.sbin/relayctl/relayctl.c b/usr.sbin/relayctl/relayctl.c index d25bae9342f..fe06c911679 100644 --- a/usr.sbin/relayctl/relayctl.c +++ b/usr.sbin/relayctl/relayctl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: relayctl.c,v 1.62 2024/11/21 13:26:25 claudio Exp $ */ +/* $OpenBSD: relayctl.c,v 1.63 2024/11/21 13:38:15 claudio Exp $ */ /* * Copyright (c) 2007 - 2013 Reyk Floeter @@ -148,7 +148,8 @@ main(int argc, char *argv[]) if ((ibuf = malloc(sizeof(struct imsgbuf))) == NULL) err(1, NULL); - imsgbuf_init(ibuf, ctl_sock); + if (imsgbuf_init(ibuf, ctl_sock) == -1) + err(1, NULL); done = 0; /* process user request */ diff --git a/usr.sbin/ripctl/ripctl.c b/usr.sbin/ripctl/ripctl.c index c3e1bb664e4..beee3d6123d 100644 --- a/usr.sbin/ripctl/ripctl.c +++ b/usr.sbin/ripctl/ripctl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ripctl.c,v 1.21 2024/11/21 13:26:25 claudio Exp $ +/* $OpenBSD: ripctl.c,v 1.22 2024/11/21 13:38:15 claudio Exp $ * * Copyright (c) 2006 Michele Marchetto * Copyright (c) 2005 Claudio Jeker @@ -110,7 +110,8 @@ main(int argc, char *argv[]) if ((ibuf = malloc(sizeof(struct imsgbuf))) == NULL) err(1, NULL); - imsgbuf_init(ibuf, ctl_sock); + if (imsgbuf_init(ibuf, ctl_sock) == -1) + err(1, NULL); done = 0; /* process user request */ diff --git a/usr.sbin/ripd/control.c b/usr.sbin/ripd/control.c index f651e4887a1..20689670b47 100644 --- a/usr.sbin/ripd/control.c +++ b/usr.sbin/ripd/control.c @@ -1,4 +1,4 @@ -/* $OpenBSD: control.c,v 1.33 2024/11/21 13:21:34 claudio Exp $ */ +/* $OpenBSD: control.c,v 1.34 2024/11/21 13:38:15 claudio Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer @@ -143,7 +143,12 @@ control_accept(int listenfd, short event, void *bula) return; } - imsgbuf_init(&c->iev.ibuf, connfd); + if (imsgbuf_init(&c->iev.ibuf, connfd) == -1) { + log_warn("control_accept"); + close(connfd); + free(c); + return; + } c->iev.handler = control_dispatch_imsg; c->iev.events = EV_READ; event_set(&c->iev.ev, c->iev.ibuf.fd, c->iev.events, diff --git a/usr.sbin/ripd/rde.c b/usr.sbin/ripd/rde.c index f4eee623520..7c694160c6d 100644 --- a/usr.sbin/ripd/rde.c +++ b/usr.sbin/ripd/rde.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rde.c,v 1.30 2024/11/21 13:21:34 claudio Exp $ */ +/* $OpenBSD: rde.c,v 1.31 2024/11/21 13:38:15 claudio Exp $ */ /* * Copyright (c) 2006 Michele Marchetto @@ -129,9 +129,11 @@ rde(struct ripd_conf *xconf, int pipe_parent2rde[2], int pipe_ripe2rde[2], if ((iev_ripe = malloc(sizeof(struct imsgev))) == NULL || (iev_main = malloc(sizeof(struct imsgev))) == NULL) fatal(NULL); - imsgbuf_init(&iev_ripe->ibuf, pipe_ripe2rde[1]); + if (imsgbuf_init(&iev_ripe->ibuf, pipe_ripe2rde[1]) == -1) + fatal(NULL); iev_ripe->handler = rde_dispatch_imsg; - imsgbuf_init(&iev_main->ibuf, pipe_parent2rde[1]); + if (imsgbuf_init(&iev_main->ibuf, pipe_parent2rde[1]) == -1) + fatal(NULL); iev_main->handler = rde_dispatch_parent; /* setup event handler */ diff --git a/usr.sbin/ripd/ripd.c b/usr.sbin/ripd/ripd.c index a8a900e6556..0f0cde2c4fe 100644 --- a/usr.sbin/ripd/ripd.c +++ b/usr.sbin/ripd/ripd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ripd.c,v 1.43 2024/11/21 13:21:34 claudio Exp $ */ +/* $OpenBSD: ripd.c,v 1.44 2024/11/21 13:38:15 claudio Exp $ */ /* * Copyright (c) 2006 Michele Marchetto @@ -235,9 +235,11 @@ main(int argc, char *argv[]) if ((iev_ripe = malloc(sizeof(struct imsgev))) == NULL || (iev_rde = malloc(sizeof(struct imsgev))) == NULL) fatal(NULL); - imsgbuf_init(&iev_ripe->ibuf, pipe_parent2ripe[0]); + if (imsgbuf_init(&iev_ripe->ibuf, pipe_parent2ripe[0]) == -1) + fatal(NULL); iev_ripe->handler = main_dispatch_ripe; - imsgbuf_init(&iev_rde->ibuf, pipe_parent2rde[0]); + if (imsgbuf_init(&iev_rde->ibuf, pipe_parent2rde[0]) == -1) + fatal(NULL); iev_rde->handler = main_dispatch_rde; /* setup event handler */ diff --git a/usr.sbin/ripd/ripe.c b/usr.sbin/ripd/ripe.c index 0b702fc6dc9..8cbed40213f 100644 --- a/usr.sbin/ripd/ripe.c +++ b/usr.sbin/ripd/ripe.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ripe.c,v 1.36 2024/11/21 13:21:34 claudio Exp $ */ +/* $OpenBSD: ripe.c,v 1.37 2024/11/21 13:38:15 claudio Exp $ */ /* * Copyright (c) 2006 Michele Marchetto @@ -153,9 +153,11 @@ ripe(struct ripd_conf *xconf, int pipe_parent2ripe[2], int pipe_ripe2rde[2], if ((iev_rde = malloc(sizeof(struct imsgev))) == NULL || (iev_main = malloc(sizeof(struct imsgev))) == NULL) fatal(NULL); - imsgbuf_init(&iev_rde->ibuf, pipe_ripe2rde[0]); + if (imsgbuf_init(&iev_rde->ibuf, pipe_ripe2rde[0]) == -1) + fatal(NULL); iev_rde->handler = ripe_dispatch_rde; - imsgbuf_init(&iev_main->ibuf, pipe_parent2ripe[1]); + if (imsgbuf_init(&iev_main->ibuf, pipe_parent2ripe[1]) == -1) + fatal(NULL); iev_main->handler = ripe_dispatch_main; /* setup event handler */ diff --git a/usr.sbin/slaacctl/slaacctl.c b/usr.sbin/slaacctl/slaacctl.c index 3debc535754..600fbad2856 100644 --- a/usr.sbin/slaacctl/slaacctl.c +++ b/usr.sbin/slaacctl/slaacctl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: slaacctl.c,v 1.27 2024/11/21 13:26:25 claudio Exp $ */ +/* $OpenBSD: slaacctl.c,v 1.28 2024/11/21 13:38:15 claudio Exp $ */ /* * Copyright (c) 2005 Claudio Jeker @@ -109,7 +109,8 @@ main(int argc, char *argv[]) if ((ibuf = malloc(sizeof(struct imsgbuf))) == NULL) err(1, NULL); - imsgbuf_init(ibuf, ctl_sock); + if (imsgbuf_init(ibuf, ctl_sock) == -1) + err(1, NULL); done = 0; /* Process user request. */ diff --git a/usr.sbin/unwindctl/unwindctl.c b/usr.sbin/unwindctl/unwindctl.c index 8c7f34e2826..2735c33cb5b 100644 --- a/usr.sbin/unwindctl/unwindctl.c +++ b/usr.sbin/unwindctl/unwindctl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: unwindctl.c,v 1.33 2024/11/21 13:26:25 claudio Exp $ */ +/* $OpenBSD: unwindctl.c,v 1.34 2024/11/21 13:38:15 claudio Exp $ */ /* * Copyright (c) 2005 Claudio Jeker @@ -129,7 +129,8 @@ main(int argc, char *argv[]) if ((ibuf = malloc(sizeof(struct imsgbuf))) == NULL) err(1, NULL); - imsgbuf_init(ibuf, ctl_sock); + if (imsgbuf_init(ibuf, ctl_sock) == -1) + err(1, NULL); done = 0; /* Check for root-only actions */ diff --git a/usr.sbin/ypldap/ldapclient.c b/usr.sbin/ypldap/ldapclient.c index 5d94b7fd755..578653f0348 100644 --- a/usr.sbin/ypldap/ldapclient.c +++ b/usr.sbin/ypldap/ldapclient.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ldapclient.c,v 1.54 2024/11/21 13:21:34 claudio Exp $ */ +/* $OpenBSD: ldapclient.c,v 1.55 2024/11/21 13:38:15 claudio Exp $ */ /* * Copyright (c) 2008 Alexander Schrijver @@ -393,7 +393,8 @@ ldapclient(int pipe_main2client[2]) env.sc_iev->events = EV_READ; env.sc_iev->data = &env; - imsgbuf_init(&env.sc_iev->ibuf, pipe_main2client[1]); + if (imsgbuf_init(&env.sc_iev->ibuf, pipe_main2client[1]) == -1) + fatal(NULL); env.sc_iev->handler = client_dispatch_parent; event_set(&env.sc_iev->ev, env.sc_iev->ibuf.fd, env.sc_iev->events, env.sc_iev->handler, &env); @@ -401,7 +402,8 @@ ldapclient(int pipe_main2client[2]) env.sc_iev_dns->events = EV_READ; env.sc_iev_dns->data = &env; - imsgbuf_init(&env.sc_iev_dns->ibuf, pipe_dns[0]); + if (imsgbuf_init(&env.sc_iev_dns->ibuf, pipe_dns[0]) == -1) + fatal(NULL); env.sc_iev_dns->handler = client_dispatch_dns; event_set(&env.sc_iev_dns->ev, env.sc_iev_dns->ibuf.fd, env.sc_iev_dns->events, env.sc_iev_dns->handler, &env); diff --git a/usr.sbin/ypldap/ypldap.c b/usr.sbin/ypldap/ypldap.c index c15498e0f1c..ccabd9760a1 100644 --- a/usr.sbin/ypldap/ypldap.c +++ b/usr.sbin/ypldap/ypldap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ypldap.c,v 1.30 2024/11/21 13:21:34 claudio Exp $ */ +/* $OpenBSD: ypldap.c,v 1.31 2024/11/21 13:38:15 claudio Exp $ */ /* * Copyright (c) 2008 Pierre-Yves Ritschard @@ -589,7 +589,8 @@ main(int argc, char *argv[]) close(pipe_main2client[1]); if ((env.sc_iev = calloc(1, sizeof(*env.sc_iev))) == NULL) fatal(NULL); - imsgbuf_init(&env.sc_iev->ibuf, pipe_main2client[0]); + if (imsgbuf_init(&env.sc_iev->ibuf, pipe_main2client[0]) == -1) + fatal(NULL); env.sc_iev->handler = main_dispatch_client; env.sc_iev->events = EV_READ; diff --git a/usr.sbin/ypldap/ypldap_dns.c b/usr.sbin/ypldap/ypldap_dns.c index 0129b7c3a77..458a8f31cc6 100644 --- a/usr.sbin/ypldap/ypldap_dns.c +++ b/usr.sbin/ypldap/ypldap_dns.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ypldap_dns.c,v 1.20 2024/11/21 13:21:34 claudio Exp $ */ +/* $OpenBSD: ypldap_dns.c,v 1.21 2024/11/21 13:38:15 claudio Exp $ */ /* * Copyright (c) 2003-2008 Henning Brauer @@ -115,7 +115,8 @@ ypldap_dns(int pipe_ntp[2], struct passwd *pw) env.sc_iev->events = EV_READ; env.sc_iev->data = &env; - imsgbuf_init(&env.sc_iev->ibuf, pipe_ntp[1]); + if (imsgbuf_init(&env.sc_iev->ibuf, pipe_ntp[1]) == -1) + fatal(NULL); env.sc_iev->handler = dns_dispatch_imsg; event_set(&env.sc_iev->ev, env.sc_iev->ibuf.fd, env.sc_iev->events, env.sc_iev->handler, &env); -- cgit v1.2.3