diff options
author | louiz’ <louiz@louiz.org> | 2016-10-27 01:15:26 +0200 |
---|---|---|
committer | louiz’ <louiz@louiz.org> | 2016-10-27 01:15:26 +0200 |
commit | 6d5d7eff6835ff0dbeca8d84bfadee127918c3e9 (patch) | |
tree | 033511655f3fa87fe8e23b3b5cf3da8eda27c4d0 /louloulibs/network | |
parent | 021f025cb039011ad07158b0d94f1b430a409e49 (diff) | |
download | biboumi-6d5d7eff6835ff0dbeca8d84bfadee127918c3e9.tar.gz biboumi-6d5d7eff6835ff0dbeca8d84bfadee127918c3e9.tar.bz2 biboumi-6d5d7eff6835ff0dbeca8d84bfadee127918c3e9.tar.xz biboumi-6d5d7eff6835ff0dbeca8d84bfadee127918c3e9.zip |
Directly use Botan::byte instead of char, to avoid an unnecessary cast
Diffstat (limited to 'louloulibs/network')
-rw-r--r-- | louloulibs/network/tcp_socket_handler.cpp | 14 | ||||
-rw-r--r-- | louloulibs/network/tcp_socket_handler.hpp | 5 |
2 files changed, 8 insertions, 11 deletions
diff --git a/louloulibs/network/tcp_socket_handler.cpp b/louloulibs/network/tcp_socket_handler.cpp index 9d8cfea..1adbaac 100644 --- a/louloulibs/network/tcp_socket_handler.cpp +++ b/louloulibs/network/tcp_socket_handler.cpp @@ -417,15 +417,14 @@ void TCPSocketHandler::start_tls() void TCPSocketHandler::tls_recv() { static constexpr size_t buf_size = 4096; - char recv_buf[buf_size]; + Botan::byte recv_buf[buf_size]; const ssize_t size = this->do_recv(recv_buf, buf_size); if (size > 0) { const bool was_active = this->tls->is_active(); try { - this->tls->received_data(reinterpret_cast<const Botan::byte*>(recv_buf), - static_cast<size_t>(size)); + this->tls->received_data(recv_buf, static_cast<size_t>(size)); } catch (const Botan::TLS::TLS_Exception& e) { // May happen if the server sends malformed TLS data (buggy server, // or more probably we are just connected to a server that sends @@ -448,9 +447,8 @@ void TCPSocketHandler::tls_send(std::string&& data) const bool was_active = this->tls->is_active(); if (!this->pre_buf.empty()) { - this->tls->send(reinterpret_cast<const Botan::byte*>(this->pre_buf.data()), - this->pre_buf.size()); - this->pre_buf = ""; + this->tls->send(this->pre_buf.data(), this->pre_buf.size()); + this->pre_buf.clear(); } if (!data.empty()) this->tls->send(reinterpret_cast<const Botan::byte*>(data.data()), @@ -459,7 +457,9 @@ void TCPSocketHandler::tls_send(std::string&& data) this->on_tls_activated(); } else - this->pre_buf += data; + this->pre_buf.insert(this->pre_buf.end(), + std::make_move_iterator(data.begin()), + std::make_move_iterator(data.end())); } void TCPSocketHandler::tls_data_cb(const Botan::byte* data, size_t size) diff --git a/louloulibs/network/tcp_socket_handler.hpp b/louloulibs/network/tcp_socket_handler.hpp index b0ba493..7bbe4d4 100644 --- a/louloulibs/network/tcp_socket_handler.hpp +++ b/louloulibs/network/tcp_socket_handler.hpp @@ -266,9 +266,6 @@ private: * An additional buffer to keep data that the user wants to send, but * cannot because the handshake is not done. */ - std::string pre_buf; + std::vector<Botan::byte> pre_buf; #endif // BOTAN_FOUND }; - - - |