Skip to content

Commit

Permalink
Plugged another memory leak
Browse files Browse the repository at this point in the history
  • Loading branch information
mtrojnar committed Jan 10, 2016
1 parent afc8693 commit 39c15d8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
7 changes: 5 additions & 2 deletions src/p11_rsa.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,12 @@ static RSA *pkcs11_get_rsa(PKCS11_KEY * key)
RSA_free(rsa);
return NULL;
}

if(!BN_is_zero(rsa->e)) /* The public exponent was retrieved */
return rsa;
BN_clear_free(rsa->e);
/* In case someone modifies this function to execute RSA_free()
* before a valid BN value is assigned to rsa->e */
rsa->e = NULL;

/* The public exponent was not found in the private key:
* retrieve it from the corresponding public key */
Expand Down Expand Up @@ -235,7 +238,7 @@ RSA_METHOD *PKCS11_get_rsa_method(void)
/* This function is *not* currently exported */
void PKCS11_rsa_method_free(void)
{
free_rsa_ex_index();
free_rsa_ex_index();
}

PKCS11_KEY_ops pkcs11_rsa_ops = {
Expand Down
2 changes: 1 addition & 1 deletion src/p11_slot.c
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ int pkcs11_login(PKCS11_SLOT * slot, int so, const char *pin, int relogin)
rv = CRYPTOKI_call(ctx,
C_Login(priv->session, so ? CKU_SO : CKU_USER,
(CK_UTF8CHAR *) pin, pin ? strlen(pin) : 0));
if (rv && rv != CKR_USER_ALREADY_LOGGED_IN) /* logged in -> OK */
if (rv && rv != CKR_USER_ALREADY_LOGGED_IN) /* logged in -> OK */
CRYPTOKI_checkerr(PKCS11_F_PKCS11_LOGIN, rv);
priv->loggedIn = 1;

Expand Down

0 comments on commit 39c15d8

Please sign in to comment.