diff options
author | Michiel Visser <opensource@webmichiel.nl> | 2022-02-18 15:58:27 +0100 |
---|---|---|
committer | Ali Mohammad Pur <Ali.mpfard@gmail.com> | 2022-02-23 13:20:28 +0330 |
commit | ab84aa6fb28c9019ba79da74cf805ed506381b0f (patch) | |
tree | a6e01efce24e42051221f6d4aa3fa4b79335afce | |
parent | 610b380515624013e42b7ba3a73e7e15440d1d5c (diff) | |
download | serenity-ab84aa6fb28c9019ba79da74cf805ed506381b0f.zip |
LibTLS: Add OutOfMemory error that will send an InternalError alert
-rw-r--r-- | Userland/Libraries/LibTLS/Handshake.cpp | 3 | ||||
-rw-r--r-- | Userland/Libraries/LibTLS/HandshakeServer.cpp | 11 | ||||
-rw-r--r-- | Userland/Libraries/LibTLS/TLSv12.h | 1 |
3 files changed, 8 insertions, 7 deletions
diff --git a/Userland/Libraries/LibTLS/Handshake.cpp b/Userland/Libraries/LibTLS/Handshake.cpp index ee3e708081..51fab9ddee 100644 --- a/Userland/Libraries/LibTLS/Handshake.cpp +++ b/Userland/Libraries/LibTLS/Handshake.cpp @@ -473,7 +473,8 @@ ssize_t TLSv12::handle_handshake_payload(ReadonlyBytes vbuffer) write_packet(packet); break; } - case Error::NotUnderstood: { + case Error::NotUnderstood: + case Error::OutOfMemory: { auto packet = build_alert(true, (u8)AlertDescription::InternalError); write_packet(packet); break; diff --git a/Userland/Libraries/LibTLS/HandshakeServer.cpp b/Userland/Libraries/LibTLS/HandshakeServer.cpp index c2cb8ec27f..fc41241082 100644 --- a/Userland/Libraries/LibTLS/HandshakeServer.cpp +++ b/Userland/Libraries/LibTLS/HandshakeServer.cpp @@ -225,8 +225,7 @@ ssize_t TLSv12::handle_server_key_exchange(ReadonlyBytes buffer) TODO(); break; case KeyExchangeAlgorithm::DHE_RSA: - handle_dhe_rsa_server_key_exchange(buffer); - break; + return handle_dhe_rsa_server_key_exchange(buffer); case KeyExchangeAlgorithm::DH_anon: dbgln("Server key exchange for DH_anon is not implemented"); TODO(); @@ -255,7 +254,7 @@ ssize_t TLSv12::handle_dhe_rsa_server_key_exchange(ReadonlyBytes buffer) auto p_result = ByteBuffer::copy(dh_p); if (p_result.is_error()) { dbgln("dhe_rsa_server_key_exchange failed: Not enough memory"); - return 0; + return (i8)Error::OutOfMemory; } m_context.server_diffie_hellman_params.p = p_result.release_value(); @@ -264,7 +263,7 @@ ssize_t TLSv12::handle_dhe_rsa_server_key_exchange(ReadonlyBytes buffer) auto g_result = ByteBuffer::copy(dh_g); if (g_result.is_error()) { dbgln("dhe_rsa_server_key_exchange failed: Not enough memory"); - return 0; + return (i8)Error::OutOfMemory; } m_context.server_diffie_hellman_params.g = g_result.release_value(); @@ -273,7 +272,7 @@ ssize_t TLSv12::handle_dhe_rsa_server_key_exchange(ReadonlyBytes buffer) auto Ys_result = ByteBuffer::copy(dh_Ys); if (Ys_result.is_error()) { dbgln("dhe_rsa_server_key_exchange failed: Not enough memory"); - return 0; + return (i8)Error::OutOfMemory; } m_context.server_diffie_hellman_params.Ys = Ys_result.release_value(); @@ -310,7 +309,7 @@ ssize_t TLSv12::handle_ecdhe_rsa_server_key_exchange(ReadonlyBytes buffer) auto server_public_key_copy_result = ByteBuffer::copy(server_public_key); if (server_public_key_copy_result.is_error()) { dbgln("ecdhe_rsa_server_key_exchange failed: Not enough memory"); - return 0; + return (i8)Error::OutOfMemory; } m_context.server_diffie_hellman_params.p = server_public_key_copy_result.release_value(); diff --git a/Userland/Libraries/LibTLS/TLSv12.h b/Userland/Libraries/LibTLS/TLSv12.h index 6727794191..757b735742 100644 --- a/Userland/Libraries/LibTLS/TLSv12.h +++ b/Userland/Libraries/LibTLS/TLSv12.h @@ -109,6 +109,7 @@ enum class Error : i8 { DecryptionFailed = -20, NeedMoreData = -21, TimedOut = -22, + OutOfMemory = -23, }; enum class AlertLevel : u8 { |