include: remove VLAs

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
This commit is contained in:
Christian Brauner 2018-07-26 14:42:05 +02:00
parent f994bc87af
commit dd94de5a87
No known key found for this signature in database
GPG Key ID: 8EB056D53EECB12D
2 changed files with 15 additions and 2 deletions

View 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;
}

View 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);