From: Nikos Mavrogiannopoulos Date: Thu, 19 Jul 2012 18:59:13 +0000 (+0200) Subject: Avoid the usage of alloca(). Reported by Rob McMahon. X-Git-Tag: gnutls_3_1_0pre0~38 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7af349a1f1f91baca8b7cae2ee3b53d9172bdaa7;p=thirdparty%2Fgnutls.git Avoid the usage of alloca(). Reported by Rob McMahon. --- diff --git a/tests/openpgp-auth.c b/tests/openpgp-auth.c index d3e521c415..503519aa4f 100644 --- a/tests/openpgp-auth.c +++ b/tests/openpgp-auth.c @@ -87,12 +87,12 @@ doit () if (err != 0) fail ("socketpair %s\n", strerror (errno)); - pub_key_path = alloca (strlen (srcdir) + strlen (pub_key_file) + 2); + pub_key_path = malloc (strlen (srcdir) + strlen (pub_key_file) + 2); strcpy (pub_key_path, srcdir); strcat (pub_key_path, "/"); strcat (pub_key_path, pub_key_file); - priv_key_path = alloca (strlen (srcdir) + strlen (priv_key_file) + 2); + priv_key_path = malloc (strlen (srcdir) + strlen (priv_key_file) + 2); strcpy (priv_key_path, srcdir); strcat (priv_key_path, "/"); strcat (priv_key_path, priv_key_file); @@ -267,6 +267,8 @@ doit () } + free(pub_key_path); + free(priv_key_path); gnutls_global_deinit (); } #else diff --git a/tests/openpgp-auth2.c b/tests/openpgp-auth2.c index 92253fd31f..8877df593f 100644 --- a/tests/openpgp-auth2.c +++ b/tests/openpgp-auth2.c @@ -86,12 +86,12 @@ doit () if (err != 0) fail ("socketpair %s\n", strerror (errno)); - pub_key_path = alloca (strlen (srcdir) + strlen (pub_key_file) + 2); + pub_key_path = malloc (strlen (srcdir) + strlen (pub_key_file) + 2); strcpy (pub_key_path, srcdir); strcat (pub_key_path, "/"); strcat (pub_key_path, pub_key_file); - priv_key_path = alloca (strlen (srcdir) + strlen (priv_key_file) + 2); + priv_key_path = malloc (strlen (srcdir) + strlen (priv_key_file) + 2); strcpy (priv_key_path, srcdir); strcat (priv_key_path, "/"); strcat (priv_key_path, priv_key_file); @@ -250,6 +250,8 @@ doit () fail ("child failed: %d\n", status); } + free(pub_key_path); + free(priv_key_path); gnutls_global_deinit (); } #else