]> err.no Git - varnish/commitdiff
Fix off by one
authorphk <phk@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Wed, 5 Jul 2006 14:40:14 +0000 (14:40 +0000)
committerphk <phk@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Wed, 5 Jul 2006 14:40:14 +0000 (14:40 +0000)
git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@334 d4fa192b-c00b-0410-8231-f00ffab90ce4

varnish-cache/bin/varnishd/cache_http.c

index 7ff5a8c36308740beeb8dd3eaa123fb5455fdda0..fee27f29880c7b1c06c7d33694b95bfa459dbb8d 100644 (file)
@@ -192,6 +192,7 @@ http_GetTail(struct http *hp, unsigned len, char **b, char **e)
        *b = hp->t;
        *e = hp->t + len;
        hp->t += len;
+       assert(hp->t <= hp->v);
        return (1);
 }
 
@@ -217,6 +218,7 @@ http_Dissect(struct http *hp, int fd, int rr)
                        ;
                VSLR(SLT_Request, fd, hp->req, p);
                *p++ = '\0';
+               assert(!strcmp(hp->req, "GET"));
 
                /* Next find the URI */
                while (isspace(*p))
@@ -293,6 +295,7 @@ http_Dissect(struct http *hp, int fd, int rr)
                        VSLR(SLT_LostHeader, fd, p, q);
                }
        }
+       assert(hp->t <= hp->v);
        assert(hp->t == r);
 }
 
@@ -316,7 +319,10 @@ http_header_complete(struct http *hp)
                        continue;
                break;
        }
-       hp->t = ++p;
+       if (++p > hp->v)
+               return (0);
+       hp->t = p;
+       assert(hp->t <= hp->v);
        return (1);
 }
 
@@ -371,6 +377,8 @@ http_RecvHead(struct http *hp, int fd, struct event_base *eb, http_callback_f *f
        unsigned l;
 
        assert(hp != NULL);
+       assert(hp->v <= hp->e);
+       assert(hp->t <= hp->v);
        VSL(SLT_Debug, fd, "Recv t %u v %u", hp->t - hp->s, hp->v - hp->s);
        if (hp->t > hp->s && hp->t < hp->v) {
                l = hp->v - hp->t;