Skip to content

Commit

Permalink
Merge pull request #3634 from FAlbertDev/fix/tls_http_server_segfault
Browse files Browse the repository at this point in the history
Fix: Segfault in tls_http_server
  • Loading branch information
reneme committed Jul 25, 2023
2 parents b61b900 + d22c9e2 commit cff50ed
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/cli/tls_http_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,11 @@ class TLS_Asio_HTTP_Session final : public std::enable_shared_from_this<TLS_Asio
}

void stop() {
if(!m_tls) {
// Server is already closed
return;
}

m_tls->close();

// Need to explicitly destroy the TLS::Server object to break the
Expand Down Expand Up @@ -287,6 +292,10 @@ class TLS_Asio_HTTP_Session final : public std::enable_shared_from_this<TLS_Asio
}

void handle_http_request(const HTTP_Parser::Request& request) override {
if(!m_tls) {
log_error("Received client data after close");
return;
}
std::ostringstream response;
if(request.verb() == "GET") {
if(request.location() == "/" || request.location() == "/status") {
Expand Down Expand Up @@ -382,6 +391,10 @@ class TLS_Asio_HTTP_Session final : public std::enable_shared_from_this<TLS_Asio
}

void tls_alert(Botan::TLS::Alert alert) override {
if(!m_tls) {
log_error("Received client data after close");
return;
}
if(alert.type() == Botan::TLS::Alert::CloseNotify) {
m_tls->close();
} else {
Expand Down

0 comments on commit cff50ed

Please sign in to comment.