Commit df9360f4 authored by Kyle Nekritz's avatar Kyle Nekritz Committed by facebook-github-bot-1

Fix segfaults in AsyncSSLSocket when used in unencrypted mode.

Reviewed By: djwatson

Differential Revision: D2720027

fb-gh-sync-id: 1d56aabedeaf65a5d48e152eaee5c81695be7620
parent 0dbbe856
......@@ -412,6 +412,9 @@ std::string AsyncSSLSocket::getApplicationProtocol() noexcept {
}
bool AsyncSSLSocket::isEorTrackingEnabled() const {
if (ssl_ == nullptr) {
return false;
}
const BIO *wb = SSL_get_wbio(ssl_);
return wb && wb->method == &eorAwareBioMethod;
}
......@@ -1094,7 +1097,8 @@ AsyncSSLSocket::handleConnect() noexcept {
void AsyncSSLSocket::setReadCB(ReadCallback *callback) {
#ifdef SSL_MODE_MOVE_BUFFER_OWNERSHIP
// turn on the buffer movable in openssl
if (!isBufferMovable_ && callback != nullptr && callback->isBufferMovable()) {
if (ssl_ != nullptr && !isBufferMovable_ &&
callback != nullptr && callback->isBufferMovable()) {
SSL_set_mode(ssl_, SSL_get_mode(ssl_) | SSL_MODE_MOVE_BUFFER_OWNERSHIP);
isBufferMovable_ = true;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment