]> git.proxmox.com Git - mirror_lxc.git/commitdiff
rbd: remove stack allocations
authorChristian Brauner <christian.brauner@ubuntu.com>
Tue, 5 Feb 2019 06:44:13 +0000 (07:44 +0100)
committerChristian Brauner <christian.brauner@ubuntu.com>
Wed, 6 Feb 2019 10:47:58 +0000 (11:47 +0100)
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
src/lxc/storage/rbd.c

index e02a629b9181bf93c235fefbc7fbf0a902d6ad34..beeebab7855a96d060dff215debd12bddb66c7bc 100644 (file)
@@ -33,6 +33,7 @@
 
 #include "config.h"
 #include "log.h"
+#include "memory_utils.h"
 #include "storage.h"
 #include "storage_utils.h"
 #include "utils.h"
@@ -195,9 +196,9 @@ int rbd_create(struct lxc_storage *bdev, const char *dest, const char *n,
 
 int rbd_destroy(struct lxc_storage *orig)
 {
+       __do_free char *rbdfullname = NULL;
        int ret;
        const char *src;
-       char *rbdfullname;
        char cmd_output[PATH_MAX];
        struct rbd_args args = {0};
        size_t len;
@@ -215,7 +216,7 @@ int rbd_destroy(struct lxc_storage *orig)
        }
 
        len = strlen(src);
-       rbdfullname = alloca(len - 8);
+       rbdfullname = must_realloc(NULL, len - 8);
        (void)strlcpy(rbdfullname, &src[9], len - 8);
        args.rbd_name = rbdfullname;