]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
include: remove VLAs
authorChristian Brauner <christian.brauner@ubuntu.com>
Thu, 26 Jul 2018 12:42:05 +0000 (14:42 +0200)
committerChristian Brauner <christian.brauner@ubuntu.com>
Thu, 26 Jul 2018 14:38:42 +0000 (16:38 +0200)
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
src/include/ifaddrs.c
src/include/lxcmntent.c

index 1f954dd7d3ba62a8ccef07bfb3b3424346f15c88..3fbe170d6fed56fc75daa23ef22f85f6a7451ccd 100644 (file)
@@ -575,7 +575,15 @@ int getifaddrs(struct ifaddrs **ifap)
     }
 
     unsigned l_numLinks = countLinks(l_socket, l_linkResults) + countLinks(l_socket, l_addrResults);
-    struct ifaddrs *l_links[l_numLinks];
+    struct ifaddrs **l_links;
+    l_links = malloc(l_numLinks * sizeof(struct ifaddrs *));
+    if (!l_links)
+    {
+        close(l_socket);
+        freeResultList(l_linkResults);
+        return -1;
+    }
+
     memset(l_links, 0, l_numLinks * sizeof(struct ifaddrs *));
 
     interpret(l_socket, l_linkResults, l_links, ifap);
@@ -583,6 +591,7 @@ int getifaddrs(struct ifaddrs **ifap)
 
     freeResultList(l_linkResults);
     freeResultList(l_addrResults);
+    free(l_links);
     close(l_socket);
     return 0;
 }
index dcb34a2f6829fe9c758b2a83f03219d1eca905ff..53f5256a1de76e923bd506435342ad33fbcb8cc4 100644 (file)
@@ -18,6 +18,7 @@
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
  */
 
+#include <alloca.h>
 #include <stdio.h>
 #include <string.h>
 #include <mntent.h>
@@ -153,7 +154,10 @@ FILE *setmntent (const char *file, const char *mode)
     /* Extend the mode parameter with "c" to disable cancellation in the
     I/O functions and "e" to set FD_CLOEXEC. */
     size_t modelen = strlen (mode);
-    char newmode[modelen + 3];
+    char *newmode;
+
+    newmode = alloca(modelen + 3);
+
     memcpy (newmode, mode, modelen);
     memcpy (newmode + modelen, "ce", 3);
     FILE *result = fopen (file, newmode);