summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibProtocol
diff options
context:
space:
mode:
authorMichiel Visser <opensource@webmichiel.nl>2022-02-16 11:51:04 +0100
committerAli Mohammad Pur <Ali.mpfard@gmail.com>2022-02-16 17:28:46 +0330
commit45004022ad994e78ec0210aa969033e11dad3500 (patch)
tree7933f0dace1feb3c4acc2797ec27235ba3626699 /Userland/Libraries/LibProtocol
parent7070713ec82675cd8ac0c6a86e6259d3543f60c4 (diff)
downloadserenity-45004022ad994e78ec0210aa969033e11dad3500.zip
LibProtocol: Fix crash on EOF when using Request::stream_into
`Request::stream_into_impl` would call `stream.write_or_error` with a zero length buffer when EOF was reached. However, the `Core::Stream::Stream::write_or_error` implementation verifies that the buffer lenght is non-zero, resulting in a crash. With this change the zero length buffer is never written to the stream.
Diffstat (limited to 'Userland/Libraries/LibProtocol')
-rw-r--r--Userland/Libraries/LibProtocol/Request.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/Userland/Libraries/LibProtocol/Request.cpp b/Userland/Libraries/LibProtocol/Request.cpp
index 35b7cbb2c7..bf506c2582 100644
--- a/Userland/Libraries/LibProtocol/Request.cpp
+++ b/Userland/Libraries/LibProtocol/Request.cpp
@@ -52,12 +52,12 @@ void Request::stream_into_impl(T& stream)
if (result.is_error())
continue;
auto nread = result.value();
+ if (nread == 0)
+ break;
if (!stream.write_or_error({ buf, nread })) {
// FIXME: What do we do here?
TODO();
}
- if (nread == 0)
- break;
} while (true);
if (m_internal_stream_data->read_stream->is_eof() && m_internal_stream_data->request_done) {