[PATCH mdnsd] service: do not leak uninitialized data in SRV record

Erik Karlsson erik.r.karlsson at gmail.com
Tue Apr 21 02:47:30 PDT 2026


From: Erik Karlsson <erik.karlsson at iopsys.eu>

The priority and weight fields will be set to zero in accordance with
behavior prior to introduction of the bug where calloc was used and in
accordance with RFC 6763 Section 5 which prescribes priority and weight
of zero for a single SRV record.

Fixes: cef25024 ("fix excessive stack usage")
Signed-off-by: Erik Karlsson <erik.karlsson at iopsys.eu>
---
 service.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/service.c b/service.c
index 441ec2e..1b52dfe 100644
--- a/service.c
+++ b/service.c
@@ -20,6 +20,7 @@
 #include <inttypes.h>
 #include <stdio.h>
 #include <time.h>
+#include <string.h>
 
 #include <libubus.h>
 #include <libubox/uloop.h>
@@ -98,6 +99,7 @@ service_add_srv(const char *name, struct service *s, int ttl)
 	if (len <= sizeof(*sd))
 		return;
 
+	memset(sd, 0, sizeof(*sd));
 	sd->port = cpu_to_be16(s->port);
 	dns_packet_answer(name, TYPE_SRV, mdns_buf, len, ttl);
 }
-- 
2.53.0




More information about the openwrt-devel mailing list