diff options
author | Luke Wilde <lukew@serenityos.org> | 2022-10-18 22:07:41 +0100 |
---|---|---|
committer | Linus Groh <mail@linusgroh.de> | 2022-10-18 23:18:20 +0200 |
commit | 41d6307c179f267cbf45adaf216f8380920dec34 (patch) | |
tree | 68e60222a228d67fa8aeff4f613d85775316d084 /Userland/Libraries | |
parent | 5fcf00f30d2294bce1e06f99907e34842c42f160 (diff) | |
download | serenity-41d6307c179f267cbf45adaf216f8380920dec34.zip |
LibHTTP: Fix not consuming the last byte of body in from_raw_request
`index + 1` was not correct. For example, if the body has two bytes, we
would consume the first byte and increment the index. We then add one
to the index and see it's equal to the size, so we take this one byte
and set the body result to it. The while loop would still continue and
we consume the second byte, adding it to the temporary buffer. We see
that the index is above the size, so we don't update the body, dropping
the last byte on the floor.
Diffstat (limited to 'Userland/Libraries')
-rw-r--r-- | Userland/Libraries/LibHTTP/HttpRequest.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/Userland/Libraries/LibHTTP/HttpRequest.cpp b/Userland/Libraries/LibHTTP/HttpRequest.cpp index dc1928a104..fa43b6585e 100644 --- a/Userland/Libraries/LibHTTP/HttpRequest.cpp +++ b/Userland/Libraries/LibHTTP/HttpRequest.cpp @@ -175,7 +175,7 @@ Optional<HttpRequest> HttpRequest::from_raw_request(ReadonlyBytes raw_request) break; case State::InBody: buffer.append(consume()); - if (index + 1 == raw_request.size()) { + if (index == raw_request.size()) { // End of data, so store the body auto maybe_body = ByteBuffer::copy(buffer); // FIXME: Propagate this error somehow. |