[master] ddd9f277e Use VSBs to generate code for VMOD objects.
Geoff Simmons
geoff at uplex.de
Fri Jan 11 11:16:07 UTC 2019
commit ddd9f277e7c2388c4b991f9ddc8f8619d8c2bbad
Author: Geoff Simmons <geoff at uplex.de>
Date: Fri Jan 11 11:42:16 2019 +0100
Use VSBs to generate code for VMOD objects.
Fixes #2880
diff --git a/bin/varnishtest/tests/r02880.vtc b/bin/varnishtest/tests/r02880.vtc
new file mode 100644
index 000000000..1d554230b
--- /dev/null
+++ b/bin/varnishtest/tests/r02880.vtc
@@ -0,0 +1,13 @@
+varnishtest "Long VMOD object names"
+
+varnish v1 -vcl {
+ import debug;
+ backend b { .host = "${bad_ip}"; }
+
+ sub vcl_init {
+ new l234567890123456789012345678901234567890123456789012345678
+ = debug.obj();
+ new l2345678901234567890123456789012345678901234567890123456789
+ = debug.obj();
+ }
+}
diff --git a/lib/libvcc/vcc_vmod.c b/lib/libvcc/vcc_vmod.c
index babd70eef..9fe6ddddf 100644
--- a/lib/libvcc/vcc_vmod.c
+++ b/lib/libvcc/vcc_vmod.c
@@ -38,6 +38,7 @@
#include "vfil.h"
#include "vjsn.h"
#include "vmod_abi.h"
+#include "vsb.h"
static int
vcc_path_dlopen(void *priv, const char *fn)
@@ -349,8 +350,7 @@ vcc_Act_New(struct vcc *tl, struct token *t, struct symbol *sym)
{
struct symbol *sy1, *sy2, *sy3;
struct inifin *ifp;
- char buf1[128];
- char buf2[128];
+ struct vsb *buf;
const struct vjsn_val *vv, *vf;
const char *p;
@@ -393,8 +393,10 @@ vcc_Act_New(struct vcc *tl, struct token *t, struct symbol *sym)
vf = VTAILQ_NEXT(vf, list);
- bprintf(buf1, ", &%s, \"%s\"", sy1->rname, sy1->name);
- vcc_Eval_Func(tl, vf, buf1, sy2);
+ buf = VSB_new_auto();
+ VSB_printf(buf, ", &%s, \"%s\"", sy1->rname, sy1->name);
+ VSB_finish(buf);
+ vcc_Eval_Func(tl, vf, VSB_data(buf), sy2);
ERRCHK(tl);
SkipToken(tl, ';');
sy1->def_e = tl->t;
@@ -411,8 +413,10 @@ vcc_Act_New(struct vcc *tl, struct token *t, struct symbol *sym)
VSB_printf(ifp->fin, "\t\t%s(&%s);", vf->value, sy1->rname);
/* Instantiate symbols for the methods */
- bprintf(buf1, ", %s", sy1->rname);
- p = TlDup(tl, buf1);
+ VSB_clear(buf);
+ VSB_printf(buf, ", %s", sy1->rname);
+ VSB_finish(buf);
+ p = TlDup(tl, VSB_data(buf));
while (vv != NULL) {
vf = VTAILQ_FIRST(&vv->children);
assert(vf->type == VJSN_STRING);
@@ -420,11 +424,14 @@ vcc_Act_New(struct vcc *tl, struct token *t, struct symbol *sym)
vf = VTAILQ_NEXT(vf, list);
assert(vf->type == VJSN_STRING);
- bprintf(buf2, "%s.%s", sy1->name, vf->value);
- sy3 = VCC_MkSym(tl, buf2, SYM_FUNC, VCL_LOW, VCL_HIGH);
+ VSB_clear(buf);
+ VSB_printf(buf, "%s.%s", sy1->name, vf->value);
+ VSB_finish(buf);
+ sy3 = VCC_MkSym(tl, VSB_data(buf), SYM_FUNC, VCL_LOW, VCL_HIGH);
AN(sy3);
func_sym(sy3, sy2->vmod, VTAILQ_NEXT(vf, list));
sy3->extra = p;
vv = VTAILQ_NEXT(vv, list);
}
+ VSB_destroy(&buf);
}
More information about the varnish-commit
mailing list