]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
OSSL_STORE: Fix error flag clearing and setting (provider path only)
authorRichard Levitte <levitte@openssl.org>
Wed, 6 Sep 2023 05:13:26 +0000 (07:13 +0200)
committerRichard Levitte <levitte@openssl.org>
Fri, 8 Sep 2023 06:32:58 +0000 (08:32 +0200)
When the provider's load function returned with an error, the libcrypto
error flag was only set if EOF hadn't been reached.  This is troublesome,
as an error can very well occur during the last load before EOF is reached!

Also, the error flag was never reset, even though documentation specifies
that it should indicate an error in the last load (i.e. not the one before
that).

Fixes #21968

Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/21976)

crypto/store/store_lib.c

index fcacf687e629d1b90810437e227edb805d1a3d65..0e805062ac0c09cbd13465f65b0644ad69e2ab9d 100644 (file)
@@ -428,14 +428,14 @@ OSSL_STORE_INFO *OSSL_STORE_load(OSSL_STORE_CTX *ctx)
 
             load_data.v = NULL;
             load_data.ctx = ctx;
+            ctx->error_flag = 0;
 
             if (!ctx->fetched_loader->p_load(ctx->loader_ctx,
                                              ossl_store_handle_load_result,
                                              &load_data,
                                              ossl_pw_passphrase_callback_dec,
                                              &ctx->pwdata)) {
-                if (!OSSL_STORE_eof(ctx))
-                    ctx->error_flag = 1;
+                ctx->error_flag = 1;
                 return NULL;
             }
             v = load_data.v;