pesign/0019-get_password_passthrough-handle-the-callback-context.patch
Robbie Harwood bb3aaa1ba2 Roll up to pjones's smartcard/cms fixes
Signed-off-by: Robbie Harwood <rharwood@redhat.com>
2022-08-31 21:06:34 +00:00

52 lines
1.4 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Peter Jones <pjones@redhat.com>
Date: Mon, 29 Aug 2022 14:21:44 -0400
Subject: [PATCH] get_password_passthrough(): handle the callback context right
Right now, we have a few callback functions for PK11_Authenticate(), and
they take different arguments. This is incorrect; none of the callers
ever pass anything through except our CMS context.
This fixes get_password_passthrough() to correctly accept the CMS
context and get the passthrough data from cms->pwdata instead of trying
to treat the CMS context as the pwdata.
Related: rhbz#2122777
Signed-off-by: Peter Jones <pjones@redhat.com>
---
src/password.c | 16 +++++++++++++---
1 file changed, 13 insertions(+), 3 deletions(-)
diff --git a/src/password.c b/src/password.c
index 18c32ed..8eb1c33 100644
--- a/src/password.c
+++ b/src/password.c
@@ -365,13 +365,23 @@ err:
}
char *
-get_password_passthrough(PK11SlotInfo *slot UNUSED,
- PRBool retry, void *arg)
+get_password_passthrough(PK11SlotInfo *slot UNUSED, PRBool retry, void *arg)
{
+ cms_context *cms;
+ secuPWData *pwdata;
+
+ dbgprintf("ctx:%p", arg);
+
if (retry || !arg)
return NULL;
- char *ret = strdup(arg);
+ cms = (cms_context *)arg;
+ pwdata = &cms->pwdata;
+
+ if (pwdata->source != PW_PLAINTEXT)
+ return NULL;
+
+ char *ret = strdup(pwdata->data);
if (!ret)
err(1, "Could not allocate memory");