diff options
-rw-r--r-- | usr.sbin/httpd/control.c | 11 | ||||
-rw-r--r-- | usr.sbin/httpd/proc.c | 12 | ||||
-rw-r--r-- | usr.sbin/relayd/control.c | 12 | ||||
-rw-r--r-- | usr.sbin/relayd/proc.c | 12 | ||||
-rw-r--r-- | usr.sbin/snmpd/proc.c | 12 |
5 files changed, 41 insertions, 18 deletions
diff --git a/usr.sbin/httpd/control.c b/usr.sbin/httpd/control.c index f5d8143a24b..9a4eb3b5163 100644 --- a/usr.sbin/httpd/control.c +++ b/usr.sbin/httpd/control.c @@ -1,4 +1,4 @@ -/* $OpenBSD: control.c,v 1.20 2024/11/21 13:21:34 claudio Exp $ */ +/* $OpenBSD: control.c,v 1.21 2024/11/21 13:38:45 claudio Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org> @@ -159,12 +159,17 @@ control_accept(int listenfd, short event, void *arg) } if ((c = calloc(1, sizeof(struct ctl_conn))) == NULL) { - close(connfd); log_warn("%s: calloc", __func__); + close(connfd); 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; c->iev.data = cs; /* proc.c cheats (reuses the handler) */ diff --git a/usr.sbin/httpd/proc.c b/usr.sbin/httpd/proc.c index 972946f82a4..66d528668df 100644 --- a/usr.sbin/httpd/proc.c +++ b/usr.sbin/httpd/proc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: proc.c,v 1.51 2024/11/21 13:21:34 claudio Exp $ */ +/* $OpenBSD: proc.c,v 1.52 2024/11/21 13:38:45 claudio Exp $ */ /* * Copyright (c) 2010 - 2016 Reyk Floeter <reyk@openbsd.org> @@ -155,8 +155,10 @@ proc_connect(struct privsep *ps) for (inst = 0; inst < ps->ps_instances[dst]; inst++) { iev = &ps->ps_ievs[dst][inst]; - imsgbuf_init(&iev->ibuf, - ps->ps_pp->pp_pipes[dst][inst]); + if (imsgbuf_init(&iev->ibuf, + ps->ps_pp->pp_pipes[dst][inst]) == -1) + fatal(NULL); + imsgbuf_allow_fdpass(&iev->ibuf); event_set(&iev->ev, iev->ibuf.fd, iev->events, iev->handler, iev->data); event_add(&iev->ev, NULL); @@ -265,7 +267,9 @@ proc_accept(struct privsep *ps, int fd, enum privsep_procid dst, pp->pp_pipes[dst][n] = fd; iev = &ps->ps_ievs[dst][n]; - imsgbuf_init(&iev->ibuf, fd); + if (imsgbuf_init(&iev->ibuf, fd) == -1) + fatal(NULL); + imsgbuf_allow_fdpass(&iev->ibuf); event_set(&iev->ev, iev->ibuf.fd, iev->events, iev->handler, iev->data); event_add(&iev->ev, NULL); } diff --git a/usr.sbin/relayd/control.c b/usr.sbin/relayd/control.c index 828b83e8cdf..bd13efd1d9b 100644 --- a/usr.sbin/relayd/control.c +++ b/usr.sbin/relayd/control.c @@ -1,4 +1,4 @@ -/* $OpenBSD: control.c,v 1.63 2024/11/21 13:21:34 claudio Exp $ */ +/* $OpenBSD: control.c,v 1.64 2024/11/21 13:38:45 claudio Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org> @@ -159,12 +159,18 @@ control_accept(int listenfd, short event, void *arg) } if ((c = calloc(1, sizeof(struct ctl_conn))) == NULL) { - close(connfd); log_warn("%s: calloc", __func__); + close(connfd); + return; + } + + if (imsgbuf_init(&c->iev.ibuf, connfd) == -1) { + log_warn("%s: imsgbuf_init", __func__); + close(connfd); + free(c); return; } - imsgbuf_init(&c->iev.ibuf, connfd); c->iev.handler = control_dispatch_imsg; c->iev.events = EV_READ; c->iev.data = cs; /* proc.c cheats (reuses the handler) */ diff --git a/usr.sbin/relayd/proc.c b/usr.sbin/relayd/proc.c index 253a907ccc1..3eb00aa0381 100644 --- a/usr.sbin/relayd/proc.c +++ b/usr.sbin/relayd/proc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: proc.c,v 1.51 2024/11/21 13:21:34 claudio Exp $ */ +/* $OpenBSD: proc.c,v 1.52 2024/11/21 13:38:45 claudio Exp $ */ /* * Copyright (c) 2010 - 2016 Reyk Floeter <reyk@openbsd.org> @@ -155,8 +155,10 @@ proc_connect(struct privsep *ps) for (inst = 0; inst < ps->ps_instances[dst]; inst++) { iev = &ps->ps_ievs[dst][inst]; - imsgbuf_init(&iev->ibuf, - ps->ps_pp->pp_pipes[dst][inst]); + if (imsgbuf_init(&iev->ibuf, + ps->ps_pp->pp_pipes[dst][inst]) == -1) + fatal("imsgbuf_init"); + imsgbuf_allow_fdpass(&iev->ibuf); event_set(&iev->ev, iev->ibuf.fd, iev->events, iev->handler, iev->data); event_add(&iev->ev, NULL); @@ -265,7 +267,9 @@ proc_accept(struct privsep *ps, int fd, enum privsep_procid dst, pp->pp_pipes[dst][n] = fd; iev = &ps->ps_ievs[dst][n]; - imsgbuf_init(&iev->ibuf, fd); + if (imsgbuf_init(&iev->ibuf, fd) == -1) + fatal("imsgbuf_init"); + imsgbuf_allow_fdpass(&iev->ibuf); event_set(&iev->ev, iev->ibuf.fd, iev->events, iev->handler, iev->data); event_add(&iev->ev, NULL); } diff --git a/usr.sbin/snmpd/proc.c b/usr.sbin/snmpd/proc.c index 4455cdd1f5b..bbf7335275b 100644 --- a/usr.sbin/snmpd/proc.c +++ b/usr.sbin/snmpd/proc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: proc.c,v 1.38 2024/11/21 13:21:34 claudio Exp $ */ +/* $OpenBSD: proc.c,v 1.39 2024/11/21 13:38:45 claudio Exp $ */ /* * Copyright (c) 2010 - 2016 Reyk Floeter <reyk@openbsd.org> @@ -155,8 +155,10 @@ proc_connect(struct privsep *ps) for (inst = 0; inst < ps->ps_instances[dst]; inst++) { iev = &ps->ps_ievs[dst][inst]; - imsgbuf_init(&iev->ibuf, - ps->ps_pp->pp_pipes[dst][inst]); + if (imsgbuf_init(&iev->ibuf, + ps->ps_pp->pp_pipes[dst][inst]) == -1) + fatal("imsgbuf_init"); + imsgbuf_allow_fdpass(&iev->ibuf); event_set(&iev->ev, iev->ibuf.fd, iev->events, iev->handler, iev->data); event_add(&iev->ev, NULL); @@ -265,7 +267,9 @@ proc_accept(struct privsep *ps, int fd, enum privsep_procid dst, pp->pp_pipes[dst][n] = fd; iev = &ps->ps_ievs[dst][n]; - imsgbuf_init(&iev->ibuf, fd); + if (imsgbuf_init(&iev->ibuf, fd) == -1) + fatal("imsgbuf_init"); + imsgbuf_allow_fdpass(&iev->ibuf); event_set(&iev->ev, iev->ibuf.fd, iev->events, iev->handler, iev->data); event_add(&iev->ev, NULL); } |