From 2e965b3324b32be00a2193bf304dcb936f02824b Mon Sep 17 00:00:00 2001 From: rsc Date: Wed, 5 May 2004 04:22:16 +0000 Subject: various bug fixes --- src/libhttpd/gethead.c | 11 +++-------- src/libhttpd/hio.c | 6 +++--- src/libhttpd/parse.c | 2 +- src/libhttpd/parsereq.c | 4 ++-- 4 files changed, 9 insertions(+), 14 deletions(-) (limited to 'src/libhttpd') diff --git a/src/libhttpd/gethead.c b/src/libhttpd/gethead.c index 5983345e..0677cc8f 100644 --- a/src/libhttpd/gethead.c +++ b/src/libhttpd/gethead.c @@ -15,15 +15,11 @@ hgethead(HConnect *c, int many) int n; hin = &c->hin; -fprint(2, "hgethead top %p - %p\n", hin->pos, hin->stop); for(;;){ s = (char*)hin->pos; pp = s; -fprint(2, "hgethead %p - %p\n", pp, hin->stop); while(p = memchr(pp, '\n', (char*)hin->stop - pp)){ -fprint(2, "hgethead %p - %p newline at %p %d\n", pp, hin->stop, p, *pp); if(!many || p == pp || (p == pp + 1 && *pp == '\r')){ -fprint(2, "breaking\n"); pp = p + 1; break; } @@ -32,14 +28,13 @@ fprint(2, "breaking\n"); hin->pos = (uchar*)pp; n = pp - s; if(c->hstop + n > &c->header[HBufSize]) - return 0; + return -1; memmove(c->hstop, s, n); c->hstop += n; *c->hstop = '\0'; -fprint(2, "p %p\n", p); if(p != nil) - return 1; - if(hreadbuf(hin, hin->pos) == nil || hin->state == Hend) return 0; + if(hreadbuf(hin, hin->pos) == nil || hin->state == Hend) + return -1; } } diff --git a/src/libhttpd/hio.c b/src/libhttpd/hio.c index 34d3a3a2..3561b681 100644 --- a/src/libhttpd/hio.c +++ b/src/libhttpd/hio.c @@ -281,7 +281,7 @@ hload(Hio *h, char *buf) s = strchr(hstates, buf[0]); if(s == nil) - return 0; + return -1; h->state = s - hstates; s = strchr(hxfers, buf[1]); @@ -300,13 +300,13 @@ hload(Hio *h, char *buf) } *t++ = c; if(t >= stop) - return 0; + return -1; } *t = '\0'; h->pos = h->start; h->stop = t; h->seek = 0; - return 1; + return 0; } void diff --git a/src/libhttpd/parse.c b/src/libhttpd/parse.c index 5fd4092a..8e8364b0 100644 --- a/src/libhttpd/parse.c +++ b/src/libhttpd/parse.c @@ -198,7 +198,7 @@ hparseheaders(HConnect *c, int timeout) memset(&h, 0, sizeof(h)); h.c = c; alarm(timeout); - if(!hgethead(c, 1)) + if(hgethead(c, 1) < 0) return -1; alarm(0); h.hstart = c->hpos; diff --git a/src/libhttpd/parsereq.c b/src/libhttpd/parsereq.c index 7ef63413..94237988 100644 --- a/src/libhttpd/parsereq.c +++ b/src/libhttpd/parsereq.c @@ -41,8 +41,8 @@ hparsereq(HConnect *c, int timeout) * only works for http/1.1 or later. */ alarm(timeout); - if(!hgethead(c, 0)) - return 0; + if(hgethead(c, 0) < 0) + return -1; alarm(0); c->reqtime = time(nil); c->req.meth = getword(c); -- cgit v1.2.3