summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNikos Mavrogiannopoulos <nmav@gnutls.org>2012-07-21 14:14:53 +0200
committerNikos Mavrogiannopoulos <nmav@gnutls.org>2012-07-21 14:14:53 +0200
commit9cda828053a6a0878535963f81a7fc1f772d8b59 (patch)
tree70886b5511b09d58ced100f49d72af88a19275e1
parent83155cf54ac3983bcefa93a451b038b625e9a357 (diff)
downloadgnutls-9cda828053a6a0878535963f81a7fc1f772d8b59.tar.gz
use stack for file paths
-rw-r--r--tests/openpgp-auth.c12
-rw-r--r--tests/openpgp-auth2.c12
2 files changed, 14 insertions, 10 deletions
diff --git a/tests/openpgp-auth.c b/tests/openpgp-auth.c
index 503519aa4f..548d51188a 100644
--- a/tests/openpgp-auth.c
+++ b/tests/openpgp-auth.c
@@ -60,7 +60,7 @@ doit ()
int err, i;
int sockets[2];
const char *srcdir;
- char *pub_key_path, *priv_key_path;
+ char pub_key_path[512], priv_key_path[512];
pid_t child;
gnutls_global_init ();
@@ -87,12 +87,16 @@ doit ()
if (err != 0)
fail ("socketpair %s\n", strerror (errno));
- pub_key_path = malloc (strlen (srcdir) + strlen (pub_key_file) + 2);
+ if (sizeof(pub_key_path) < strlen (srcdir) + strlen (pub_key_file) + 2)
+ abort();
+
strcpy (pub_key_path, srcdir);
strcat (pub_key_path, "/");
strcat (pub_key_path, pub_key_file);
- priv_key_path = malloc (strlen (srcdir) + strlen (priv_key_file) + 2);
+ if (sizeof(priv_key_path) < strlen (srcdir) + strlen (priv_key_file) + 2)
+ abort();
+
strcpy (priv_key_path, srcdir);
strcat (priv_key_path, "/");
strcat (priv_key_path, priv_key_file);
@@ -267,8 +271,6 @@ 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 8877df593f..79a7ad9bef 100644
--- a/tests/openpgp-auth2.c
+++ b/tests/openpgp-auth2.c
@@ -69,7 +69,7 @@ doit ()
int err;
int sockets[2];
const char *srcdir;
- char *pub_key_path, *priv_key_path;
+ char pub_key_path[512], priv_key_path[512];
pid_t child;
gnutls_global_init ();
@@ -86,12 +86,16 @@ doit ()
if (err != 0)
fail ("socketpair %s\n", strerror (errno));
- pub_key_path = malloc (strlen (srcdir) + strlen (pub_key_file) + 2);
+ if (sizeof(pub_key_path) < strlen (srcdir) + strlen (pub_key_file) + 2)
+ abort();
+
strcpy (pub_key_path, srcdir);
strcat (pub_key_path, "/");
strcat (pub_key_path, pub_key_file);
- priv_key_path = malloc (strlen (srcdir) + strlen (priv_key_file) + 2);
+ if (sizeof(priv_key_path) < strlen (srcdir) + strlen (priv_key_file) + 2)
+ abort();
+
strcpy (priv_key_path, srcdir);
strcat (priv_key_path, "/");
strcat (priv_key_path, priv_key_file);
@@ -250,8 +254,6 @@ doit ()
fail ("child failed: %d\n", status);
}
- free(pub_key_path);
- free(priv_key_path);
gnutls_global_deinit ();
}
#else