summaryrefslogtreecommitdiff
path: root/tests/basic.c
diff options
context:
space:
mode:
authorJakub Jelen <jjelen@redhat.com>2022-05-11 15:06:30 +0200
committerNIIBE Yutaka <gniibe@fsij.org>2022-05-31 15:22:10 +0900
commitef2e1523c33c3143b4fee0c00f88a5a0842b337f (patch)
treeb2caa75c882b2ba133ec9fc82f8bfe007bd0f2a9 /tests/basic.c
parentca2afc9fb64d9a9b2f8930ba505d9ab6c8a57667 (diff)
downloadlibgcrypt-ef2e1523c33c3143b4fee0c00f88a5a0842b337f.tar.gz
Fix memory leaks in tests
* tests/aeswrap.c (check_one_with_padding): Free hd on error paths * tests/basic.c (check_ccm_cipher): Free context on error paths (check_ocb_cipher_checksum): Ditto. (do_check_xts_cipher): Ditto. (check_gost28147_cipher_basic): Ditto. * tests/bench-slope.c (bench_ecc_init): Free memory on invalid input. * tests/t-cv25519.c (test_it): Free memory on error path * tests/t-dsa.c (hex2buffer): Free memory on error path * tests/t-ecdsa.c (hex2buffer): Free memory on error path (one_test_sexp): Cleanup memory on exit * tests/t-mpi-point.c (check_ec_mul): Free memory on error (check_ec_mul_reduction): Ditto * tests/t-rsa-15.c (hex2buffer): Ditto * tests/t-rsa-pss.c (hex2buffer): Ditto * tests/t-x448.c (test_it): Free memory on error path * tests/testdrv.c (my_spawn): Free memory on error paths -- GnuPG-bug-id: 5973 Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Diffstat (limited to 'tests/basic.c')
-rw-r--r--tests/basic.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/tests/basic.c b/tests/basic.c
index f5513740..90bbf962 100644
--- a/tests/basic.c
+++ b/tests/basic.c
@@ -7339,6 +7339,8 @@ check_ccm_cipher (void)
if (!keylen)
{
fail ("cipher-ccm, gcry_cipher_get_algo_keylen failed\n");
+ gcry_cipher_close (hde);
+ gcry_cipher_close (hdd);
return;
}
@@ -7358,6 +7360,8 @@ check_ccm_cipher (void)
if (!blklen)
{
fail ("cipher-ccm, gcry_cipher_get_algo_blklen failed\n");
+ gcry_cipher_close (hde);
+ gcry_cipher_close (hdd);
return;
}
@@ -8431,7 +8435,7 @@ check_ocb_cipher_checksum (int algo, int keylen)
const size_t buflen = 128 * 16;
unsigned char *inbuf, *outbuf;
gpg_error_t err = 0;
- gcry_cipher_hd_t hde, hde2, hdd;
+ gcry_cipher_hd_t hde = NULL, hde2 = NULL, hdd = NULL;
unsigned char tag[16];
unsigned char tag2[16];
unsigned char tag3[16];
@@ -8493,6 +8497,8 @@ check_ocb_cipher_checksum (int algo, int keylen)
err = gcry_cipher_open (&hdd, algo, GCRY_CIPHER_MODE_OCB, 0);
if (err)
{
+ gcry_cipher_close (hde);
+ gcry_cipher_close (hde2);
fail ("cipher-ocb, gcry_cipher_open failed (checksum, algo %d): %s\n",
algo, gpg_strerror (err));
goto out_free;
@@ -9126,6 +9132,7 @@ do_check_xts_cipher (int inplace)
{
fail ("cipher-xts, gcry_cipher_open failed (tv %d): %s\n",
tidx, gpg_strerror (err));
+ gcry_cipher_close (hde);
return;
}
@@ -9350,6 +9357,8 @@ check_gost28147_cipher_basic (enum gcry_cipher_algos algo)
if (err)
{
fail ("gost28147, gcry_cipher_open failed: %s\n", gpg_strerror (err));
+ gcry_cipher_close (hde);
+ gcry_cipher_close (hdd);
return;
}