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 -1
View File
@@ -15,6 +15,7 @@
#include "alloc-util.h"
#include "blockdev-util.h"
#include "data-fd-util.h"
#include "device-private.h"
#include "device-util.h"
#include "devnum-util.h"
#include "dissect-image.h"
@@ -1027,7 +1028,7 @@ int loop_device_open(
#endif
nr = info.lo_number;
if (sd_device_get_sysattr_value(dev, "loop/backing_file", &s) >= 0) {
if (device_get_sysattr_safe_string(dev, "loop/backing_file", &s) >= 0) {
backing_file = strdup(s);
if (!backing_file)
return -ENOMEM;