[pkg-opensc-commit] [engine-pkcs11] 140/152: Use user interface correctly
Eric Dorland
eric at moszumanska.debian.org
Mon Oct 19 03:11:26 UTC 2015
This is an automated email from the git hooks/post-receive script.
eric pushed a commit to branch master
in repository engine-pkcs11.
commit 37ae31845360e14b3401e93129a02acee1d9f015
Author: Petr Písař <petr.pisar at atlas.cz>
Date: Mon Aug 19 20:17:40 2013 +0200
Use user interface correctly
Call-back data passed by the OpenSSL from an application are application
specific data opaque to an engine.
Previous engine_pkcs11 code tried to use the call-back data which could
result in crash. This patch fixes it.
---
src/engine_pkcs11.c | 31 +++++++++++--------------------
1 file changed, 11 insertions(+), 20 deletions(-)
diff --git a/src/engine_pkcs11.c b/src/engine_pkcs11.c
index dfb500a..9e13a0c 100644
--- a/src/engine_pkcs11.c
+++ b/src/engine_pkcs11.c
@@ -116,34 +116,24 @@ int inc_verbose(void)
return 1;
}
-/* either get the pin code from the supplied callback data, or get the pin
- * via asking our self. In both cases keep a copy of the pin code in the
- * pin variable (strdup'ed copy). */
+/* Get the PIN via asking user interface. The supplied call-back data are
+ * passed to the user interface implemented by an application. Only the
+ * application knows how to interpret the call-back data.
+ * A (strdup'ed) copy of the PIN code will be stored in the pin variable. */
static int get_pin(UI_METHOD * ui_method, void *callback_data)
{
UI *ui;
- struct {
- const void *password;
- const char *prompt_info;
- } *mycb = callback_data;
-
- /* pin in the call back data, copy and use */
- if (mycb != NULL && mycb->password) {
- zero_pin();
- pin = (char *)calloc(MAX_PIN_LENGTH, sizeof(char));
- if (!pin)
- return 0;
- strncpy(pin,mycb->password,MAX_PIN_LENGTH);
- pin_length = MAX_PIN_LENGTH;
- return 1;
- }
/* call ui to ask for a pin */
ui = UI_new();
+ if (ui == NULL) {
+ fprintf(stderr, "UI_new failed\n");
+ return 0;
+ }
if (ui_method != NULL)
UI_set_method(ui, ui_method);
if (callback_data != NULL)
- UI_set_app_data(ui, callback_data);
+ UI_add_user_data(ui, callback_data);
zero_pin();
pin = (char *)calloc(MAX_PIN_LENGTH, sizeof(char));
@@ -151,7 +141,8 @@ static int get_pin(UI_METHOD * ui_method, void *callback_data)
return 0;
pin_length = MAX_PIN_LENGTH;
if (!UI_add_input_string
- (ui, "PKCS#11 token PIN: ", 0, pin, 1, MAX_PIN_LENGTH)) {
+ (ui, "PKCS#11 token PIN: ", UI_INPUT_FLAG_DEFAULT_PWD,
+ pin, 1, MAX_PIN_LENGTH)) {
fprintf(stderr, "UI_add_input_string failed\n");
UI_free(ui);
return 0;
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-opensc/engine-pkcs11.git
More information about the pkg-opensc-commit
mailing list