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 19:01:47 +0200
commit4e3dde7d1324efc0f7db722e2f78fc9b5572a060 (patch)
tree29bf311535f86b2c94ef0b371fcbd8bf491f3d7b
parenta4d959ff0424a1b951955e0f12254bd903f0d2f7 (diff)
downloadgnutls-4e3dde7d1324efc0f7db722e2f78fc9b5572a060.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