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

index 4f8c285a06a4c2c0f0e8aef6d63ec0f3f69ddfa1..6a71a9a11d8eea8bb9d9cff75e9f149a9daaa0c5 100644 (file)
@@ -49,6 +49,7 @@
 #include "log.h"
 #include "lxclock.h"
 #include "macro.h"
+#include "memory_utils.h"
 #include "monitor.h"
 #include "state.h"
 #include "utils.h"
@@ -170,9 +171,9 @@ int lxc_monitor_close(int fd)
  */
 int lxc_monitor_sock_name(const char *lxcpath, struct sockaddr_un *addr)
 {
+       __do_free char *path;
        size_t len;
        int ret;
-       char *path;
        uint64_t hash;
 
        /* addr.sun_path is only 108 bytes, so we hash the full name and
@@ -183,7 +184,7 @@ int lxc_monitor_sock_name(const char *lxcpath, struct sockaddr_un *addr)
 
        /* strlen("lxc/") + strlen("/monitor-sock") + 1 = 18 */
        len = strlen(lxcpath) + 18;
-       path = alloca(len);
+       path = must_realloc(NULL, len);
        ret = snprintf(path, len, "lxc/%s/monitor-sock", lxcpath);
        if (ret < 0 || (size_t)ret >= len) {
                ERROR("Failed to create name for monitor socket");