Mailing List Archive

[6.0] ae97f2ccf Check for illegal status codes when executing return(synth())
commit ae97f2ccfc029a5883b7c424035f3a8c71f5d34c
Author: Martin Blix Grydeland <martin@varnish-software.com>
Date: Fri Apr 24 16:31:45 2020 +0200

Check for illegal status codes when executing return(synth())

Some status codes are illegal and will cause VRT_fail() when executed as
normal set instructions in VCL. But this test is bypassed when status is
set as a side effect of a `return (synth(code))` statement.

This patch applies the same rules as when executing a set-instruction to
the return(synth()) handling.

Fixes second part of: #3301

diff --git a/bin/varnishd/cache/cache_vrt.c b/bin/varnishd/cache/cache_vrt.c
index 343481346..42f2995a1 100644
--- a/bin/varnishd/cache/cache_vrt.c
+++ b/bin/varnishd/cache/cache_vrt.c
@@ -56,8 +56,22 @@ VRT_synth(VRT_CTX, VCL_INT code, VCL_STRING reason)

CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC);
assert(ctx->req != NULL || ctx->bo != NULL);
- if (code < 100 || code > 65535)
- code = 503;
+ if (code < 0) {
+ VRT_fail(ctx, "return(synth()) status code (%jd) is negative",
+ code);
+ return;
+ }
+ if (code > 65535) {
+ VRT_fail(ctx, "return(synth()) status code (%jd) > 65535",
+ code);
+ return;
+ }
+ if ((code % 1000) < 100) {
+ VRT_fail(ctx,
+ "illegal return(synth()) status code (%jd) (..0##)",
+ code);
+ return;
+ }

if (ctx->req == NULL) {
CHECK_OBJ_NOTNULL(ctx->bo, BUSYOBJ_MAGIC);
_______________________________________________
varnish-commit mailing list
varnish-commit@varnish-cache.org
https://www.varnish-cache.org/lists/mailman/listinfo/varnish-commit