r366 - trunk/varnish-cache/bin/varnishd

phk at projects.linpro.no phk at projects.linpro.no
Fri Jul 7 08:29:23 CEST 2006


Author: phk
Date: 2006-07-07 08:29:23 +0200 (Fri, 07 Jul 2006)
New Revision: 366

Modified:
   trunk/varnish-cache/bin/varnishd/cache.h
   trunk/varnish-cache/bin/varnishd/cache_http.c
   trunk/varnish-cache/bin/varnishd/cache_pool.c
Log:
Dump our buffer as Debug if we have HTTP header trouble.

Issue 400 for HTTP header buffer overflow.



Modified: trunk/varnish-cache/bin/varnishd/cache.h
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache.h	2006-07-07 06:27:32 UTC (rev 365)
+++ trunk/varnish-cache/bin/varnishd/cache.h	2006-07-07 06:29:23 UTC (rev 366)
@@ -169,7 +169,7 @@
 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);

Modified: trunk/varnish-cache/bin/varnishd/cache_http.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_http.c	2006-07-07 06:27:32 UTC (rev 365)
+++ trunk/varnish-cache/bin/varnishd/cache_http.c	2006-07-07 06:29:23 UTC (rev 366)
@@ -226,21 +226,27 @@
 		/* 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 @@
 			*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 @@
 	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 @@
 			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 @@
 	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 @@
 		hp->t = hp->s;
 		if (http_header_complete(hp)) {
 			assert(func != NULL);
-			func(arg, 1);
+			func(arg, 0);
 			return;
 		}
 	} else  {

Modified: trunk/varnish-cache/bin/varnishd/cache_pool.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_pool.c	2006-07-07 06:27:32 UTC (rev 365)
+++ trunk/varnish-cache/bin/varnishd/cache_pool.c	2006-07-07 06:29:23 UTC (rev 366)
@@ -135,12 +135,15 @@
 }
 
 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;
 	}




More information about the varnish-commit mailing list