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.
This commit is contained in:
Beniamino Galvani
2025-02-20 18:42:20 +01:00
committed by Íñigo Huguet
parent 472a7b48e8
commit 14a521ac9b

View File

@@ -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);