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