Commit 23705c43 authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Use VRT_fail in case silly HTTP status numbers are set, and test that.

parent e9e1373b
......@@ -97,17 +97,14 @@ VRT_l_##obj##_status(VRT_CTX, long num) \
\
CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); \
CHECK_OBJ_NOTNULL(ctx->http_##obj, HTTP_MAGIC); \
if (num > 65535) { \
VSLb(ctx->vsl, SLT_VCL_Error, \
"%s.status > 65535", #obj); \
WS_MarkOverflow(ctx->http_##obj->ws); \
} else if ((num % 1000) < 100) { \
VSLb(ctx->vsl, SLT_VCL_Error, \
"illegal %s.status (..0##)", #obj); \
WS_MarkOverflow(ctx->http_##obj->ws); \
} else { \
if (num < 0) \
VRT_fail(ctx, "%s.status (%ld) is negative", #obj, num); \
else if (num > 65535) \
VRT_fail(ctx, "%s.status (%ld) > 65535", #obj, num); \
else if ((num % 1000) < 100) \
VRT_fail(ctx, "illegal %s.status (%ld) (..0##)", #obj, num); \
else \
http_SetStatus(ctx->http_##obj, (uint16_t)num); \
} \
}
#define VRT_STATUS_R(obj) \
......
......@@ -91,6 +91,15 @@ varnish v1 -vcl+backend {
return (synth(400));
}
}
if (req.http.huge == "yes") {
set resp.status = 65536;
}
if (req.http.small == "yes") {
set resp.status = 99;
}
if (req.http.negative == "yes") {
set resp.status = -200;
}
}
sub vcl_recv {
......@@ -100,6 +109,9 @@ varnish v1 -vcl+backend {
}
sub vcl_synth {
if (resp.reason == "VCL failed") {
return (deliver);
}
std.log("synth " + resp.status + " " + resp.reason);
if (resp.status != 22301) {
set resp.status = 501;
......@@ -148,10 +160,35 @@ client c1 {
rxresp
expect resp.status == 302
expect resp.reason == "Wrong Postcode"
}
} -run
logexpect l1 -v v1 {
expect * * VCL_Error "illegal resp.status .99. ...0##."
expect * * VCL_Error "resp.status .65536. > 65535"
expect * * VCL_Error "resp.status .-200. is negative"
} -start
client c1 -run
client c1 {
txreq -url "/a" -hdr "Small: yes"
rxresp
expect resp.status == 503
expect resp.reason == "VCL failed"
expect_close
} -run
client c1 {
txreq -url "/a" -hdr "Huge: yes"
rxresp
expect resp.status == 503
expect resp.reason == "VCL failed"
} -run
server s1 -wait
client c1 {
txreq -url "/a" -hdr "Negative: yes"
rxresp
expect resp.status == 503
expect resp.reason == "VCL failed"
} -run
varnish v1 -stop
logexpect l1 -wait
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