diff options
author | Andreas Kling <kling@serenityos.org> | 2020-12-19 18:19:15 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-12-19 18:29:13 +0100 |
commit | b30acdb4b7ba34e5a1908f006acc03c3653fd229 (patch) | |
tree | 0869aa844f861e2017ada0f4a3cf01321c595347 | |
parent | d5600e966a4d09d4c12a91f76c3cd19493f34eef (diff) | |
download | serenity-b30acdb4b7ba34e5a1908f006acc03c3653fd229.zip |
LibTLS+Userland: Remove all uses of ByteBuffer::slice_view()
This was another way to get a non-owning ByteBuffer wrapper.
-rw-r--r-- | Libraries/LibTLS/Record.cpp | 4 | ||||
-rw-r--r-- | Libraries/LibTLS/TLSv12.cpp | 2 | ||||
-rw-r--r-- | Userland/Tests/LibC/snprintf-correctness.cpp | 18 | ||||
-rw-r--r-- | Userland/Tests/LibC/strlcpy-correctness.cpp | 18 |
4 files changed, 21 insertions, 21 deletions
diff --git a/Libraries/LibTLS/Record.cpp b/Libraries/LibTLS/Record.cpp index 8f8b71c575..fe306949ec 100644 --- a/Libraries/LibTLS/Record.cpp +++ b/Libraries/LibTLS/Record.cpp @@ -65,7 +65,7 @@ void TLSv12::update_packet(ByteBuffer& packet) if (packet[0] == (u8)MessageType::Handshake && packet.size() > header_size) { u8 handshake_type = packet[header_size]; if (handshake_type != HandshakeType::HelloRequest && handshake_type != HandshakeType::HelloVerifyRequest) { - update_hash(packet.slice_view(header_size, packet.size() - header_size)); + update_hash(packet.bytes().slice(header_size, packet.size() - header_size)); } } if (m_context.cipher_spec_set && m_context.crypto.created) { @@ -272,7 +272,7 @@ ssize_t TLSv12::handle_message(ReadonlyBytes buffer) if (m_context.cipher_spec_set && type != MessageType::ChangeCipher) { #ifdef TLS_DEBUG dbg() << "Encrypted: "; - print_buffer(buffer.slice_view(header_size, length)); + print_buffer(buffer.slice(header_size, length)); #endif if (is_aead()) { diff --git a/Libraries/LibTLS/TLSv12.cpp b/Libraries/LibTLS/TLSv12.cpp index 0101148af8..4a0fe20440 100644 --- a/Libraries/LibTLS/TLSv12.cpp +++ b/Libraries/LibTLS/TLSv12.cpp @@ -579,7 +579,7 @@ void TLSv12::consume(ReadonlyBytes record) #endif break; } - auto consumed = handle_message(m_context.message_buffer.slice_view(index, length)); + auto consumed = handle_message(m_context.message_buffer.bytes().slice(index, length)); #ifdef TLS_DEBUG if (consumed > 0) diff --git a/Userland/Tests/LibC/snprintf-correctness.cpp b/Userland/Tests/LibC/snprintf-correctness.cpp index 4a29d0ff81..9f9b43c49d 100644 --- a/Userland/Tests/LibC/snprintf-correctness.cpp +++ b/Userland/Tests/LibC/snprintf-correctness.cpp @@ -85,9 +85,9 @@ static bool test_single(const Testcase& testcase) // Checking the results: bool return_ok = actual_return == testcase.expected_return; - bool canary_1_ok = actual.slice_view(0, SANDBOX_CANARY_SIZE) == expected.slice_view(0, SANDBOX_CANARY_SIZE); - bool main_ok = actual.slice_view(SANDBOX_CANARY_SIZE, testcase.dest_n) == expected.slice_view(SANDBOX_CANARY_SIZE, testcase.dest_n); - bool canary_2_ok = actual.slice_view(SANDBOX_CANARY_SIZE + testcase.dest_n, SANDBOX_CANARY_SIZE) == expected.slice_view(SANDBOX_CANARY_SIZE + testcase.dest_n, SANDBOX_CANARY_SIZE); + bool canary_1_ok = actual.slice(0, SANDBOX_CANARY_SIZE) == expected.slice(0, SANDBOX_CANARY_SIZE); + bool main_ok = actual.slice(SANDBOX_CANARY_SIZE, testcase.dest_n) == expected.slice(SANDBOX_CANARY_SIZE, testcase.dest_n); + bool canary_2_ok = actual.slice(SANDBOX_CANARY_SIZE + testcase.dest_n, SANDBOX_CANARY_SIZE) == expected.slice(SANDBOX_CANARY_SIZE + testcase.dest_n, SANDBOX_CANARY_SIZE); bool buf_ok = actual == expected; // Evaluate gravity: @@ -98,20 +98,20 @@ static bool test_single(const Testcase& testcase) if (!canary_1_ok) { warnln("Canary 1 overwritten: Expected {}\n" " instead got {}", - show(expected.slice_view(0, SANDBOX_CANARY_SIZE)), - show(actual.slice_view(0, SANDBOX_CANARY_SIZE))); + show(expected.slice(0, SANDBOX_CANARY_SIZE)), + show(actual.slice(0, SANDBOX_CANARY_SIZE))); } if (!main_ok) { warnln("Wrong output: Expected {}\n" " instead, got {}", - show(expected.slice_view(SANDBOX_CANARY_SIZE, testcase.dest_n)), - show(actual.slice_view(SANDBOX_CANARY_SIZE, testcase.dest_n))); + show(expected.slice(SANDBOX_CANARY_SIZE, testcase.dest_n)), + show(actual.slice(SANDBOX_CANARY_SIZE, testcase.dest_n))); } if (!canary_2_ok) { warnln("Canary 2 overwritten: Expected {}\n" " instead, got {}", - show(expected.slice_view(SANDBOX_CANARY_SIZE + testcase.dest_n, SANDBOX_CANARY_SIZE)), - show(actual.slice_view(SANDBOX_CANARY_SIZE + testcase.dest_n, SANDBOX_CANARY_SIZE))); + show(expected.slice(SANDBOX_CANARY_SIZE + testcase.dest_n, SANDBOX_CANARY_SIZE)), + show(actual.slice(SANDBOX_CANARY_SIZE + testcase.dest_n, SANDBOX_CANARY_SIZE))); } if (!return_ok) { warnln("Wrong return value: Expected {}, got {} instead!", testcase.expected_return, actual_return); diff --git a/Userland/Tests/LibC/strlcpy-correctness.cpp b/Userland/Tests/LibC/strlcpy-correctness.cpp index d36677a990..00c3beeb38 100644 --- a/Userland/Tests/LibC/strlcpy-correctness.cpp +++ b/Userland/Tests/LibC/strlcpy-correctness.cpp @@ -89,9 +89,9 @@ static bool test_single(const Testcase& testcase) // Checking the results: bool return_ok = actual_return == testcase.src_n; - bool canary_1_ok = actual.slice_view(0, SANDBOX_CANARY_SIZE) == expected.slice_view(0, SANDBOX_CANARY_SIZE); - bool main_ok = actual.slice_view(SANDBOX_CANARY_SIZE, testcase.dest_n) == expected.slice_view(SANDBOX_CANARY_SIZE, testcase.dest_n); - bool canary_2_ok = actual.slice_view(SANDBOX_CANARY_SIZE + testcase.dest_n, SANDBOX_CANARY_SIZE) == expected.slice_view(SANDBOX_CANARY_SIZE + testcase.dest_n, SANDBOX_CANARY_SIZE); + bool canary_1_ok = actual.slice(0, SANDBOX_CANARY_SIZE) == expected.slice(0, SANDBOX_CANARY_SIZE); + bool main_ok = actual.slice(SANDBOX_CANARY_SIZE, testcase.dest_n) == expected.slice(SANDBOX_CANARY_SIZE, testcase.dest_n); + bool canary_2_ok = actual.slice(SANDBOX_CANARY_SIZE + testcase.dest_n, SANDBOX_CANARY_SIZE) == expected.slice(SANDBOX_CANARY_SIZE + testcase.dest_n, SANDBOX_CANARY_SIZE); bool buf_ok = actual == expected; // Evaluate gravity: @@ -102,20 +102,20 @@ static bool test_single(const Testcase& testcase) if (!canary_1_ok) { warnln("Canary 1 overwritten: Expected canary {}\n" " instead got {}", - show(expected.slice_view(0, SANDBOX_CANARY_SIZE)), - show(actual.slice_view(0, SANDBOX_CANARY_SIZE))); + show(expected.slice(0, SANDBOX_CANARY_SIZE)), + show(actual.slice(0, SANDBOX_CANARY_SIZE))); } if (!main_ok) { warnln("Wrong output: Expected {}\n" " instead got {}", - show(expected.slice_view(SANDBOX_CANARY_SIZE, testcase.dest_n)), - show(actual.slice_view(SANDBOX_CANARY_SIZE, testcase.dest_n))); + show(expected.slice(SANDBOX_CANARY_SIZE, testcase.dest_n)), + show(actual.slice(SANDBOX_CANARY_SIZE, testcase.dest_n))); } if (!canary_2_ok) { warnln("Canary 2 overwritten: Expected {}\n" " instead got {}", - show(expected.slice_view(SANDBOX_CANARY_SIZE + testcase.dest_n, SANDBOX_CANARY_SIZE)), - show(actual.slice_view(SANDBOX_CANARY_SIZE + testcase.dest_n, SANDBOX_CANARY_SIZE))); + show(expected.slice(SANDBOX_CANARY_SIZE + testcase.dest_n, SANDBOX_CANARY_SIZE)), + show(actual.slice(SANDBOX_CANARY_SIZE + testcase.dest_n, SANDBOX_CANARY_SIZE))); } if (!return_ok) { warnln("Wrong return value: Expected {}, got {} instead!", testcase.src_n, actual_return); |