Commit bc40c1af authored by Andreas Plesner Jacobsen's avatar Andreas Plesner Jacobsen Committed by Tollef Fog Heen

Ignore invalid HTTP headers

parent 2f57b83a
...@@ -250,7 +250,7 @@ static int ...@@ -250,7 +250,7 @@ static int
collect_backend(struct logline *lp, enum VSL_tag_e tag, unsigned spec, collect_backend(struct logline *lp, enum VSL_tag_e tag, unsigned spec,
const char *ptr, unsigned len) const char *ptr, unsigned len)
{ {
const char *end, *next; const char *end, *next, *split;
assert(spec & VSL_S_BACKEND); assert(spec & VSL_S_BACKEND);
end = ptr + len; end = ptr + len;
...@@ -330,18 +330,19 @@ collect_backend(struct logline *lp, enum VSL_tag_e tag, unsigned spec, ...@@ -330,18 +330,19 @@ collect_backend(struct logline *lp, enum VSL_tag_e tag, unsigned spec,
break; break;
case SLT_TxHeader: case SLT_TxHeader:
split = strchr(ptr, ':');
if (!lp->active) if (!lp->active)
break; break;
if (split == NULL)
break;
if (isprefix(ptr, "authorization:", end, &next) && if (isprefix(ptr, "authorization:", end, &next) &&
isprefix(next, "basic", end, &next)) { isprefix(next, "basic", end, &next)) {
lp->df_u = trimline(next, end); lp->df_u = trimline(next, end);
} else { } else {
struct hdr *h; struct hdr *h;
const char *split;
size_t l; size_t l;
h = malloc(sizeof(struct hdr)); h = malloc(sizeof(struct hdr));
AN(h); AN(h);
split = strchr(ptr, ':');
AN(split); AN(split);
l = strlen(split); l = strlen(split);
h->key = trimline(ptr, split-1); h->key = trimline(ptr, split-1);
...@@ -369,7 +370,7 @@ static int ...@@ -369,7 +370,7 @@ static int
collect_client(struct logline *lp, enum VSL_tag_e tag, unsigned spec, collect_client(struct logline *lp, enum VSL_tag_e tag, unsigned spec,
const char *ptr, unsigned len) const char *ptr, unsigned len)
{ {
const char *end, *next; const char *end, *next, *split;
long l; long l;
time_t t; time_t t;
...@@ -437,8 +438,11 @@ collect_client(struct logline *lp, enum VSL_tag_e tag, unsigned spec, ...@@ -437,8 +438,11 @@ collect_client(struct logline *lp, enum VSL_tag_e tag, unsigned spec,
case SLT_TxHeader: case SLT_TxHeader:
case SLT_RxHeader: case SLT_RxHeader:
split = strchr(ptr, ':');
if (!lp->active) if (!lp->active)
break; break;
if (split == NULL)
break;
if (tag == SLT_RxHeader && if (tag == SLT_RxHeader &&
isprefix(ptr, "authorization:", end, &next) && isprefix(ptr, "authorization:", end, &next) &&
isprefix(next, "basic", end, &next)) { isprefix(next, "basic", end, &next)) {
...@@ -446,10 +450,8 @@ collect_client(struct logline *lp, enum VSL_tag_e tag, unsigned spec, ...@@ -446,10 +450,8 @@ collect_client(struct logline *lp, enum VSL_tag_e tag, unsigned spec,
lp->df_u = trimline(next, end); lp->df_u = trimline(next, end);
} else { } else {
struct hdr *h; struct hdr *h;
const char *split;
h = malloc(sizeof(struct hdr)); h = malloc(sizeof(struct hdr));
AN(h); AN(h);
split = strchr(ptr, ':');
AN(split); AN(split);
h->key = trimline(ptr, split); h->key = trimline(ptr, split);
h->value = trimline(split+1, end); h->value = trimline(split+1, end);
......
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