mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-01-16 09:57:19 -05:00
pqi free x509 cert even before exit
Avoid risk of introducing memory leak if we change the behaviour code from exit to return in the future
This commit is contained in:
parent
fb9e172898
commit
f9f7e0df18
@ -1151,6 +1151,7 @@ int pqissl::Authorise_SSL_Connection()
|
|||||||
// reset switch.
|
// reset switch.
|
||||||
waiting = WAITING_NOT;
|
waiting = WAITING_NOT;
|
||||||
|
|
||||||
|
#ifdef RS_PQISSL_AUTH_REDUNDANT_CHECK
|
||||||
X509* peercert = SSL_get_peer_certificate(ssl_connection);
|
X509* peercert = SSL_get_peer_certificate(ssl_connection);
|
||||||
if (!peercert)
|
if (!peercert)
|
||||||
{
|
{
|
||||||
@ -1172,11 +1173,11 @@ int pqissl::Authorise_SSL_Connection()
|
|||||||
* If the cert is from a friend anyway we should find a way to make good
|
* If the cert is from a friend anyway we should find a way to make good
|
||||||
* use of this connection instead of throwing it away... */
|
* use of this connection instead of throwing it away... */
|
||||||
|
|
||||||
|
X509_free(peercert);
|
||||||
reset_locked();
|
reset_locked();
|
||||||
return failure;
|
return failure;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef RS_PQISSL_AUTH_REDUNDANT_CHECK
|
|
||||||
/* At this point the actual connection authentication has already been
|
/* At this point the actual connection authentication has already been
|
||||||
* performed in AuthSSL::VerifyX509Callback, any furter authentication check
|
* performed in AuthSSL::VerifyX509Callback, any furter authentication check
|
||||||
* like the following two are redundant. */
|
* like the following two are redundant. */
|
||||||
@ -1188,20 +1189,24 @@ int pqissl::Authorise_SSL_Connection()
|
|||||||
<< "certificate signature. This should never happen at this "
|
<< "certificate signature. This should never happen at this "
|
||||||
<< "point!" << std::endl;
|
<< "point!" << std::endl;
|
||||||
print_stacktrace();
|
print_stacktrace();
|
||||||
|
|
||||||
|
X509_free(peercert); // not needed but just in case we change to return
|
||||||
exit(failure);
|
exit(failure);
|
||||||
}
|
}
|
||||||
|
|
||||||
RsPgpId pgpId = RsX509Cert::getCertIssuer(*peercert);
|
RsPgpId pgpId = RsX509Cert::getCertIssuer(*peercert);
|
||||||
if( !AuthGPG::getAuthGPG()->isGPGAccepted(pgpId) )
|
if( !AuthGPG::getAuthGPG()->isGPGAccepted(pgpId) )
|
||||||
{
|
{
|
||||||
RsErr() << __PRETTY_FUNCTION__ << " pgpId: " << pgpId
|
RsFatal() << __PRETTY_FUNCTION__ << " pgpId: " << pgpId
|
||||||
<< " is not friend. It is very unlikely to happen at this "
|
<< " is not friend. It is very unlikely to happen at this "
|
||||||
<< "point! Either the user must have been so fast to deny "
|
<< "point! Either the user must have been so fast to deny "
|
||||||
<< "friendship just after VerifyX509Callback have returned "
|
<< "friendship just after VerifyX509Callback have returned "
|
||||||
<< "success and just before this code being executed, or "
|
<< "success and just before this code being executed, or "
|
||||||
<< "something really fishy is happening! Share the full log "
|
<< "something really fishy is happening! Share the full log "
|
||||||
<< "with developers." << std::endl;
|
<< "with developers." << std::endl;
|
||||||
print_stacktrace();
|
print_stacktrace();
|
||||||
|
|
||||||
|
X509_free(peercert); // not needed but just in case we change to return
|
||||||
exit(failure);
|
exit(failure);
|
||||||
}
|
}
|
||||||
#endif // def RS_PQISSL_AUTH_REDUNDANT_CHECK
|
#endif // def RS_PQISSL_AUTH_REDUNDANT_CHECK
|
||||||
|
@ -793,19 +793,23 @@ int pqissllistener::completeConnection(int fd, IncomingSSLInfo& info)
|
|||||||
<< "certificate signature. This should never happen at this "
|
<< "certificate signature. This should never happen at this "
|
||||||
<< "point!" << std::endl;
|
<< "point!" << std::endl;
|
||||||
print_stacktrace();
|
print_stacktrace();
|
||||||
|
|
||||||
|
X509_free(peercert); // not needed but just in case we change to return
|
||||||
exit(failure);
|
exit(failure);
|
||||||
}
|
}
|
||||||
|
|
||||||
if( !AuthGPG::getAuthGPG()->isGPGAccepted(pgpId) )
|
if( !AuthGPG::getAuthGPG()->isGPGAccepted(pgpId) )
|
||||||
{
|
{
|
||||||
RsErr() << __PRETTY_FUNCTION__ << " pgpId: " << pgpId
|
RsFatal() << __PRETTY_FUNCTION__ << " pgpId: " << pgpId
|
||||||
<< " is not friend. It is very unlikely to happen at this "
|
<< " is not friend. It is very unlikely to happen at this "
|
||||||
<< "point! Either the user must have been so fast to deny "
|
<< "point! Either the user must have been so fast to deny "
|
||||||
<< "friendship just after VerifyX509Callback have returned "
|
<< "friendship just after VerifyX509Callback have returned "
|
||||||
<< "success and just before this code being executed, or "
|
<< "success and just before this code being executed, or "
|
||||||
<< "something really fishy is happening! Share the full log "
|
<< "something really fishy is happening! Share the full log "
|
||||||
<< "with developers." << std::endl;
|
<< "with developers." << std::endl;
|
||||||
print_stacktrace();
|
print_stacktrace();
|
||||||
|
|
||||||
|
X509_free(peercert); // not needed but just in case we change to return
|
||||||
exit(failure);
|
exit(failure);
|
||||||
}
|
}
|
||||||
#endif //def RS_PQISSL_AUTH_REDUNDANT_CHECK
|
#endif //def RS_PQISSL_AUTH_REDUNDANT_CHECK
|
||||||
|
Loading…
Reference in New Issue
Block a user