diff --git a/src/libopensc/pkcs15-cert.c b/src/libopensc/pkcs15-cert.c index cf722bb3..2e34e471 100644 --- a/src/libopensc/pkcs15-cert.c +++ b/src/libopensc/pkcs15-cert.c @@ -143,7 +143,6 @@ int sc_pkcs15_read_certificate(struct sc_pkcs15_card *p15card, free(data); return r; } - len = len; sc_unlock(p15card->card); } cert = malloc(sizeof(struct sc_pkcs15_cert)); diff --git a/src/scam/p15_eid.c b/src/scam/p15_eid.c index 365b2c92..6a7ca569 100644 --- a/src/scam/p15_eid.c +++ b/src/scam/p15_eid.c @@ -284,7 +284,7 @@ static int get_certificate(const char *user, X509 ** cert_out) goto end; *cert_out = cert; err = SCAM_SUCCESS; - end: +end: if (in) BIO_free(in); if (dir) @@ -297,7 +297,6 @@ static int get_certificate(const char *user, X509 ** cert_out) int p15_eid_auth(int argc, const char **argv, const char *user, const char *password) { - struct sc_pkcs15_cert *p15cert = NULL; u8 random_data[20], chg[256], txt[256]; int r, err = SCAM_FAILED, chglen; EVP_PKEY *pubkey = NULL; @@ -349,13 +348,11 @@ int p15_eid_auth(int argc, const char **argv, if (r == sizeof(random_data) && !memcmp(txt, random_data, r)) { err = SCAM_SUCCESS; } - end: +end: if (pubkey) EVP_PKEY_free(pubkey); if (cert) X509_free(cert); - if (p15cert) - sc_pkcs15_free_certificate(p15cert); return err; } diff --git a/src/scam/p15_ldap.c b/src/scam/p15_ldap.c index 8db7c629..96b4cd36 100644 --- a/src/scam/p15_ldap.c +++ b/src/scam/p15_ldap.c @@ -234,6 +234,7 @@ int p15_ldap_auth(int argc, const char **argv, int r, err = SCAM_FAILED, chglen; EVP_PKEY *pubkey = NULL; X509 *cert = NULL; + unsigned char *ptr = NULL; if (!lctx || !ctx) return SCAM_FAILED; @@ -243,7 +244,8 @@ int p15_ldap_auth(int argc, const char **argv, goto end; } cert = X509_new(); - if (!d2i_X509(&cert, &p15cert->data, p15cert->data_len)) { + ptr = p15cert->data; + if (!d2i_X509(&cert, &ptr, p15cert->data_len)) { scam_fw_p15_ldap.logmsg("Invalid certificate. (user %s)\n", user); goto end; } @@ -281,7 +283,7 @@ int p15_ldap_auth(int argc, const char **argv, if (r == sizeof(random_data) && !memcmp(txt, random_data, r)) { err = SCAM_SUCCESS; } - end: +end: if (pubkey) EVP_PKEY_free(pubkey); if (cert)