]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
storage: remove stack allocations
authorChristian Brauner <christian.brauner@ubuntu.com>
Tue, 5 Feb 2019 06:32:21 +0000 (07:32 +0100)
committerChristian Brauner <christian.brauner@ubuntu.com>
Wed, 6 Feb 2019 10:47:57 +0000 (11:47 +0100)
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
src/lxc/storage/storage.c

index 837e8cabeebb1fdb3a3e518eafba375be7ede753..4cff0a1a4d98805a4eb4e0ce929085687dcf1e35 100644 (file)
@@ -51,6 +51,7 @@
 #include "lvm.h"
 #include "lxc.h"
 #include "lxclock.h"
+#include "memory_utils.h"
 #include "namespace.h"
 #include "nbd.h"
 #include "overlay.h"
@@ -567,13 +568,11 @@ struct lxc_storage *storage_create(const char *dest, const char *type,
 
        /* -B lvm,dir */
        if (strchr(type, ',')) {
-               char *dup, *token;
+               __do_free char *dup;
+               char *token;
                size_t len;
 
-               len = strlen(type);
-               dup = alloca(len + 1);
-               (void)strlcpy(dup, type, len + 1);
-
+               dup = must_copy_string(type);
                lxc_iterate_parts(token, dup, ",") {
                        bdev = do_storage_create(dest, token, cname, specs);
                        if (bdev)