From dff44e4c8f3070abe108965f216ec6b364ca882d Mon Sep 17 00:00:00 2001 From: Hodlinator <172445034+hodlinator@users.noreply.github.com> Date: Tue, 28 Jul 2026 10:12:08 +0200 Subject: [PATCH] util: LineReader - Drop support for raw std::byte spans TorControlConnection and HTTPRemoteClient have been updated to use std::string receive buffers which mirrors approach in HTTPClient::ReadResponse(). --- src/httpserver.cpp | 2 +- src/httpserver.h | 2 +- src/test/fuzz/http_request.cpp | 2 +- src/torcontrol.cpp | 2 +- src/torcontrol.h | 2 +- src/util/string.h | 2 -- 6 files changed, 5 insertions(+), 7 deletions(-) diff --git a/src/httpserver.cpp b/src/httpserver.cpp index a05d19db1f2..d7193f06206 100644 --- a/src/httpserver.cpp +++ b/src/httpserver.cpp @@ -861,7 +861,7 @@ void HTTPServer::SocketHandlerConnected(const IOReadiness& io_readiness) const } if (recv_ready || err_ready) { - std::byte buf[0x10000]; // typical socket buffer is 8K-64K + char buf[0x10000]; // typical socket buffer is 8K-64K const ssize_t nrecv{WITH_LOCK( client->m_sock_mutex, diff --git a/src/httpserver.h b/src/httpserver.h index 9031eb61e0a..91142aa2681 100644 --- a/src/httpserver.h +++ b/src/httpserver.h @@ -461,7 +461,7 @@ public: * we copy data from the socket buffer to the client object * and attempt to read HTTP requests from here. */ - std::vector m_recv_buffer{}; + std::string m_recv_buffer{}; //! Requests from a client must be processed in the order in which //! they were received, blocking on a per-client basis. We won't diff --git a/src/test/fuzz/http_request.cpp b/src/test/fuzz/http_request.cpp index c992edcd178..82b270bdce4 100644 --- a/src/test/fuzz/http_request.cpp +++ b/src/test/fuzz/http_request.cpp @@ -25,7 +25,7 @@ FUZZ_TARGET(http_request) using util::LineReader; FuzzedDataProvider fuzzed_data_provider{buffer.data(), buffer.size()}; - const std::vector http_buffer{ConsumeRandomLengthByteVector(fuzzed_data_provider, 4096)}; + const std::string http_buffer{fuzzed_data_provider.ConsumeRandomLengthString(4096)}; HTTPRequest http_request; LineReader reader(http_buffer, MAX_HEADERS_SIZE); diff --git a/src/torcontrol.cpp b/src/torcontrol.cpp index 9e00c7151ba..6f05ea4b091 100644 --- a/src/torcontrol.cpp +++ b/src/torcontrol.cpp @@ -149,7 +149,7 @@ bool TorControlConnection::ReceiveAndProcess() { if (!m_sock) return false; - std::byte buf[4096]; + char buf[4096]; ssize_t nread = m_sock->Recv(buf, sizeof(buf), MSG_DONTWAIT); if (nread < 0) { diff --git a/src/torcontrol.h b/src/torcontrol.h index 410cb0b368c..06a9d3e8bd3 100644 --- a/src/torcontrol.h +++ b/src/torcontrol.h @@ -109,7 +109,7 @@ private: /** Response handlers */ std::deque m_reply_handlers; /** Buffer for incoming data */ - std::vector m_recv_buffer; + std::string m_recv_buffer; /** Process complete lines from the receive buffer */ bool ProcessBuffer(); }; diff --git a/src/util/string.h b/src/util/string.h index e8f6ddf886a..d60fff0432c 100644 --- a/src/util/string.h +++ b/src/util/string.h @@ -272,8 +272,6 @@ class LineReader std::string_view::iterator m_it; public: - explicit LineReader(std::span buffer, size_t max_line_length) - : LineReader{std::string_view{reinterpret_cast(buffer.data()), buffer.size()}, max_line_length} {} explicit LineReader(std::string_view str, size_t max_line_length); /**