rbd: remove stack allocations

parent 9371d3f2
...@@ -33,6 +33,7 @@ ...@@ -33,6 +33,7 @@
#include "config.h" #include "config.h"
#include "log.h" #include "log.h"
#include "memory_utils.h"
#include "storage.h" #include "storage.h"
#include "storage_utils.h" #include "storage_utils.h"
#include "utils.h" #include "utils.h"
...@@ -195,9 +196,9 @@ int rbd_create(struct lxc_storage *bdev, const char *dest, const char *n, ...@@ -195,9 +196,9 @@ int rbd_create(struct lxc_storage *bdev, const char *dest, const char *n,
int rbd_destroy(struct lxc_storage *orig) int rbd_destroy(struct lxc_storage *orig)
{ {
__do_free char *rbdfullname = NULL;
int ret; int ret;
const char *src; const char *src;
char *rbdfullname;
char cmd_output[PATH_MAX]; char cmd_output[PATH_MAX];
struct rbd_args args = {0}; struct rbd_args args = {0};
size_t len; size_t len;
...@@ -215,7 +216,7 @@ int rbd_destroy(struct lxc_storage *orig) ...@@ -215,7 +216,7 @@ int rbd_destroy(struct lxc_storage *orig)
} }
len = strlen(src); len = strlen(src);
rbdfullname = alloca(len - 8); rbdfullname = must_realloc(NULL, len - 8);
(void)strlcpy(rbdfullname, &src[9], len - 8); (void)strlcpy(rbdfullname, &src[9], len - 8);
args.rbd_name = rbdfullname; args.rbd_name = rbdfullname;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment