networkd-ndisc: add assert for DNSSL allocation overflow safety

Coverity flags ALIGN(sizeof(NDiscDNSSL)) + strlen(*j) + 1 as a
potential overflow. Domain names are protocol-bounded but add an
assert to make this explicit for static analyzers.

CID#1548066

Follow-up for 1e7a0e21c9
This commit is contained in:
Luca Boccassi
2026-03-30 09:37:31 +01:00
parent 21cc3216a7
commit 3fd6774633
+2
View File
@@ -1909,6 +1909,8 @@ static int ndisc_router_process_dnssl(Link *link, sd_ndisc_router *rt, bool zero
_cleanup_free_ NDiscDNSSL *s = NULL;
NDiscDNSSL *dnssl;
/* Silence static analyzers */
assert(strlen(*j) <= SIZE_MAX - ALIGN(sizeof(NDiscDNSSL)) - 1);
s = malloc0(ALIGN(sizeof(NDiscDNSSL)) + strlen(*j) + 1);
if (!s)
return log_oom();