]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
udevadm-info: use strdup() instead of strscpy()
authorYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 2 Oct 2018 07:23:50 +0000 (16:23 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 16 Oct 2018 18:31:20 +0000 (03:31 +0900)
src/udev/udevadm-info.c

index dbbc589e6bc4574f8f48c8b4a4073fb47c073eac..b2127db0b17d1caa6a450928cf9a5f8e6b0d742d 100644 (file)
 
 #include "sd-device.h"
 
+#include "alloc-util.h"
 #include "device-enumerator-private.h"
 #include "device-private.h"
 #include "device-util.h"
 #include "dirent-util.h"
 #include "fd-util.h"
-#include "libudev-private.h"
 #include "string-util.h"
 #include "udevadm.h"
 #include "udevadm-util.h"
@@ -252,10 +252,9 @@ static int help(void) {
 
 int info_main(int argc, char *argv[], void *userdata) {
         _cleanup_(sd_device_unrefp) sd_device *device = NULL;
-        bool root = 0;
-        bool export = 0;
+        bool root = false, export = false;
+        _cleanup_free_ char *name = NULL;
         const char *export_prefix = NULL;
-        char name[UTIL_PATH_SIZE];
         int c, r;
 
         static const struct option options[] = {
@@ -332,7 +331,9 @@ int info_main(int argc, char *argv[], void *userdata) {
                         break;
                 case 'd':
                         action = ACTION_DEVICE_ID_FILE;
-                        strscpy(name, sizeof(name), optarg);
+                        name = strdup(optarg);
+                        if (!name)
+                                return log_oom();
                         break;
                 case 'a':
                         action = ACTION_ATTRIBUTE_WALK;