LibTLS: Clear connected/error callbacks before leaving connect()

Otherwise error events will call into our setup code, eventually leading
to a UAF.
This commit is contained in:
Ali Mohammad Pur 2024-05-16 21:46:32 +02:00 committed by Andreas Kling
parent a362c37c8b
commit 06d522f017
Notes: sideshowbarker 2024-07-18 22:57:59 +09:00

View File

@ -66,6 +66,9 @@ ErrorOr<NonnullOwnPtr<TLSv12>> TLSv12::connect(ByteString const& host, u16 port,
};
TRY(promise->await());
tls_socket->on_tls_error = nullptr;
tls_socket->on_connected = nullptr;
tls_socket->m_context.should_expect_successful_read = true;
return tls_socket;
}
@ -84,6 +87,9 @@ ErrorOr<NonnullOwnPtr<TLSv12>> TLSv12::connect(ByteString const& host, Core::Soc
promise->reject(AK::Error::from_string_view(enum_to_string(alert)));
};
TRY(promise->await());
tls_socket->on_tls_error = nullptr;
tls_socket->on_connected = nullptr;
tls_socket->m_context.should_expect_successful_read = true;
return tls_socket;
}