summaryrefslogtreecommitdiff
path: root/usr.sbin/bgpd
diff options
context:
space:
mode:
Diffstat (limited to 'usr.sbin/bgpd')
-rw-r--r--usr.sbin/bgpd/bgpd.c12
-rw-r--r--usr.sbin/bgpd/control.c9
-rw-r--r--usr.sbin/bgpd/rde.c9
-rw-r--r--usr.sbin/bgpd/rtr.c9
-rw-r--r--usr.sbin/bgpd/session.c9
5 files changed, 33 insertions, 15 deletions
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 <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;
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 <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);
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 <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) {
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 <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) {
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 <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 "