diff options
| author | Marq Schneider <queueRAM@gmail.com> | 2010-07-18 13:41:04 -0500 |
|---|---|---|
| committer | Marq Schneider <queueRAM@gmail.com> | 2010-07-18 13:41:04 -0500 |
| commit | 1b22c92d46f3f98af781853c3e16190c686bbd9b (patch) | |
| tree | bced12b2ea3a1dc315f592b841f8a59910599a92 /misc/http_client.c | |
| parent | 034ba1a5e4906d4f69dccea8d41108b5adbc780c (diff) | |
| download | btpd-1b22c92d46f3f98af781853c3e16190c686bbd9b.tar.gz btpd-1b22c92d46f3f98af781853c3e16190c686bbd9b.zip | |
Applied patches from OpenBSD to fix addrinfo and HTTP.
Applied OpenBSD patches from Nicholas Marriott. Closes GH-12
Diffstat (limited to 'misc/http_client.c')
| -rw-r--r-- | misc/http_client.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/misc/http_client.c b/misc/http_client.c index 1b0d564..6a72533 100644 --- a/misc/http_client.c +++ b/misc/http_client.c @@ -213,7 +213,7 @@ static int http_parse(struct http_req *req, int len) { char *end, *numend; - size_t dlen; + size_t dlen, consumed; struct http_response res; again: switch (req->pstate) { @@ -230,6 +230,11 @@ again: else goto error; } + + /* req->rbuf.buf may be reallocated inside iobuf_write() + * so calculate the offset before that is called */ + consumed = end - (char *)req->rbuf.buf + dlen; + if (!iobuf_write(&req->rbuf, "", 1)) goto error; req->rbuf.off--; @@ -237,7 +242,7 @@ again: goto error; if (req->cancel) goto cancel; - iobuf_consumed(&req->rbuf, end - (char *)req->rbuf.buf + dlen); + iobuf_consumed(&req->rbuf, consumed); goto again; case PS_CHUNK_SIZE: assert(req->chunked); |