Skip to content

Commit f1a88d2

Browse files
committed
Revert "Do not restore NULL UI method"
This reverts commit 0573d95.
1 parent e725696 commit f1a88d2

File tree

1 file changed

+26
-20
lines changed

1 file changed

+26
-20
lines changed

src/eng_back.c

Lines changed: 26 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -233,27 +233,30 @@ int ENGINE_CTX_finish(ENGINE_CTX *ctx)
233233
EVP_PKEY *ENGINE_CTX_load_pubkey(ENGINE_CTX *ctx, const char *s_key_id,
234234
UI_METHOD *ui_method, void *callback_data)
235235
{
236-
UI_METHOD *orig_ui_method = ctx->ui_method;
237-
void *orig_callback_data = ctx->callback_data;
236+
UI_METHOD *orig_ui_method;
237+
void *orig_callback_data;
238238
EVP_PKEY *evp_pkey;
239239

240-
ctx->ui_method = ui_method;
241-
ctx->callback_data = callback_data;
242-
243240
pthread_mutex_lock(&ctx->lock);
241+
244242
/* Delayed libp11 initialization */
245243
if (!UTIL_CTX_init_libp11(ctx->util_ctx)) {
246244
ENGerr(ENG_F_CTX_LOAD_OBJECT, ENG_R_INVALID_PARAMETER);
247245
pthread_mutex_unlock(&ctx->lock);
248246
return NULL;
249247
}
248+
249+
orig_ui_method = ctx->ui_method;
250+
orig_callback_data = ctx->callback_data;
251+
ctx->ui_method = ui_method;
252+
ctx->callback_data = callback_data;
253+
250254
evp_pkey = UTIL_CTX_get_pubkey_from_uri(ctx->util_ctx, s_key_id);
251-
pthread_mutex_unlock(&ctx->lock);
252255

253-
if (orig_ui_method)
254-
ctx->ui_method = orig_ui_method;
255-
if (orig_callback_data)
256-
ctx->callback_data = orig_callback_data;
256+
ctx->ui_method = orig_ui_method;
257+
ctx->callback_data = orig_callback_data;
258+
259+
pthread_mutex_unlock(&ctx->lock);
257260

258261
if (!evp_pkey) {
259262
ENGINE_CTX_log(ctx, LOG_ERR, "PKCS11_get_public_key returned NULL\n");
@@ -267,27 +270,30 @@ EVP_PKEY *ENGINE_CTX_load_pubkey(ENGINE_CTX *ctx, const char *s_key_id,
267270
EVP_PKEY *ENGINE_CTX_load_privkey(ENGINE_CTX *ctx, const char *s_key_id,
268271
UI_METHOD *ui_method, void *callback_data)
269272
{
270-
UI_METHOD *orig_ui_method = ctx->ui_method;
271-
void *orig_callback_data = ctx->callback_data;
273+
UI_METHOD *orig_ui_method;
274+
void *orig_callback_data;
272275
EVP_PKEY *evp_pkey;
273276

274-
ctx->ui_method = ui_method;
275-
ctx->callback_data = callback_data;
276-
277277
pthread_mutex_lock(&ctx->lock);
278+
278279
/* Delayed libp11 initialization */
279280
if (!UTIL_CTX_init_libp11(ctx->util_ctx)) {
280281
ENGerr(ENG_F_CTX_LOAD_OBJECT, ENG_R_INVALID_PARAMETER);
281282
pthread_mutex_unlock(&ctx->lock);
282283
return NULL;
283284
}
285+
286+
orig_ui_method = ctx->ui_method;
287+
orig_callback_data = ctx->callback_data;
288+
ctx->ui_method = ui_method;
289+
ctx->callback_data = callback_data;
290+
284291
evp_pkey = UTIL_CTX_get_privkey_from_uri(ctx->util_ctx, s_key_id);
285-
pthread_mutex_unlock(&ctx->lock);
286292

287-
if (orig_ui_method)
288-
ctx->ui_method = orig_ui_method;
289-
if (orig_callback_data)
290-
ctx->callback_data = orig_callback_data;
293+
ctx->ui_method = orig_ui_method;
294+
ctx->callback_data = orig_callback_data;
295+
296+
pthread_mutex_unlock(&ctx->lock);
291297

292298
if (!evp_pkey) {
293299
ENGINE_CTX_log(ctx, LOG_ERR, "PKCS11_get_private_key returned NULL\n");

0 commit comments

Comments
 (0)