diff options
author | Florian Obser <florian@cvs.openbsd.org> | 2024-08-24 16:34:24 +0000 |
---|---|---|
committer | Florian Obser <florian@cvs.openbsd.org> | 2024-08-24 16:34:24 +0000 |
commit | 366002b60f43b5692adfdaab11169fed40ab750f (patch) | |
tree | 2d435356a658c3f8eb28f383739edf7ceefebf3c /sbin | |
parent | 5224ccc6610607091d1227d38e2a12193c38969d (diff) |
Stop peeking into struct imsg when relaying control messages.
pointed out by & OK tb
Diffstat (limited to 'sbin')
-rw-r--r-- | sbin/slaacd/control.c | 7 | ||||
-rw-r--r-- | sbin/slaacd/slaacd.c | 12 | ||||
-rw-r--r-- | sbin/slaacd/slaacd.h | 5 |
3 files changed, 16 insertions, 8 deletions
diff --git a/sbin/slaacd/control.c b/sbin/slaacd/control.c index a5fb37fb4bc..2cdf0568d4c 100644 --- a/sbin/slaacd/control.c +++ b/sbin/slaacd/control.c @@ -1,4 +1,4 @@ -/* $OpenBSD: control.c,v 1.10 2024/08/24 09:44:41 florian Exp $ */ +/* $OpenBSD: control.c,v 1.11 2024/08/24 16:34:23 florian Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org> @@ -296,10 +296,9 @@ control_imsg_relay(struct imsg *imsg) { struct ctl_conn *c; - if ((c = control_connbypid(imsg->hdr.pid)) == NULL) + if ((c = control_connbypid(imsg_get_pid(imsg))) == NULL) return (0); - return (imsg_compose_event(&c->iev, imsg->hdr.type, 0, imsg->hdr.pid, - -1, imsg->data, IMSG_DATA_SIZE(*imsg))); + return (imsg_forward_event(&c->iev, imsg)); } #endif /* SMALL */ diff --git a/sbin/slaacd/slaacd.c b/sbin/slaacd/slaacd.c index c76bae07ed3..da9a98ecff6 100644 --- a/sbin/slaacd/slaacd.c +++ b/sbin/slaacd/slaacd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: slaacd.c,v 1.71 2024/08/24 09:44:41 florian Exp $ */ +/* $OpenBSD: slaacd.c,v 1.72 2024/08/24 16:34:23 florian Exp $ */ /* * Copyright (c) 2017 Florian Obser <florian@openbsd.org> @@ -587,6 +587,16 @@ imsg_compose_event(struct imsgev *iev, uint16_t type, uint32_t peerid, return (ret); } +int +imsg_forward_event(struct imsgev *iev, struct imsg *imsg) +{ + int ret; + + if ((ret = imsg_forward(&iev->ibuf, imsg)) != -1) + imsg_event_add(iev); + + return (ret); +} static int main_imsg_send_ipc_sockets(struct imsgbuf *frontend_buf, struct imsgbuf *engine_buf) diff --git a/sbin/slaacd/slaacd.h b/sbin/slaacd/slaacd.h index 77087c3c56a..9f7ba45749d 100644 --- a/sbin/slaacd/slaacd.h +++ b/sbin/slaacd/slaacd.h @@ -1,4 +1,4 @@ -/* $OpenBSD: slaacd.h,v 1.39 2024/08/24 09:42:40 florian Exp $ */ +/* $OpenBSD: slaacd.h,v 1.40 2024/08/24 16:34:23 florian Exp $ */ /* * Copyright (c) 2017 Florian Obser <florian@openbsd.org> @@ -27,8 +27,6 @@ #define MAX_RDNS_COUNT 8 /* max nameserver in a RTM_PROPOSAL */ -#define IMSG_DATA_SIZE(imsg) ((imsg).hdr.len - IMSG_HEADER_SIZE) - struct imsgev { struct imsgbuf ibuf; void (*handler)(int, short, void *); @@ -204,6 +202,7 @@ struct imsg_dup_addr { void imsg_event_add(struct imsgev *); int imsg_compose_event(struct imsgev *, uint16_t, uint32_t, pid_t, int, void *, uint16_t); +int imsg_forward_event(struct imsgev *, struct imsg *); #ifndef SMALL const char *sin6_to_str(struct sockaddr_in6 *); const char *i2s(uint32_t); |