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:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user