[master] 6b27b8c Prefix the C-symbol of VCL objects with "vo_" to avoid issues with reserved C keywords.
Poul-Henning Kamp
phk at FreeBSD.org
Mon May 12 09:55:10 CEST 2014
commit 6b27b8c35c090df1dd61eead77184ac98e402f1f
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date: Mon May 12 07:54:30 2014 +0000
Prefix the C-symbol of VCL objects with "vo_" to avoid issues with
reserved C keywords.
Fixes #1498
diff --git a/bin/varnishtest/tests/r01498.vtc b/bin/varnishtest/tests/r01498.vtc
new file mode 100644
index 0000000..d321448
--- /dev/null
+++ b/bin/varnishtest/tests/r01498.vtc
@@ -0,0 +1,18 @@
+varnishtest "backend name VCC crash"
+
+varnish v1 -vcl {
+ vcl 4.0;
+ import ${vmod_directors};
+ backend s1 {
+ .host = "127.0.0.1";
+ .port = "80";
+ }
+ sub vcl_init {
+ new static = directors.random();
+ static.add_backend(s1, 100.0);
+ }
+
+ sub vcl_backend_fetch {
+ set bereq.backend = static.backend();
+ }
+}
diff --git a/lib/libvcc/vcc_action.c b/lib/libvcc/vcc_action.c
index 84724c1..b06ff3d 100644
--- a/lib/libvcc/vcc_action.c
+++ b/lib/libvcc/vcc_action.c
@@ -200,17 +200,17 @@ parse_new(struct vcc *tl)
p++;
p += 2;
- Fh(tl, 0, "static %s *%s;\n\n", s_struct, sy1->name);
+ Fh(tl, 0, "static %s *vo_%s;\n\n", s_struct, sy1->name);
vcc_NextToken(tl);
- bprintf(buf1, ", &%s, \"%s\"", sy1->name, sy1->name);
+ bprintf(buf1, ", &vo_%s, \"%s\"", sy1->name, sy1->name);
vcc_Eval_Func(tl, s_init, buf1, "ASDF", s_init + strlen(s_init) + 1);
ifp = New_IniFin(tl);
- VSB_printf(ifp->fin, "\t%s(&%s);", s_fini, sy1->name);
+ VSB_printf(ifp->fin, "\t%s(&vo_%s);", s_fini, sy1->name);
ExpectErr(tl, ';');
- bprintf(buf1, ", %s", sy1->name);
+ bprintf(buf1, ", vo_%s", sy1->name);
/* Split the methods from the args */
while (*p != '\0') {
p += strlen(s_obj);
More information about the varnish-commit
mailing list