From 88af1ebb04bf9db0da9bb3949b407dc46e5d6644 Mon Sep 17 00:00:00 2001 From: Richard Levitte Date: Tue, 18 Feb 2020 15:35:24 +0100 Subject: [PATCH] test/evp_test.c: fix keygen_test_run() There was a misunderstanding what it should return. It should return 0 on internal error, but 1 even if the thing it tests fails (the error is determined by |t->err|). Reviewed-by: Shane Lontis (Merged from https://github.com/openssl/openssl/pull/10289) --- test/evp_test.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/test/evp_test.c b/test/evp_test.c index 63ae144920..0f2720807a 100644 --- a/test/evp_test.c +++ b/test/evp_test.c @@ -2504,8 +2504,8 @@ static int keygen_test_run(EVP_TEST *t) { KEYGEN_TEST_DATA *keygen = t->data; EVP_PKEY *pkey = NULL; + int rv = 1; - t->err = NULL; if (EVP_PKEY_keygen(keygen->genctx, &pkey) <= 0) { t->err = "KEYGEN_GENERATE_ERROR"; goto err; @@ -2514,6 +2514,7 @@ static int keygen_test_run(EVP_TEST *t) if (keygen->keyname != NULL) { KEY_LIST *key; + rv = 0; if (find_key(NULL, keygen->keyname, private_keys)) { TEST_info("Duplicate key %s", keygen->keyname); goto err; @@ -2526,15 +2527,15 @@ static int keygen_test_run(EVP_TEST *t) key->key = pkey; key->next = private_keys; private_keys = key; + rv = 1; } else { EVP_PKEY_free(pkey); } - return 1; + t->err = NULL; err: - EVP_PKEY_free(pkey); - return 0; + return rv; } static const EVP_TEST_METHOD keygen_test_method = { -- 2.25.1