summaryrefslogtreecommitdiffstats
path: root/lib/libfetch
diff options
context:
space:
mode:
authordes <des@FreeBSD.org>2015-12-16 09:17:07 +0000
committerdes <des@FreeBSD.org>2015-12-16 09:17:07 +0000
commitf487c94c08bac0f4959d84ed0dc62e5ecd215aee (patch)
tree36ea2cf0bc84393cf3cfe58ee80c6c737bf3100c /lib/libfetch
parentb2f446313468f5dd643849b55606deda0852499b (diff)
downloadFreeBSD-src-f487c94c08bac0f4959d84ed0dc62e5ecd215aee.zip
FreeBSD-src-f487c94c08bac0f4959d84ed0dc62e5ecd215aee.tar.gz
Reset bufpos to 0 immediately after refilling the buffer. Otherwise, we
risk leaving the connection in an indeterminate state if the server fails to send a chunk delimiter. Depending on the application and on the sizes of the preceding chunks, the result can be anything from missing data to a segfault. With this patch, it will be reported as a protocol error. PR: 204771 MFC after: 1 week
Diffstat (limited to 'lib/libfetch')
-rw-r--r--lib/libfetch/http.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/lib/libfetch/http.c b/lib/libfetch/http.c
index 51cac70..4867333 100644
--- a/lib/libfetch/http.c
+++ b/lib/libfetch/http.c
@@ -246,8 +246,9 @@ http_fillbuf(struct httpio *io, size_t len)
io->error = errno;
return (-1);
}
+ io->bufpos = 0;
io->buflen = nbytes;
- io->chunksize -= io->buflen;
+ io->chunksize -= nbytes;
if (io->chunksize == 0) {
if (fetch_read(io->conn, &ch, 1) != 1 || ch != '\r' ||
@@ -255,8 +256,6 @@ http_fillbuf(struct httpio *io, size_t len)
return (-1);
}
- io->bufpos = 0;
-
return (io->buflen);
}
OpenPOWER on IntegriCloud