Skip to content

Commit

Permalink
fix leak in early data (apache#6957)
Browse files Browse the repository at this point in the history
  • Loading branch information
duke8253 committed Jul 13, 2020
1 parent 5926385 commit 744e02e
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions iocore/net/SSLUtils.cc
Expand Up @@ -1833,10 +1833,6 @@ SSLAccept(SSL *ssl)

if (SSLConfigParams::server_max_early_data > 0 && !netvc->early_data_finish) {
size_t nread;
if (netvc->early_data_buf == nullptr) {
netvc->early_data_buf = new_MIOBuffer(BUFFER_SIZE_INDEX_16K);
netvc->early_data_reader = netvc->early_data_buf->alloc_reader();
}

while (true) {
IOBufferBlock *block = new_IOBufferBlock();
Expand All @@ -1845,9 +1841,14 @@ SSLAccept(SSL *ssl)

if (ret == SSL_READ_EARLY_DATA_ERROR) {
Debug("ssl_early_data", "SSL_READ_EARLY_DATA_ERROR");
block->free();
break;
} else {
if (nread > 0) {
if (netvc->early_data_buf == nullptr) {
netvc->early_data_buf = new_MIOBuffer(BUFFER_SIZE_INDEX_16K);
netvc->early_data_reader = netvc->early_data_buf->alloc_reader();
}
block->fill(nread);
netvc->early_data_buf->append_block(block);
SSL_INCREMENT_DYN_STAT(ssl_early_data_received_count);
Expand All @@ -1856,13 +1857,15 @@ SSLAccept(SSL *ssl)
std::string early_data_str(reinterpret_cast<char *>(block->buf()), nread);
Debug("ssl_early_data_show_received", "Early data buffer: \n%s", early_data_str.c_str());
}
} else {
block->free();
}

if (ret == SSL_READ_EARLY_DATA_FINISH) {
netvc->early_data_finish = true;
Debug("ssl_early_data", "SSL_READ_EARLY_DATA_FINISH: size = %lu", nread);

if (netvc->early_data_reader->read_avail() == 0) {
if (netvc->early_data_reader == nullptr || netvc->early_data_reader->read_avail() == 0) {
Debug("ssl_early_data", "no data in early data buffer");
ERR_clear_error();
ret = SSL_accept(ssl);
Expand Down

0 comments on commit 744e02e

Please sign in to comment.