[master] 63807dd Make the utils ignore binary and unsafe VSL records.

Poul-Henning Kamp phk at FreeBSD.org
Mon Mar 5 10:09:08 UTC 2018


commit 63807dd22725653e23c20071a9eb958642413f36
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Mon Mar 5 10:07:30 2018 +0000

    Make the utils ignore binary and unsafe VSL records.
    
    This includes the Debug record, if that becomes a problem we will
    deal with it.

diff --git a/bin/varnishhist/varnishhist.c b/bin/varnishhist/varnishhist.c
index 3ba61db..fdc773a 100644
--- a/bin/varnishhist/varnishhist.c
+++ b/bin/varnishhist/varnishhist.c
@@ -258,6 +258,9 @@ accumulate(struct VSL_data *vsl, struct VSL_transaction * const pt[],
 			/* get the value we want and register if it's a hit */
 			tag = VSL_TAG(tr->c->rec.ptr);
 
+			if (VSL_tagflags[tag])
+				continue;
+
 			switch (tag) {
 			case SLT_Hit:
 				hit = 1;
@@ -549,6 +552,11 @@ main(int argc, char **argv)
 				VUT_Error(vut, 1,
 				    "-P: '%s' is not a valid tag name",
 				    optarg);
+			if (VSL_tagflags[match_tag])
+				VUT_Error(vut, 1,
+				    "-P: '%s' is an unsafe or binary record",
+				    optarg);
+
 			cli_p.name = "custom";
 			cli_p.tag = match_tag;
 			profile = NULL;
diff --git a/bin/varnishncsa/varnishncsa.c b/bin/varnishncsa/varnishncsa.c
index 6870ab3..5573407 100644
--- a/bin/varnishncsa/varnishncsa.c
+++ b/bin/varnishncsa/varnishncsa.c
@@ -570,6 +570,9 @@ addf_vsl(enum VSL_tag_e tag, long i, const char *prefix)
 
 	ALLOC_OBJ(w, VSL_WATCH_MAGIC);
 	AN(w);
+	if (VSL_tagflags[tag])
+		VUT_Error(vut, 1, "Tag %s can contain control characters",
+		    VSL_tags[tag]);
 	w->tag = tag;
 	assert(i <= INT_MAX);
 	w->idx = i;
@@ -961,6 +964,9 @@ dispatch_f(struct VSL_data *vsl, struct VSL_transaction * const pt[],
 		skip = 0;
 		while (skip == 0 && 1 == VSL_Next(t->c)) {
 			tag = VSL_TAG(t->c->rec.ptr);
+			if (VSL_tagflags[tag])
+				continue;
+
 			b = VSL_CDATA(t->c->rec.ptr);
 			e = b + VSL_LEN(t->c->rec.ptr);
 			while (e > b && e[-1] == '\0')
diff --git a/bin/varnishtop/varnishtop.c b/bin/varnishtop/varnishtop.c
index c687376..61f0e4d 100644
--- a/bin/varnishtop/varnishtop.c
+++ b/bin/varnishtop/varnishtop.c
@@ -131,9 +131,11 @@ accumulate(struct VSL_data *vsl, struct VSL_transaction * const pt[],
 
 	for (tr = pt[0]; tr != NULL; tr = *++pt) {
 		while ((1 == VSL_Next(tr->c))) {
+			tag = VSL_TAG(tr->c->rec.ptr);
+			if (VSL_tagflags[tag])
+				continue;
 			if (!VSL_Match(vsl, tr->c))
 				continue;
-			tag = VSL_TAG(tr->c->rec.ptr);
 			b = VSL_CDATA(tr->c->rec.ptr);
 			e = b + VSL_LEN(tr->c->rec.ptr);
 			u = 0;
diff --git a/include/vapi/vsl.h b/include/vapi/vsl.h
index b2d7f1c..f91c661 100644
--- a/include/vapi/vsl.h
+++ b/include/vapi/vsl.h
@@ -163,6 +163,9 @@ extern const unsigned VSL_tagflags[SLT__MAX];
 	 * Tag flags array.
 	 * Use these macros with VSL_tagflags (included from vsl_int.h):
 	 *
+	 * VSL_tagflags[tag] & SLT_F_BINARY
+	 *   Non-zero if the payload is binary data
+	 *
 	 * VSL_tagflags[tag] & SLT_F_UNSAFE
 	 *   Non-zero if the payload with this tag may include
 	 *   non-printable characters


More information about the varnish-commit mailing list