From 7c21568bcd0fdf27420043a4ea11bb4d7a125164 Mon Sep 17 00:00:00 2001 From: Jim Garlick Date: Mon, 18 Sep 2023 09:34:59 -0700 Subject: [PATCH] broker/module: comment unchecked snprintf Problem: an snprintf() return value is not checked. Cast to void and add a comment explaining why it cannot fail. --- src/broker/module.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/broker/module.c b/src/broker/module.c index 4967420cbc71..c08be1ea496b 100644 --- a/src/broker/module.c +++ b/src/broker/module.c @@ -372,10 +372,11 @@ module_t *module_create (flux_t *h, } zsock_set_unbounded (p->sock); zsock_set_linger (p->sock, 5); - snprintf (p->endpoint, - sizeof (p->endpoint), - "inproc://%s", - module_get_uuid (p)); + // copying 9 + 37 + 1 = 47 bytes into 128 byte buffer cannot fail + (void)snprintf (p->endpoint, + sizeof (p->endpoint), + "inproc://%s", + module_get_uuid (p)); if (zmq_bind (p->sock, p->endpoint) < 0) { errprintf (error, "zmq_bind %s: %s", p->endpoint, strerror (errno)); goto cleanup;