]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
udev-builtin: replace udev_build_argv() by strv_split_extract()
authorYu Watanabe <watanabe.yu+github@gmail.com>
Sun, 23 Sep 2018 06:49:49 +0000 (15:49 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Wed, 26 Sep 2018 13:58:51 +0000 (22:58 +0900)
src/udev/udev-builtin.c

index be7e995933fb8ce9b479d02c9908542c371c090e..956dc30ed2976af3c1afa3a8fc826cf71eea6a81 100644 (file)
@@ -102,18 +102,18 @@ enum udev_builtin_cmd udev_builtin_lookup(const char *command) {
 }
 
 int udev_builtin_run(struct udev_device *dev, enum udev_builtin_cmd cmd, const char *command, bool test) {
-        char arg[UTIL_PATH_SIZE];
-        int argc;
-        char *argv[128];
+        _cleanup_strv_free_ char **argv = NULL;
 
         if (!builtins[cmd])
                 return -EOPNOTSUPP;
 
+        argv = strv_split_full(command, NULL, SPLIT_QUOTES | SPLIT_RELAX);
+        if (!argv)
+                return -ENOMEM;
+
         /* we need '0' here to reset the internal state */
         optind = 0;
-        strscpy(arg, sizeof(arg), command);
-        udev_build_argv(arg, &argc, argv);
-        return builtins[cmd]->cmd(dev, argc, argv, test);
+        return builtins[cmd]->cmd(dev, strv_length(argv), argv, test);
 }
 
 int udev_builtin_add_property(struct udev_device *dev, bool test, const char *key, const char *val) {