]> err.no Git - varnish/commitdiff
Dump our buffer as Debug if we have HTTP header trouble.
authorphk <phk@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Fri, 7 Jul 2006 06:29:23 +0000 (06:29 +0000)
committerphk <phk@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Fri, 7 Jul 2006 06:29:23 +0000 (06:29 +0000)
Issue 400 for HTTP header buffer overflow.

git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@366 d4fa192b-c00b-0410-8231-f00ffab90ce4

varnish-cache/bin/varnishd/cache.h
varnish-cache/bin/varnishd/cache_http.c
varnish-cache/bin/varnishd/cache_pool.c

index e3083ca948dda343c693726731a0d4a42fb8ab49..3c60a06b84c264f814b170bac840a49e843e48f8 100644 (file)
@@ -169,7 +169,7 @@ void HSH_Deref(struct object *o);
 void HSH_Init(void);
 
 /* cache_http.c */
-typedef void http_callback_f(void *, int good);
+typedef void http_callback_f(void *, int bad);
 struct http;
 struct http *http_New(void);
 void http_Delete(struct http *hp);
index 795d4c126080d20fd17c66d7908f0275fa94b083..2316ac86e53498401784b1cd34040b3ba22bed80 100644 (file)
@@ -226,21 +226,27 @@ http_Dissect(struct http *hp, int fd, int rr)
                /* Next find the URI */
                while (isspace(*p) && *p != '\n')
                        p++;
-               if (*p == '\n')
+               if (*p == '\n') {
+                       VSLR(SLT_Debug, fd, hp->s, hp->v);
                        return (400);
+               }
                hp->url = p;
                while (!isspace(*p))
                        p++;
                VSLR(SLT_URL, fd, hp->url, p);
-               if (*p == '\n')
+               if (*p == '\n') {
+                       VSLR(SLT_Debug, fd, hp->s, hp->v);
                        return (400);
+               }
                *p++ = '\0';
 
                /* Finally, look for protocol */
                while (isspace(*p) && *p != '\n')
                        p++;
-               if (*p == '\n')
+               if (*p == '\n') {
+                       VSLR(SLT_Debug, fd, hp->s, hp->v);
                        return (400);
+               }
                hp->proto = p;
                while (!isspace(*p))
                        p++;
@@ -249,8 +255,10 @@ http_Dissect(struct http *hp, int fd, int rr)
                        *p++ = '\0';
                while (isspace(*p) && *p != '\n')
                        p++;
-               if (*p != '\n')
+               if (*p != '\n') {
+                       VSLR(SLT_Debug, fd, hp->s, hp->v);
                        return (400);
+               }
                *p++ = '\0';
        } else {
                /* First, protocol */
@@ -354,6 +362,14 @@ http_read_f(int fd, short event, void *arg)
        int i;
 
        l = hp->e - hp->v;
+       if (l <= 1) {
+               VSLR(SLT_Debug, fd, hp->s, hp->v);
+               hp->t = NULL;
+               event_del(&hp->ev);
+               if (hp->callback != NULL)
+                       hp->callback(hp->arg, 1);
+               return;
+       }
        assert(l > 1);
        errno = 0;
        i = read(fd, hp->v, l - 1);
@@ -366,10 +382,11 @@ http_read_f(int fd, short event, void *arg)
                        VSL(SLT_HttpError, fd, "Received nothing");
                else
                        VSL(SLT_HttpError, fd, "Received errno %d", errno);
+               VSLR(SLT_Debug, fd, hp->s, hp->v);
                hp->t = NULL;
                event_del(&hp->ev);
                if (hp->callback != NULL)
-                       hp->callback(hp->arg, 0);
+                       hp->callback(hp->arg, 2);
                return;
        }
 
@@ -381,7 +398,7 @@ http_read_f(int fd, short event, void *arg)
        assert(hp->t != NULL);
        event_del(&hp->ev);
        if (hp->callback != NULL)
-               hp->callback(hp->arg, 1);
+               hp->callback(hp->arg, 0);
 }
 
 /*--------------------------------------------------------------------*/
@@ -403,7 +420,7 @@ http_RecvHead(struct http *hp, int fd, struct event_base *eb, http_callback_f *f
                hp->t = hp->s;
                if (http_header_complete(hp)) {
                        assert(func != NULL);
-                       func(arg, 1);
+                       func(arg, 0);
                        return;
                }
        } else  {
index 4f3fdf94bbfba1c65e04e38c765909a5db51e9aa..323ab3b12fc58b93eeba0ea9302039b83572295d 100644 (file)
@@ -135,12 +135,15 @@ out:
 }
 
 void
-DealWithSession(void *arg, int good)
+DealWithSession(void *arg, int bad)
 {
        struct sess *sp = arg;
 
-       if (!good) {
-               vca_close_session(sp, "no request");
+       if (bad) {
+               if (bad == 1)
+                       vca_close_session(sp, "overflow");
+               else
+                       vca_close_session(sp, "no request");
                vca_return_session(sp);
                return;
        }