]> git.ipfire.org Git - thirdparty/gnutls.git/commitdiff
Avoid the usage of alloca(). Reported by Rob McMahon.
authorNikos Mavrogiannopoulos <nmav@gnutls.org>
Thu, 19 Jul 2012 18:59:13 +0000 (20:59 +0200)
committerNikos Mavrogiannopoulos <nmav@gnutls.org>
Thu, 19 Jul 2012 18:59:55 +0000 (20:59 +0200)
tests/openpgp-auth.c
tests/openpgp-auth2.c

index d3e521c415285770fb88d6955d7ec2bd0a848748..503519aa4f84e50f3eeb915c293ec0f8f6be97cc 100644 (file)
@@ -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
index 92253fd31f5c9e620c3633a21b58ae3bd4427c3e..8877df593fb1ee2a5378a51f77a27b4287675b74 100644 (file)
@@ -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