]> git.sesse.net Git - nageru/commitdiff
Fix an issue where data would get corrupted if the client asked for chunked transfer...
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Thu, 7 Apr 2016 21:00:08 +0000 (23:00 +0200)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Thu, 7 Apr 2016 21:00:08 +0000 (23:00 +0200)
httpd.cpp

index cd3d6e11e23dd17dab74f9eb13d4a6603e8dd081..518e77dc4cafa0a39c689a7be299b0f65da03535 100644 (file)
--- a/httpd.cpp
+++ b/httpd.cpp
@@ -277,6 +277,7 @@ ssize_t HTTPD::Stream::reader_callback(uint64_t pos, char *buf, size_t max)
                if (max >= len) {
                        // Consume the entire (rest of the) string.
                        memcpy(buf, s.data() + used_of_buffered_data, len);
+                       buf += len;
                        ret += len;
                        max -= len;
                        buffered_data.pop_front();
@@ -284,6 +285,7 @@ ssize_t HTTPD::Stream::reader_callback(uint64_t pos, char *buf, size_t max)
                } else {
                        // We don't need the entire string; just use the first part of it.
                        memcpy(buf, s.data() + used_of_buffered_data, max);
+                       buf += max;
                        used_of_buffered_data += max;
                        ret += max;
                        max = 0;