Playing with the "openssl pkcs12" command, I got a core-dump.
Wouldn't have happened usually, I suppose, except that I'm having it
linked with E-fence, which is a memory allocation/deallocation debugger.
It complained that openssl was trying to allocate 0 bytes, and raised
a SIGILL, thus generating said core dump.
Looking through the code, I foudn a small bug (incorrect variabel use)
that is fixed with the following patch (I moved "cert" to be inside
the loop where it is used to make sure the compiler would complain if
it was wrongly used somewhere else):
Index: pkcs12.c
===================================================================
RCS file: /src/packages/openssl/repository//openssl/apps/pkcs12.c,v
retrieving revision 1.21
diff -u -r1.21 pkcs12.c
--- pkcs12.c 1999/08/02 21:44:46 1.21
+++ pkcs12.c 1999/10/05 07:34:36
@@ -281,13 +281,13 @@
}
}
-if (export_cert) {
+ if (export_cert) {
EVP_PKEY *key;
STACK *bags, *safes;
PKCS12_SAFEBAG *bag;
PKCS8_PRIV_KEY_INFO *p8;
PKCS7 *authsafe;
- X509 *cert = NULL, *ucert = NULL;
+ X509 *ucert = NULL;
STACK_OF(X509) *certs;
char *catmp;
int i;
@@ -313,7 +313,7 @@
for(i = 0; i < sk_X509_num(certs); i++) {
ucert = sk_X509_value(certs, i);
if(X509_check_private_key(ucert, key)) {
- X509_digest(cert, EVP_sha1(), keyid, &keyidlen);
+ X509_digest(ucert, EVP_sha1(), keyid, &keyidlen);
break;
}
}
@@ -354,6 +354,7 @@
/* We now have loads of certificates: include them all */
for(i = 0; i < sk_X509_num(certs); i++) {
+ X509 *cert = NULL;
cert = sk_X509_value(certs, i);
bag = M_PKCS12_x5092certbag(cert);
/* If it matches private key set id */
--
Richard Levitte \ Spannv�gen 38, II \ [EMAIL PROTECTED]
Redakteur@Stacken \ S-161 43 BROMMA \ T: +46-8-26 52 47
\ SWEDEN \ or +46-708-26 53 44
Procurator Odiosus Ex Infernis -- [EMAIL PROTECTED]
Unsolicited commercial email is subject to an archival fee of $400.
See <http://www.stacken.kth.se/~levitte/mail/> for more info.
______________________________________________________________________
OpenSSL Project http://www.openssl.org
Development Mailing List [EMAIL PROTECTED]
Automated List Manager [EMAIL PROTECTED]