1
0
mirror of https://github.com/openbsd/src.git synced 2024-12-21 23:18:00 -08:00

Convert simple stuff in usr.sbin over to new imsgbuf_init behaviour

OK tb@
This commit is contained in:
claudio 2024-11-21 13:38:14 +00:00
parent 0e59d0d19c
commit f1b790a573
56 changed files with 285 additions and 142 deletions

View File

@ -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 <henning@openbsd.org>
@ -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) {

View File

@ -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 <henning@openbsd.org>
@ -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;

View File

@ -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 <henning@openbsd.org>
@ -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);

View File

@ -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 <henning@openbsd.org>
@ -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) {

View File

@ -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 <claudio@openbsd.org>
@ -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) {

View File

@ -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 <henning@openbsd.org>
@ -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 "

View File

@ -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 <florian@openbsd.org>
@ -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,

View File

@ -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 <florian@openbsd.org>
@ -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,

View File

@ -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 <claudio@openbsd.org>
@ -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 */

View File

@ -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 <henning@openbsd.org>
@ -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,

View File

@ -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 <claudio@openbsd.org>
@ -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;

View File

@ -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 <claudio@openbsd.org>
@ -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 */

View File

@ -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 <claudio@openbsd.org>
@ -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 */

View File

@ -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 <renato@openbsd.org>
@ -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 */

View File

@ -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 <henning@openbsd.org>
@ -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,

View File

@ -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 <renato@openbsd.org>
@ -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 */

View File

@ -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 <renato@openbsd.org>
@ -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,

View File

@ -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 <renato@openbsd.org>
@ -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,

View File

@ -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 <reyk@openbsd.org>
@ -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) {

View File

@ -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 <martin@bzero.se>
@ -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)

View File

@ -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 <michele@openbsd.org>
* Copyright (c) 2005 Claudio Jeker <claudio@openbsd.org>
@ -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 */

View File

@ -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 <henning@openbsd.org>
@ -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,

View File

@ -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 <renato@openbsd.org>
@ -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,

View File

@ -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 <renato@openbsd.org>
@ -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 */

View File

@ -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 <renato@openbsd.org>
@ -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,

View File

@ -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 <reyk@openbsd.org>
@ -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);
/*

View File

@ -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 <henning@openbsd.org>
@ -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);

View File

@ -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 <henning@openbsd.org>
@ -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;

View File

@ -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 <henning@openbsd.org>
@ -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");

View File

@ -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 <henning@openbsd.org>
@ -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:

View File

@ -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 <claudio@openbsd.org>
@ -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 */

View File

@ -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 <henning@openbsd.org>
@ -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,

View File

@ -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 <claudio@openbsd.org>
@ -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 */

View File

@ -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 <claudio@openbsd.org>
@ -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 */

View File

@ -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 <claudio@openbsd.org>
@ -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 */

View File

@ -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 <claudio@openbsd.org>
@ -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 */

View File

@ -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 <henning@openbsd.org>
@ -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,

View File

@ -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 <claudio@openbsd.org>
@ -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 */

View File

@ -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 <claudio@openbsd.org>
@ -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 */

View File

@ -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 <claudio@openbsd.org>
@ -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 */

View File

@ -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 <claudio@openbsd.org>
@ -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. */

View File

@ -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 <henning@openbsd.org>
@ -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,

View File

@ -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 <florian@openbsd.org>
@ -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;

View File

@ -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 <florian@openbsd.org>
@ -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;

View File

@ -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 <florian@openbsd.org>
@ -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. */

View File

@ -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 <reyk@openbsd.org>
@ -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 */

View File

@ -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 <mydecay@openbeer.it>
* Copyright (c) 2005 Claudio Jeker <claudio@openbsd.org>
@ -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 */

View File

@ -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 <henning@openbsd.org>
@ -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,

View File

@ -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 <mydecay@openbeer.it>
@ -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 */

View File

@ -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 <mydecay@openbeer.it>
@ -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 */

View File

@ -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 <mydecay@openbeer.it>
@ -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 */

View File

@ -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 <claudio@openbsd.org>
@ -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. */

View File

@ -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 <claudio@openbsd.org>
@ -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 */

View File

@ -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 <aschrijver@openbsd.org>
@ -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);

View File

@ -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 <pyr@openbsd.org>
@ -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;

View File

@ -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 <henning@openbsd.org>
@ -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);