Commit fd963085 authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Dump our buffer as Debug if we have HTTP header trouble.

Issue 400 for HTTP header buffer overflow.



git-svn-id: http://www.varnish-cache.org/svn/trunk/varnish-cache@366 d4fa192b-c00b-0410-8231-f00ffab90ce4
parent 9b072a1d
......@@ -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);
......
......@@ -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 {
......
......@@ -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;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment