[master] 9170b2e vcc: Fix null pointer dereference if symbol lacks constructor information

Nils Goroll nils.goroll at uplex.de
Mon Nov 20 22:57:07 UTC 2017


commit 9170b2e81332eec34f2bb071b39a8976fefda7f6
Author: Nils Goroll <nils.goroll at uplex.de>
Date:   Mon Nov 20 23:12:54 2017 +0100

    vcc: Fix null pointer dereference if symbol lacks constructor information
    
    This issue is hidden by the fix in the previous commits, so we cannot test
    for it directly any more. Applying this patch to
    fa3884391f85565cb7d564cfa5f22d066948d7bc exposes the "Constructor not found".
    
    Fixes #2498

diff --git a/bin/varnishtest/tests/v00016.vtc b/bin/varnishtest/tests/v00016.vtc
index 798beae..0f9a4c8 100644
--- a/bin/varnishtest/tests/v00016.vtc
+++ b/bin/varnishtest/tests/v00016.vtc
@@ -102,3 +102,14 @@ varnish v1 -errvcl {Undefined acl foo} {
 		}
 	}
 }
+
+varnish v1 -errvcl {Symbol not found: 'foo'} {
+	backend b { .host = "127.0.0.1"; }
+
+	acl foo {
+	    "127.0.0.1"/32;
+	}
+	sub vcl_init {
+		new bar = foo;
+	}
+}
diff --git a/lib/libvcc/vcc_vmod.c b/lib/libvcc/vcc_vmod.c
index 92d63fd..7553b16 100644
--- a/lib/libvcc/vcc_vmod.c
+++ b/lib/libvcc/vcc_vmod.c
@@ -291,8 +291,12 @@ vcc_ParseNew(struct vcc *tl)
 
 	ExpectErr(tl, ID);
 	sy2 = VCC_SymbolTok(tl, NULL, tl->t, SYM_OBJECT, 0);
-	if (sy2 == NULL) {
-		VSB_printf(tl->sb, "Symbol not found: ");
+	if (sy2 == NULL || sy2->extra == NULL) {
+		if (sy2 == NULL)
+			p = "Symbol";
+		else if (sy2->extra == NULL)
+			p = "Constructor";
+		VSB_printf(tl->sb, "%s not found: ", p);
 		vcc_ErrToken(tl, tl->t);
 		VSB_printf(tl->sb, " at ");
 		vcc_ErrWhere(tl, tl->t);
@@ -301,6 +305,7 @@ vcc_ParseNew(struct vcc *tl)
 	vcc_NextToken(tl);
 
 	p = sy2->extra;
+	AN(p);
 
 	s_obj = p;
 	p += strlen(p) + 1;


More information about the varnish-commit mailing list