From 95ea3d1fa0981d02007920dfe13657ac75e787e7 Mon Sep 17 00:00:00 2001 From: Christian Brauner Date: Tue, 5 Feb 2019 07:27:29 +0100 Subject: [PATCH] network: remove stack allocations Signed-off-by: Christian Brauner --- src/lxc/network.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/lxc/network.c b/src/lxc/network.c index ec75b0c28..249d9d471 100644 --- a/src/lxc/network.c +++ b/src/lxc/network.c @@ -54,6 +54,7 @@ #include "file_utils.h" #include "log.h" #include "macro.h" +#include "memory_utils.h" #include "network.h" #include "nl.h" #include "raw_syscalls.h" @@ -549,15 +550,15 @@ out: #define PHYSNAME "/sys/class/net/%s/phy80211/name" static char *is_wlan(const char *ifname) { + __do_free char *path; int i, ret; long physlen; size_t len; - char *path; FILE *f; char *physname = NULL; len = strlen(ifname) + strlen(PHYSNAME) - 1; - path = alloca(len + 1); + path = must_realloc(NULL, len + 1); ret = snprintf(path, len, PHYSNAME, ifname); if (ret < 0 || (size_t)ret >= len) goto bad; -- 2.39.2