]> git.sur5r.net Git - openldap/commitdiff
ITS#6980 free the result of SSL_PeerCertificate
authorRich Megginson <rmeggins@redhat.com>
Wed, 29 Jun 2011 16:47:10 +0000 (10:47 -0600)
committerHoward Chu <hyc@openldap.org>
Wed, 29 Jun 2011 23:56:26 +0000 (16:56 -0700)
In tlsm_auth_cert_handler, we get the peer's cert from the socket using
SSL_PeerCertificate.  This value is allocated and/or cached.  We must
destroy it using CERT_DestroyCertificate.

libraries/libldap/tls_m.c

index 224b571842848ffff49f10dc60de43ebc823de21..32af7ec7c0a87d4613b9018d830fa8bfa90e0f4d 100644 (file)
@@ -1030,10 +1030,12 @@ tlsm_auth_cert_handler(void *arg, PRFileDesc *fd,
 {
        SECCertificateUsage certUsage = isServer ? certificateUsageSSLClient : certificateUsageSSLServer;
        SECStatus ret = SECSuccess;
+       CERTCertificate *peercert = SSL_PeerCertificate( fd );
 
-       ret = tlsm_verify_cert( (CERTCertDBHandle *)arg, SSL_PeerCertificate( fd ),
+       ret = tlsm_verify_cert( (CERTCertDBHandle *)arg, peercert,
                                                        SSL_RevealPinArg( fd ),
                                                        checksig, certUsage, 0 );
+       CERT_DestroyCertificate( peercert );
 
        return ret;
 }