Skip to content

Commit

Permalink
OSSL_STORE: Fix error flag clearing and setting (provider path only)
Browse files Browse the repository at this point in the history
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 #21976)

(cherry picked from commit 17dd9a2)
  • Loading branch information
levitte committed Sep 8, 2023
1 parent 41136a9 commit 137e3a9
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions crypto/store/store_lib.c
Original file line number Diff line number Diff line change
Expand Up @@ -424,14 +424,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;
Expand Down

0 comments on commit 137e3a9

Please sign in to comment.