Commit 2be65dda authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Treat NULL elements of string assignment as empty string line1 proto fields.

Refuse assignment of empty strings to line1 proto fields, issue VSL
record LostHdr.

line1 proto fields are request, url, proto and response. status is
numeric and not affected.

Fixes: #781



git-svn-id: http://www.varnish-cache.org/svn/trunk/varnish-cache@5224 d4fa192b-c00b-0410-8231-f00ffab90ce4
parent 0ae4d096
......@@ -161,12 +161,12 @@ vrt_build_string(struct ws *ws, const char *h, const char *p, va_list ap)
b++;
}
while (p != vrt_magic_string_end && b < e) {
if (p == NULL)
p = "(null)";
x = strlen(p);
if (b + x < e)
memcpy(b, p, x);
b += x;
if (p != NULL) {
x = strlen(p);
if (b + x < e)
memcpy(b, p, x);
b += x;
}
p = va_arg(ap, const char *);
}
if (b < e)
......@@ -247,10 +247,10 @@ vrt_do_string(struct worker *w, int fd, struct http *hp, int fld,
{
char *b;
AN(p);
// AN(p);
AN(hp);
b = vrt_assemble_string(hp, NULL, p, ap);
if (b == NULL) {
if (b == NULL || *b == '\0') {
WSL(w, SLT_LostHeader, fd, err);
} else {
http_SetH(hp, fld, b);
......@@ -264,7 +264,6 @@ VRT_l_##obj##_##hdr(const struct sess *sp, const char *p, ...) \
{ \
va_list ap; \
\
AN(p); \
va_start(ap, p); \
vrt_do_string(sp->wrk, sp->fd, \
http, fld, #obj "." #hdr, p, ap); \
......
# $Id$
test "NULL assignment to line1 fields."
server s1 {
rxreq
txresp -bodylen 10
} -start
varnish v1 -vcl+backend {
sub vcl_recv {
set req.url = req.http.foo;
}
sub vcl_miss {
set bereq.url = req.http.foo;
}
} -start
client c1 {
txreq
rxresp
} -run
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