[master] 84a2903 Correct ENUM handling in object constructors
Federico G. Schwindt
fgsch at lodoss.net
Sat Jan 23 10:17:51 CET 2016
commit 84a2903805580973c59635bacb99df5da901c02c
Author: Federico G. Schwindt <fgsch at lodoss.net>
Date: Sat Jan 23 09:09:29 2016 +0000
Correct ENUM handling in object constructors
Discussed with phk at . Fix confirmed by geoff at .
Fixes #1844.
diff --git a/lib/libvcc/vcc_action.c b/lib/libvcc/vcc_action.c
index 41eac6b..790efea 100644
--- a/lib/libvcc/vcc_action.c
+++ b/lib/libvcc/vcc_action.c
@@ -203,9 +203,14 @@ parse_new(struct vcc *tl)
s_obj = p;
p += strlen(p) + 1;
s_init = p;
- while (p[0] != '\0' || p[1] != '\0')
+ /*
+ * Check for the end marked (\0\0) followed by s(truct) to avoid
+ * matching an ENUM half-way through and generating illegal C code.
+ */
+ while (p[0] != '\0' || p[1] != '\0' || p[2] != 's')
p++;
p += 2;
+ AZ(strncmp(p, "struct vmod_", 12));
s_struct = p;
p += strlen(p) + 1;
s_fini = p + strlen(p) + 1;
diff --git a/lib/libvmod_debug/vmod.vcc b/lib/libvmod_debug/vmod.vcc
index 74c8c12..9218b5e 100644
--- a/lib/libvmod_debug/vmod.vcc
+++ b/lib/libvmod_debug/vmod.vcc
@@ -71,7 +71,7 @@ $Function BACKEND no_backend()
Fails at backend selection
-$Object obj(STRING)
+$Object obj(STRING, ENUM { one, two, three } number="one")
Test object
diff --git a/lib/libvmod_debug/vmod_debug_obj.c b/lib/libvmod_debug/vmod_debug_obj.c
index 0b9c248..2511f9a 100644
--- a/lib/libvmod_debug/vmod_debug_obj.c
+++ b/lib/libvmod_debug/vmod_debug_obj.c
@@ -43,13 +43,14 @@ struct vmod_debug_obj {
VCL_VOID
vmod_obj__init(VRT_CTX, struct vmod_debug_obj **op,
- const char *vcl_name, VCL_STRING s)
+ const char *vcl_name, VCL_STRING s, VCL_ENUM e)
{
struct vmod_debug_obj *o;
CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC);
(void)vcl_name;
(void)s;
+ (void)e;
AN(op);
AZ(*op);
ALLOC_OBJ(o, VMOD_DEBUG_OBJ_MAGIC);
More information about the varnish-commit
mailing list