Not all possible DNS names will survive serialization. Restrict the set
of valid dns names to LDH encoded names.
Fixes: 25c33e350042 (network: parse RFC9463 DHCPv4 DNR option, 2024-01-16)
Fixes: a07e83cc58f6 (network: Parse RFC9463 DHCPv6 DNR option, 2024-01-17)
Fixes: 0c90d1d2f243 (ndisc: Parse RFC9463 encrypted DNS (DNR) option, 2024-01-19)
r = ndisc_get_dns_name(opt + off, ilen, &res.auth_name);
if (r < 0)
return r;
+ r = dns_name_is_valid_ldh(res.auth_name);
+ if (r < 0)
+ return r;
+ if (!r)
+ return -EBADMSG;
if (dns_name_is_root(res.auth_name))
return -EBADMSG;
off += ilen;
r = lease_parse_dns_name(option + offset, ilen, &res.auth_name);
if (r < 0)
return r;
+ r = dns_name_is_valid_ldh(res.auth_name);
+ if (r < 0)
+ return r;
+ if (!r)
+ return -EBADMSG;
if (dns_name_is_root(res.auth_name))
return -EBADMSG;
offset += ilen;
#include "alloc-util.h"
#include "dhcp6-internal.h"
#include "dhcp6-lease-internal.h"
+#include "dns-domain.h"
#include "network-common.h"
#include "sort-util.h"
#include "strv.h"
r = dhcp6_option_parse_domainname(optval + offset, ilen, &res.auth_name);
if (r < 0)
return r;
+ r = dns_name_is_valid_ldh(res.auth_name);
+ if (r < 0)
+ return r;
+ if (!r)
+ return -EBADMSG;
offset += ilen;
/* RFC9463 ยง 3.1.6: adn only mode */