Browse Source

Applied patches from OpenBSD to fix addrinfo and HTTP.

Applied OpenBSD patches from Nicholas Marriott.
Closes GH-12
master
Marq Schneider 14 years ago
parent
commit
1b22c92d46
2 changed files with 8 additions and 3 deletions
  1. +1
    -1
      btpd/addrinfo.c
  2. +7
    -2
      misc/http_client.c

+ 1
- 1
btpd/addrinfo.c View File

@@ -52,7 +52,7 @@ addrinfo_td_cb(void *arg)
struct ai_ctx *ctx = arg; struct ai_ctx *ctx = arg;
if (!ctx->cancel) if (!ctx->cancel)
ctx->cb(ctx->arg, ctx->error, ctx->res); ctx->cb(ctx->arg, ctx->error, ctx->res);
else if (ctx->error != 0) else if (ctx->res != NULL)
freeaddrinfo(ctx->res); freeaddrinfo(ctx->res);
free(ctx); free(ctx);
} }


+ 7
- 2
misc/http_client.c View File

@@ -213,7 +213,7 @@ static int
http_parse(struct http_req *req, int len) http_parse(struct http_req *req, int len)
{ {
char *end, *numend; char *end, *numend;
size_t dlen; size_t dlen, consumed;
struct http_response res; struct http_response res;
again: again:
switch (req->pstate) { switch (req->pstate) {
@@ -230,6 +230,11 @@ again:
else else
goto error; 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)) if (!iobuf_write(&req->rbuf, "", 1))
goto error; goto error;
req->rbuf.off--; req->rbuf.off--;
@@ -237,7 +242,7 @@ again:
goto error; goto error;
if (req->cancel) if (req->cancel)
goto cancel; goto cancel;
iobuf_consumed(&req->rbuf, end - (char *)req->rbuf.buf + dlen); iobuf_consumed(&req->rbuf, consumed);
goto again; goto again;
case PS_CHUNK_SIZE: case PS_CHUNK_SIZE:
assert(req->chunked); assert(req->chunked);


||||||
x
 
000:0
Loading…
Cancel
Save