network: remove stack allocations

parent 244f7f87
...@@ -54,6 +54,7 @@ ...@@ -54,6 +54,7 @@
#include "file_utils.h" #include "file_utils.h"
#include "log.h" #include "log.h"
#include "macro.h" #include "macro.h"
#include "memory_utils.h"
#include "network.h" #include "network.h"
#include "nl.h" #include "nl.h"
#include "raw_syscalls.h" #include "raw_syscalls.h"
...@@ -549,15 +550,15 @@ out: ...@@ -549,15 +550,15 @@ out:
#define PHYSNAME "/sys/class/net/%s/phy80211/name" #define PHYSNAME "/sys/class/net/%s/phy80211/name"
static char *is_wlan(const char *ifname) static char *is_wlan(const char *ifname)
{ {
__do_free char *path;
int i, ret; int i, ret;
long physlen; long physlen;
size_t len; size_t len;
char *path;
FILE *f; FILE *f;
char *physname = NULL; char *physname = NULL;
len = strlen(ifname) + strlen(PHYSNAME) - 1; len = strlen(ifname) + strlen(PHYSNAME) - 1;
path = alloca(len + 1); path = must_realloc(NULL, len + 1);
ret = snprintf(path, len, PHYSNAME, ifname); ret = snprintf(path, len, PHYSNAME, ifname);
if (ret < 0 || (size_t)ret >= len) if (ret < 0 || (size_t)ret >= len)
goto bad; goto bad;
......
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