Index | Thread | Search

From:
Rafael Sadowski <rafael@sizeofvoid.org>
Subject:
httpd: use imsg_get_data to read ctl_flags
To:
tech@openbsd.org
Date:
Fri, 18 Sep 2026 23:10:46 +0200

Download raw body.

Thread
Simplify imsg handling by using imsg_get_data. I don't understand why we
should ignore the error here. It was here since the beginning.

commit 818498aa26f5c8db914b75e4a608257f03356761
Author: Rafael Sadowski <rafael@sizeofvoid.org>
Date:   Fri Sep 18 22:56:31 2026 +0200

    httpd: use imsg_get_data to read ctl_flags

diff --git a/config.c b/config.c
index d043ee8..371fc48 100644
--- a/config.c
+++ b/config.c
@@ -143,11 +143,10 @@ config_getcfg(struct httpd *env, struct imsg *imsg)
 {
 	struct ctl_flags	 cf;
 
-	if (IMSG_DATA_SIZE(imsg) != sizeof(cf))
-		return (0); /* ignore */
+	if (imsg_get_data(imsg, &cf, sizeof(cf)) == -1)
+		fatalx("%s: imsg_get_data", __func__);
 
 	/* Update runtime flags */
-	memcpy(&cf, imsg->data, sizeof(cf));
 	env->sc_opts = cf.cf_opts;
 	env->sc_flags = cf.cf_flags;
 	memcpy(env->sc_tls_sid, cf.cf_tls_sid, sizeof(env->sc_tls_sid));