TEST: have key_unsupported() in evp_test.c look at the last error
authorRichard Levitte <levitte@openssl.org>
Sat, 29 Aug 2020 18:38:25 +0000 (20:38 +0200)
committerRichard Levitte <levitte@openssl.org>
Thu, 3 Sep 2020 15:48:32 +0000 (17:48 +0200)
key_unsupported() looked at the first error in the queue to see if a
key algorithm is supported or not.  However, there are situations
where the errors it looks for is preceded by others.  It's much safer
to look at the last recorded error.

Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/12587)

test/evp_test.c

index 238bbaf3d5c6b4b68fd3e7236db860f5919b748a..d5ec08c469ea27e306e55652411104d5d3660fe7 100644 (file)
@@ -3253,7 +3253,7 @@ static void free_key_list(KEY_LIST *lst)
  */
 static int key_unsupported(void)
 {
-    long err = ERR_peek_error();
+    long err = ERR_peek_last_error();
 
     if (ERR_GET_LIB(err) == ERR_LIB_EVP
             && (ERR_GET_REASON(err) == EVP_R_UNSUPPORTED_ALGORITHM