[master] 6b6969a Don't panic on a null ban
Nils Goroll
nils.goroll at uplex.de
Mon Jun 26 19:09:05 CEST 2017
commit 6b6969aa542023aed36b6de0a52745210fc702b5
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 3e88844..e1e521b 100644
--- a/bin/varnishd/cache/cache_vrt.c
+++ b/bin/varnishd/cache/cache_vrt.c
@@ -457,7 +457,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