@@ -312,7 +312,7 @@ struct l_dhcp6_lease *_dhcp6_lease_parse_options(
lease->rapid_commit = true;
break;
case L_DHCP6_OPTION_DOMAIN_LIST:
- lease->domain_list = net_domain_list_parse(v, l);
+ lease->domain_list = net_domain_list_parse(v, l, false);
if (!lease->domain_list)
goto error;
@@ -1104,11 +1104,11 @@ struct l_icmp6_router *_icmp6_router_parse(const struct nd_router_advert *ra,
{
struct domain_info *info = &r->domains[n_domains];
_auto_(l_free) char **domain_list =
- net_domain_list_parse(opts + 8, l - 8);
+ net_domain_list_parse(opts + 8, l - 8, true);
char **i;
- /* Ignore invalid option */
- if (!domain_list)
+ /* Ignore malformed option */
+ if (!domain_list || !domain_list[0])
break;
for (i = domain_list; *i; i++) {
@@ -21,7 +21,7 @@
*/
char *net_domain_name_parse(const uint8_t *raw, size_t raw_len);
-char **net_domain_list_parse(const uint8_t *raw, size_t raw_len);
+char **net_domain_list_parse(const uint8_t *raw, size_t raw_len, bool padded);
static inline const void *net_prefix_from_ipv6(const uint8_t *address,
uint8_t prefix_len)
@@ -295,7 +295,7 @@ char *net_domain_name_parse(const uint8_t *raw, size_t raw_len)
/*
* Parse list of domain names encoded according to RFC 1035 Section 3.1
*/
-char **net_domain_list_parse(const uint8_t *raw, size_t raw_len)
+char **net_domain_list_parse(const uint8_t *raw, size_t raw_len, bool padded)
{
size_t remaining = raw_len;
const uint8_t *p = raw;
@@ -305,6 +305,9 @@ char **net_domain_list_parse(const uint8_t *raw, size_t raw_len)
struct l_string *growable = NULL;
while (remaining) {
+ if (padded && p[0] == 0)
+ break;
+
r = validate_next_domain_name(p, remaining);
if (r < 0)
return NULL;
@@ -323,6 +326,9 @@ char **net_domain_list_parse(const uint8_t *raw, size_t raw_len)
remaining -= *p + 1;
if (*p == 0) {
+ if (!growable)
+ break;
+
p += 1;
ret[nitems++] = l_string_unwrap(growable);
growable = NULL;