From 4c9af3155b13322911f75e09052c675113091877 Mon Sep 17 00:00:00 2001 From: Beniamino Galvani Date: Wed, 29 Jan 2025 11:51:18 +0100 Subject: [PATCH] systemd: accept encoded domain names without terminating zero label Backport the following fix from systemd: https://github.com/systemd/systemd/commit/30675a6ee98540a02bd1d6afcf80f0c0aa8c0910 This fixes NMCI test failure for test "dhcpv6_hostname". --- src/libnm-systemd-shared/src/shared/dns-domain.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/libnm-systemd-shared/src/shared/dns-domain.c b/src/libnm-systemd-shared/src/shared/dns-domain.c index 7d74bda87d..42efd04a3e 100644 --- a/src/libnm-systemd-shared/src/shared/dns-domain.c +++ b/src/libnm-systemd-shared/src/shared/dns-domain.c @@ -932,9 +932,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)