r3039 - in trunk/varnish-cache: bin/varnishd include lib/libvcl

phk at projects.linpro.no phk at projects.linpro.no
Thu Jul 31 12:01:36 CEST 2008


Author: phk
Date: 2008-07-31 12:01:36 +0200 (Thu, 31 Jul 2008)
New Revision: 3039

Modified:
   trunk/varnish-cache/bin/varnishd/cache_vcl.c
   trunk/varnish-cache/include/vcl.h
   trunk/varnish-cache/lib/libvcl/vcc_fixed_token.c
   trunk/varnish-cache/lib/libvcl/vcc_gen_fixed_token.tcl
Log:
Don't write to read-only structure members in the shared object
definition structure.

Fixes ticket 285



Modified: trunk/varnish-cache/bin/varnishd/cache_vcl.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_vcl.c	2008-07-31 09:52:27 UTC (rev 3038)
+++ trunk/varnish-cache/bin/varnishd/cache_vcl.c	2008-07-31 10:01:36 UTC (rev 3039)
@@ -53,7 +53,7 @@
 	VTAILQ_ENTRY(vcls)	list;
 	char			*name;
 	void			*dlh;
-	struct VCL_conf		*conf;
+	struct VCL_conf		conf[1];
 };
 
 /*
@@ -131,6 +131,7 @@
 VCL_Load(const char *fn, const char *name, struct cli *cli)
 {
 	struct vcls *vcl;
+	struct VCL_conf const *cnf;
 
 	ASSERT_CLI();
 	vcl = vcl_find(name);
@@ -149,13 +150,14 @@
 		FREE_OBJ(vcl);
 		return (1);
 	}
-	vcl->conf = dlsym(vcl->dlh, "VCL_conf");
-	if (vcl->conf == NULL) {
-		cli_out(cli, "No VCL_conf symbol\n");
+	cnf = dlsym(vcl->dlh, "VCL_conf");
+	if (cnf == NULL) {
+		cli_out(cli, "Internal error: No VCL_conf symbol\n");
 		(void)dlclose(vcl->dlh);
 		FREE_OBJ(vcl);
 		return (1);
 	}
+	memcpy(vcl->conf, cnf, sizeof *cnf);
 
 	if (vcl->conf->magic != VCL_CONF_MAGIC) {
 		cli_out(cli, "Wrong VCL_CONF_MAGIC\n");
@@ -163,7 +165,6 @@
 		FREE_OBJ(vcl);
 		return (1);
 	}
-	vcl->conf->priv = vcl;
 	REPLACE(vcl->name, name);
 	VTAILQ_INSERT_TAIL(&vcl_head, vcl, list);
 	LOCK(&vcl_mtx);

Modified: trunk/varnish-cache/include/vcl.h
===================================================================
--- trunk/varnish-cache/include/vcl.h	2008-07-31 09:52:27 UTC (rev 3038)
+++ trunk/varnish-cache/include/vcl.h	2008-07-31 10:01:36 UTC (rev 3039)
@@ -30,8 +30,6 @@
 
 	unsigned	nhashcount;
 
-        void            *priv;
-
         vcl_init_f      *init_func;
         vcl_fini_f      *fini_func;
 

Modified: trunk/varnish-cache/lib/libvcl/vcc_fixed_token.c
===================================================================
--- trunk/varnish-cache/lib/libvcl/vcc_fixed_token.c	2008-07-31 09:52:27 UTC (rev 3038)
+++ trunk/varnish-cache/lib/libvcl/vcc_fixed_token.c	2008-07-31 10:01:36 UTC (rev 3039)
@@ -262,8 +262,6 @@
 	vsb_cat(sb, "\n");
 	vsb_cat(sb, "	unsigned	nhashcount;\n");
 	vsb_cat(sb, "\n");
-	vsb_cat(sb, "        void            *priv;\n");
-	vsb_cat(sb, "\n");
 	vsb_cat(sb, "        vcl_init_f      *init_func;\n");
 	vsb_cat(sb, "        vcl_fini_f      *fini_func;\n");
 	vsb_cat(sb, "\n");

Modified: trunk/varnish-cache/lib/libvcl/vcc_gen_fixed_token.tcl
===================================================================
--- trunk/varnish-cache/lib/libvcl/vcc_gen_fixed_token.tcl	2008-07-31 09:52:27 UTC (rev 3038)
+++ trunk/varnish-cache/lib/libvcl/vcc_gen_fixed_token.tcl	2008-07-31 10:01:36 UTC (rev 3039)
@@ -143,8 +143,6 @@
 
 	unsigned	nhashcount;
 
-        void            *priv;
-
         vcl_init_f      *init_func;
         vcl_fini_f      *fini_func;
 }




More information about the varnish-commit mailing list