Apply by doing: cd /usr/src patch -p0 < 020_asn1.patch And then rebuild and install OpenSSL: cd lib/libssl make obj make depend make make install Index: lib/libssl/src/crypto/asn1/asn1_lib.c =================================================================== RCS file: /cvs/src/lib/libssl/src/crypto/asn1/asn1_lib.c,v retrieving revision 1.10 diff -u -r1.10 asn1_lib.c --- lib/libssl/src/crypto/asn1/asn1_lib.c 10 Sep 2002 16:31:54 -0000 1.10 +++ lib/libssl/src/crypto/asn1/asn1_lib.c 3 Oct 2003 22:20:24 -0000 @@ -104,10 +104,12 @@ l<<=7L; l|= *(p++)&0x7f; if (--max == 0) goto err; + if (l > (INT_MAX >> 7L)) goto err; } l<<=7L; l|= *(p++)&0x7f; tag=(int)l; + if (--max == 0) goto err; } else { Index: lib/libssl/src/crypto/asn1/tasn_dec.c =================================================================== RCS file: /cvs/src/lib/libssl/src/crypto/asn1/tasn_dec.c,v retrieving revision 1.2 diff -u -r1.2 tasn_dec.c --- lib/libssl/src/crypto/asn1/tasn_dec.c 14 Sep 2002 11:18:02 -0000 1.2 +++ lib/libssl/src/crypto/asn1/tasn_dec.c 3 Oct 2003 22:20:24 -0000 @@ -691,6 +691,7 @@ int asn1_ex_c2i(ASN1_VALUE **pval, unsigned char *cont, int len, int utype, char *free_cont, const ASN1_ITEM *it) { + ASN1_VALUE **opval = NULL; ASN1_STRING *stmp; ASN1_TYPE *typ = NULL; int ret = 0; @@ -705,6 +706,7 @@ *pval = (ASN1_VALUE *)typ; } else typ = (ASN1_TYPE *)*pval; if(utype != typ->type) ASN1_TYPE_set(typ, utype, NULL); + opval = pval; pval = (ASN1_VALUE **)&typ->value.ptr; } switch(utype) { @@ -796,7 +798,12 @@ ret = 1; err: - if(!ret) ASN1_TYPE_free(typ); + if(!ret) + { + ASN1_TYPE_free(typ); + if (opval) + *opval = NULL; + } return ret; } Index: lib/libssl/src/crypto/x509/x509_vfy.c =================================================================== RCS file: /cvs/src/lib/libssl/src/crypto/x509/x509_vfy.c,v retrieving revision 1.6 diff -u -r1.6 x509_vfy.c --- lib/libssl/src/crypto/x509/x509_vfy.c 15 May 2002 02:29:17 -0000 1.6 +++ lib/libssl/src/crypto/x509/x509_vfy.c 3 Oct 2003 22:20:24 -0000 @@ -674,7 +674,7 @@ ok=(*cb)(0,ctx); if (!ok) goto end; } - if (X509_verify(xs,pkey) <= 0) + else if (X509_verify(xs,pkey) <= 0) /* XXX For the final trusted self-signed cert, * this is a waste of time. That check should * optional so that e.g. 'openssl x509' can be Index: lib/libssl/src/ssl/s3_clnt.c =================================================================== RCS file: /cvs/src/lib/libssl/src/ssl/s3_clnt.c,v retrieving revision 1.12 diff -u -r1.12 s3_clnt.c --- lib/libssl/src/ssl/s3_clnt.c 23 Sep 2002 21:32:28 -0000 1.12 +++ lib/libssl/src/ssl/s3_clnt.c 3 Oct 2003 22:20:24 -0000 @@ -1752,6 +1752,7 @@ *(d++)=SSL3_MT_CERTIFICATE_VERIFY; l2n3(n,d); + s->state=SSL3_ST_CW_CERT_VRFY_B; s->init_num=(int)n+4; s->init_off=0; } Index: lib/libssl/src/ssl/s3_srvr.c =================================================================== RCS file: /cvs/src/lib/libssl/src/ssl/s3_srvr.c,v retrieving revision 1.14.2.1 diff -u -r1.14.2.1 s3_srvr.c --- lib/libssl/src/ssl/s3_srvr.c 19 Mar 2003 23:39:12 -0000 1.14.2.1 +++ lib/libssl/src/ssl/s3_srvr.c 3 Oct 2003 22:20:24 -0000 @@ -425,10 +425,11 @@ if (ret == 2) s->state = SSL3_ST_SR_CLNT_HELLO_C; else { - /* could be sent for a DH cert, even if we - * have not asked for it :-) */ - ret=ssl3_get_client_certificate(s); - if (ret <= 0) goto end; + if (s->s3->tmp.cert_request) + { + ret=ssl3_get_client_certificate(s); + if (ret <= 0) goto end; + } s->init_num=0; s->state=SSL3_ST_SR_KEY_EXCH_A; } @@ -838,6 +839,9 @@ } /* TLS does not mind if there is extra stuff */ +#if 0 /* SSL 3.0 does not mind either, so we should disable this test + * (was enabled in 0.9.6d through 0.9.6j and 0.9.7 through 0.9.7b, + * in earlier SSLeay/OpenSSL releases this test existed but was buggy) */ if (s->version == SSL3_VERSION) { if (p < (d+n)) @@ -849,6 +853,7 @@ goto f_err; } } +#endif /* Given s->session->ciphers and SSL_get_ciphers, we must * pick a cipher */ @@ -1346,6 +1351,7 @@ s->init_num += 4; #endif + s->state = SSL3_ST_SW_CERT_REQ_B; } /* SSL3_ST_SW_CERT_REQ_B */