diff --git a/src/hostname/hostnamed.c b/src/hostname/hostnamed.c index 2292c07661..f8c20ff9c7 100644 --- a/src/hostname/hostnamed.c +++ b/src/hostname/hostnamed.c @@ -321,18 +321,6 @@ static int context_acquire_device_tree(Context *c) { return 1; } -static bool string_is_safe_for_dbus(const char *s) { - assert(s); - - /* Do some superficial validation: do not allow CCs and make sure D-Bus won't kick us off the bus - * because we send invalid UTF-8 data */ - - if (string_has_cc(s, /* ok= */ NULL)) - return false; - - return utf8_is_valid(s); -} - static int get_dmi_property(Context *c, const char *key, char **ret) { const char *s; int r; @@ -348,7 +336,7 @@ static int get_dmi_property(Context *c, const char *key, char **ret) { if (r < 0) return r; - if (!string_is_safe_for_dbus(s)) + if (!string_is_safe(s, STRING_ALLOW_EMPTY|STRING_ALLOW_BACKSLASHES|STRING_ALLOW_QUOTES|STRING_ALLOW_GLOBS)) return -ENXIO; return strdup_to(ret, s); @@ -447,7 +435,7 @@ static int get_sysattr(sd_device *device, const char *key, char **ret) { if (r < 0) return log_device_debug_errno(device, r, "Failed to read '%s' attribute: %m", key); - if (!string_is_safe_for_dbus(s)) + if (!string_is_safe(s, STRING_ALLOW_EMPTY|STRING_ALLOW_BACKSLASHES|STRING_ALLOW_QUOTES|STRING_ALLOW_GLOBS)) return log_device_debug_errno(device, SYNTHETIC_ERRNO(ENXIO), "'%s' attribute is not safe for exposing through DBus: %s", key, s);