Always prefer vararrays to alloca()

This commit is contained in:
Frank Denis 2017-12-12 22:27:21 +01:00
parent 2f56443631
commit 95a7dc5e46

View File

@ -21,9 +21,10 @@
# include <unistd.h>
#endif
#if HAVE_ALLOCA_H
#ifndef HAVE_C_VARARRAYS
# ifdef HAVE_ALLOCA_H
# include <alloca.h>
#elif !defined(alloca)
# elif !defined(alloca)
# if defined(__GNUC__)
# define alloca __builtin_alloca
# elif defined _AIX
@ -38,6 +39,7 @@ extern "C"
# endif
void *alloca (size_t);
# endif
# endif
#endif
#include "core.h"
@ -128,11 +130,11 @@ sodium_memzero(void *const pnt, const size_t len)
void
sodium_stackzero(const size_t len)
{
#ifdef HAVE_ALLOCA
sodium_memzero(alloca(len), len);
#elif HAVE_C_VARARRAYS
#ifdef HAVE_C_VARARRAYS
unsigned char fodder[len];
sodium_memzero(fodder, len);
#elif HAVE_ALLOCA
sodium_memzero(alloca(len), len);
#endif
}