]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
nbd: remove stack allocations
authorChristian Brauner <christian.brauner@ubuntu.com>
Tue, 5 Feb 2019 06:42:50 +0000 (07:42 +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/nbd.c

index 2fae1fdb25c8e165efeb8bfcc1dca65d5746fa56..8b19d63ac00f206fe49f723db181ccc4b112aae3 100644 (file)
@@ -35,6 +35,7 @@
 
 #include "config.h"
 #include "log.h"
+#include "memory_utils.h"
 #include "nbd.h"
 #include "storage.h"
 #include "storage_utils.h"
@@ -61,14 +62,11 @@ static bool wait_for_partition(const char *path);
 
 bool attach_nbd(char *src, struct lxc_conf *conf)
 {
-       char *orig, *p, path[50];
+       __do_free char *orig;
+       char *p, path[50];
        int i = 0;
-       size_t len;
-
-       len = strlen(src);
-       orig = alloca(len + 1);
-       (void)strlcpy(orig, src, len + 1);
 
+       orig = must_copy_string(src);
        /* if path is followed by a partition, drop that for now */
        p = strchr(orig, ':');
        if (p)