[pkg-opensc-commit] [libp11] 06/67: fixed prev_pin handling
Eric Dorland
eric at moszumanska.debian.org
Sat Jan 30 05:34:09 UTC 2016
This is an automated email from the git hooks/post-receive script.
eric pushed a commit to branch master
in repository libp11.
commit c3830219fc8946380086dc43967f848b8dc39c0b
Author: Michał Trojnara <Michal.Trojnara at mirt.net>
Date: Tue Dec 1 15:09:02 2015 +0100
fixed prev_pin handling
---
src/libp11-int.h | 2 +-
src/p11_slot.c | 17 ++++++++++++++---
2 files changed, 15 insertions(+), 4 deletions(-)
diff --git a/src/libp11-int.h b/src/libp11-int.h
index 503a7f3..973b1bd 100644
--- a/src/libp11-int.h
+++ b/src/libp11-int.h
@@ -66,7 +66,7 @@ typedef struct pkcs11_slot_private {
int prev_rw; /* the rw status the session was open */
/* options used in last PKCS11_login */
- char prev_pin[64];
+ char *prev_pin;
int prev_so;
} PKCS11_SLOT_private;
#define PRIVSLOT(slot) ((PKCS11_SLOT_private *) (slot->_private))
diff --git a/src/p11_slot.c b/src/p11_slot.c
index e433770..7269229 100644
--- a/src/p11_slot.c
+++ b/src/p11_slot.c
@@ -228,8 +228,13 @@ int pkcs11_login(PKCS11_SLOT * slot, int so, const char *pin, int relogin)
CRYPTOKI_checkerr(PKCS11_F_PKCS11_LOGIN, rv);
priv->loggedIn = 1;
- if (priv->prev_pin != pin)
- snprintf(priv->prev_pin, sizeof(priv->prev_pin), "%s", pin);
+ if (priv->prev_pin != pin) {
+ if (priv->prev_pin) {
+ OPENSSL_cleanse(priv->prev_pin, strlen(priv->prev_pin));
+ OPENSSL_free(priv->prev_pin);
+ }
+ priv->prev_pin = BUF_strdup(pin);
+ }
priv->prev_so = so;
return 0;
}
@@ -419,6 +424,9 @@ static int pkcs11_init_slot(PKCS11_CTX * ctx, PKCS11_SLOT * slot, CK_SLOT_ID id)
priv->parent = ctx;
priv->id = id;
priv->forkid = PRIVCTX(ctx)->forkid;
+ priv->prev_rw = 0;
+ priv->prev_pin = NULL;
+ priv->prev_so = 0;
slot->description = PKCS11_DUP(info.slotDescription);
slot->manufacturer = PKCS11_DUP(info.manufacturerID);
@@ -445,7 +453,10 @@ void pkcs11_release_slot(PKCS11_CTX * ctx, PKCS11_SLOT * slot)
PKCS11_SLOT_private *priv = PRIVSLOT(slot);
if (priv) {
- OPENSSL_cleanse(priv->prev_pin, sizeof(priv->prev_pin));
+ if (priv->prev_pin) {
+ OPENSSL_cleanse(priv->prev_pin, strlen(priv->prev_pin));
+ OPENSSL_free(priv->prev_pin);
+ }
CRYPTOKI_call(ctx, C_CloseAllSessions(priv->id));
}
OPENSSL_free(slot->_private);
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-opensc/libp11.git
More information about the pkg-opensc-commit
mailing list