From f883dc3eb042cf1058ca9db6f764e338b41a7b3a Mon Sep 17 00:00:00 2001 From: Arda Cinar Date: Fri, 13 Jan 2023 20:01:34 +0300 Subject: [PATCH] RequestServer: Do not crash on Gemini responses Starting a gemini request creates a pipe for the output stream for the response, and a Core::Stream::File object is created from that pipe. Previously, the length of the response was computed by calling output_stream.size() which used lseek on the file descriptor. Doing that returned an error from lseek. Computing the value by counting the received bytes (via Gemini::Job::response_length) avoids that crash. --- Userland/Services/RequestServer/GeminiRequest.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Userland/Services/RequestServer/GeminiRequest.cpp b/Userland/Services/RequestServer/GeminiRequest.cpp index 0ec84e7387..048338f30e 100644 --- a/Userland/Services/RequestServer/GeminiRequest.cpp +++ b/Userland/Services/RequestServer/GeminiRequest.cpp @@ -21,7 +21,7 @@ GeminiRequest::GeminiRequest(ConnectionFromClient& client, NonnullRefPtrresponse()) { - set_downloaded_size(MUST(const_cast(this->output_stream()).size())); + set_downloaded_size(MUST(m_job->response_length())); if (!response->meta().is_empty()) { HashMap headers; headers.set("meta", response->meta());