[4.1] 440e2f1 Don't panic on a null ban
PÃ¥l Hermunn Johansen
hermunn at varnish-software.com
Wed Jun 28 10:17:05 CEST 2017
commit 440e2f1a899c75537c5fac000293c2a8af9afc19
Author: Nils Goroll <nils.goroll at uplex.de>
Date: Mon Jun 26 18:01:33 2017 +0200
Don't panic on a null ban
like ban(req.http.non-existing-header)
diff --git a/bin/varnishd/cache/cache_vrt.c b/bin/varnishd/cache/cache_vrt.c
index a73489b..678d8aa 100644
--- a/bin/varnishd/cache/cache_vrt.c
+++ b/bin/varnishd/cache/cache_vrt.c
@@ -416,7 +416,11 @@ VRT_ban_string(VRT_CTX, const char *str)
CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC);
AN(ctx->vsl);
- AN(str);
+
+ if (str == NULL) {
+ VSLb(ctx->vsl, SLT_VCL_Error, "ban(): Null argument");
+ return;
+ }
bp = BAN_Build();
if (bp == NULL) {
diff --git a/bin/varnishtest/tests/v00011.vtc b/bin/varnishtest/tests/v00011.vtc
index 0f470ec..ea79b64 100644
--- a/bin/varnishtest/tests/v00011.vtc
+++ b/bin/varnishtest/tests/v00011.vtc
@@ -11,6 +11,7 @@ server s1 {
varnish v1 -vcl+backend {
sub vcl_recv {
if (req.method == "PURGE") {
+ ban(req.http.doesntexist);
ban("");
ban("req.url");
ban("req.url //");
@@ -31,6 +32,7 @@ client c1 {
} -run
logexpect l1 -v v1 -d 1 -g vxid {
+ expect * 1004 VCL_Error {ban[(][)]: Null argument}
expect * 1004 VCL_Error {ban[(][)]: No ban conditions found[.]}
expect * 1004 VCL_Error {ban[(][)]: Expected comparison operator[.]}
expect * 1004 VCL_Error {ban[(][)]: Expected second operand[.]}
More information about the varnish-commit
mailing list