From 14a521ac9bd20fff2a0d7dabd39351bc279e91e1 Mon Sep 17 00:00:00 2001 From: Beniamino Galvani Date: Thu, 20 Feb 2025 18:42:20 +0100 Subject: [PATCH] core: discard non UTF-8 search domains Domains are exported via D-Bus and so they must be valid UTF-8. RFC 1035 specifies that domain labels can contain any 8 bit values, but also recommends that they follow the "preferred syntax" which only allows letters, digits and hypens. Don't introduce a strict validation of the preferred syntax, but at least discard non UTF-8 search domains, as they will cause assertion failures later when they are sent over D-Bus. --- src/core/nm-l3-config-data.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/core/nm-l3-config-data.c b/src/core/nm-l3-config-data.c index 70867ff70e..2062314581 100644 --- a/src/core/nm-l3-config-data.c +++ b/src/core/nm-l3-config-data.c @@ -1419,6 +1419,9 @@ _check_and_add_domain(GPtrArray **p_arr, const char *domain) if (domain[0] == '.' || strstr(domain, "..")) return FALSE; + if (!g_utf8_validate(domain, -1, NULL)) + return FALSE; + len = strlen(domain); if (domain[len - 1] == '.') { copy = g_strndup(domain, len - 1);