Fix double-free crash in BSecureSocket when cert. verification fails
* BSecureSocket::CertificateVerificationFailed() took a BCertificate instance by value as parameter. BCertificate deletes internal data in its destructor. Passing an object by value creates a copy, so the copy attempted to delete the internal data again during its destruction. This caused mail_daemon to crash here when it came across a failed certificate. * Fix: pass BCertificate object as reference.
This commit is contained in:
@@ -20,7 +20,7 @@ public:
|
||||
BSecureSocket(const BSecureSocket& other);
|
||||
virtual ~BSecureSocket();
|
||||
|
||||
virtual bool CertificateVerificationFailed(BCertificate);
|
||||
virtual bool CertificateVerificationFailed(BCertificate&);
|
||||
|
||||
// BSocket implementation
|
||||
|
||||
|
||||
@@ -154,7 +154,8 @@ BSecureSocket::Private::VerifyCallback(int ok, X509_STORE_CTX* ctx)
|
||||
return 0;
|
||||
|
||||
// Let the BSecureSocket (or subclass) decide if we should continue anyway.
|
||||
return socket->CertificateVerificationFailed(BCertificate(certificate));
|
||||
BCertificate failedCertificate(certificate);
|
||||
return socket->CertificateVerificationFailed(failedCertificate);
|
||||
}
|
||||
|
||||
|
||||
@@ -285,7 +286,7 @@ BSecureSocket::WaitForReadable(bigtime_t timeout) const
|
||||
|
||||
|
||||
bool
|
||||
BSecureSocket::CertificateVerificationFailed(BCertificate)
|
||||
BSecureSocket::CertificateVerificationFailed(BCertificate&)
|
||||
{
|
||||
// Until apps actually make use of the certificate API, let's keep the old
|
||||
// behavior and accept all connections, even if the certificate validation
|
||||
@@ -357,7 +358,7 @@ BSecureSocket::~BSecureSocket()
|
||||
|
||||
|
||||
bool
|
||||
BSecureSocket::CertificateVerificationFailed(BCertificate)
|
||||
BSecureSocket::CertificateVerificationFailed(BCertificate&)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user