diff --git a/src/libsystemd-network/test-dhcp6-client.c b/src/libsystemd-network/test-dhcp6-client.c index 882c04afbb3..195aa145949 100644 --- a/src/libsystemd-network/test-dhcp6-client.c +++ b/src/libsystemd-network/test-dhcp6-client.c @@ -165,7 +165,9 @@ TEST(parse_domain) { domain = mfree(domain); data = (uint8_t []) { 4, 't', 'e', 's', 't' }; - assert_se(dhcp6_option_parse_domainname(data, 5, &domain) < 0); + ASSERT_OK(dhcp6_option_parse_domainname(data, 5, &domain)); + ASSERT_STREQ(domain, "test"); + domain = mfree(domain); data = (uint8_t []) { 0 }; assert_se(dhcp6_option_parse_domainname(data, 1, &domain) < 0); diff --git a/src/shared/dns-domain.c b/src/shared/dns-domain.c index e91284177c5..9f72b38c8ce 100644 --- a/src/shared/dns-domain.c +++ b/src/shared/dns-domain.c @@ -924,9 +924,12 @@ int dns_name_from_wire_format(const uint8_t **data, size_t *len, char **ret) { const char *label; uint8_t c; - /* Unterminated name */ + /* RFC 4704 § 4: fully qualified domain names include the terminating + * zero-length label, partial names don't. According to the RFC, DHCPv6 + * servers should always send the fully qualified name, but that's not + * true in practice. Also accept partial names. */ if (optlen == 0) - return -EBADMSG; + break; /* RFC 1035 § 3.1 total length of encoded name is limited to 255 octets */ if (*len - optlen > 255) diff --git a/src/test/test-dns-domain.c b/src/test/test-dns-domain.c index 053a93663c4..302fcfb7fbe 100644 --- a/src/test/test-dns-domain.c +++ b/src/test/test-dns-domain.c @@ -197,7 +197,7 @@ TEST(dns_name_from_wire_format) { test_dns_name_from_wire_format_one("", in0, sizeof(in0), strlen("")); test_dns_name_from_wire_format_one("foo", in1, sizeof(in1), strlen("foo")); - test_dns_name_from_wire_format_one(NULL, in1, sizeof(in1) - 1, -EBADMSG); + test_dns_name_from_wire_format_one("foo", in1, sizeof(in1) - 1, strlen("foo")); test_dns_name_from_wire_format_one("hallo.foo.bar", in2, sizeof(in2), strlen("hallo.foo.bar")); test_dns_name_from_wire_format_one("hallo.foo", in2_1, sizeof(in2_1), strlen("hallo.foo"));