tree-wide: use device_get_sysattr_safe_string()

The obtained strings are passed to another function, e,g, handled as a
path and opened, printed to the terminal, written to a file, saved to
udev database as udev property, exposed through DBus, passed to logger,
and so on. Hence, these should not contain any malicious characters.
This commit is contained in:
Yu Watanabe
2026-05-18 02:55:56 +09:00
parent fdce4d4687
commit 06d687ffac
14 changed files with 47 additions and 35 deletions
+2 -2
View File
@@ -281,7 +281,7 @@ static int validate_device(sd_device *device) {
const char *other_sysname = NULL, *other_type = NULL;
(void) sd_device_get_sysname(other, &other_sysname);
(void) sd_device_get_sysattr_value(other, "type", &other_type);
(void) device_get_sysattr_safe_string(other, "type", &other_type);
log_device_debug(device,
"Found another %s backlight device %s on the same PCI, skipping.",
strna(other_type), strna(other_sysname));
@@ -295,7 +295,7 @@ static int validate_device(sd_device *device) {
const char *other_sysname = NULL, *other_type = NULL;
(void) sd_device_get_sysname(other, &other_sysname);
(void) sd_device_get_sysattr_value(other, "type", &other_type);
(void) device_get_sysattr_safe_string(other, "type", &other_type);
log_device_debug(device,
"Found another %s backlight device %s, which has higher precedence, skipping.",
strna(other_type), strna(other_sysname));