sc-hsm: Prevent double-free crash if key generation fails

(upstream git commit 5279bfa2d14d2186b31189748bcf89d908f00512)
This commit is contained in:
dcoppa 2014-10-24 13:44:00 +00:00
parent 92a8ad64e0
commit f37db76fa1
2 changed files with 48 additions and 2 deletions

View File

@ -1,11 +1,11 @@
# $OpenBSD: Makefile,v 1.25 2014/08/13 11:22:39 dcoppa Exp $
# $OpenBSD: Makefile,v 1.26 2014/10/24 13:44:00 dcoppa Exp $
SHARED_ONLY= Yes
COMMENT= set of libraries and utilities to access smart cards
DISTNAME= opensc-0.14.0
REVISION= 0
REVISION= 1
CATEGORIES= security
SHARED_LIBS += opensc 3.0 # 3.0

View File

@ -0,0 +1,46 @@
$OpenBSD: patch-src_libopensc_pkcs15-sc-hsm_c,v 1.1 2014/10/24 13:44:00 dcoppa Exp $
commit 5279bfa2d14d2186b31189748bcf89d908f00512
Author: Andreas Schwier <andreas.schwier@cardcontact.de>
Date: Wed Jul 9 14:22:51 2014 +0200
sc-hsm: Prevent double-free crash if key generation fails
--- src/libopensc/pkcs15-sc-hsm.c.orig Mon Jun 30 20:37:44 2014
+++ src/libopensc/pkcs15-sc-hsm.c Fri Oct 24 15:31:26 2014
@@ -421,27 +421,35 @@ void sc_pkcs15emu_sc_hsm_free_cvc(sc_cvc_t *cvc)
{
if (cvc->signature) {
free(cvc->signature);
+ cvc->signature = NULL;
}
if (cvc->primeOrModulus) {
free(cvc->primeOrModulus);
+ cvc->primeOrModulus = NULL;
}
if (cvc->coefficientAorExponent) {
free(cvc->coefficientAorExponent);
+ cvc->coefficientAorExponent = NULL;
}
if (cvc->coefficientB) {
free(cvc->coefficientB);
+ cvc->coefficientB = NULL;
}
if (cvc->basePointG) {
free(cvc->basePointG);
+ cvc->basePointG = NULL;
}
if (cvc->order) {
free(cvc->order);
+ cvc->order = NULL;
}
if (cvc->publicPoint) {
free(cvc->publicPoint);
+ cvc->publicPoint = NULL;
}
if (cvc->cofactor) {
free(cvc->cofactor);
+ cvc->cofactor = NULL;
}
}