]> err.no Git - varnish/commitdiff
Don't write to read-only structure members in the shared object
authorphk <phk@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Thu, 31 Jul 2008 10:01:36 +0000 (10:01 +0000)
committerphk <phk@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Thu, 31 Jul 2008 10:01:36 +0000 (10:01 +0000)
definition structure.

Fixes ticket 285

git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@3039 d4fa192b-c00b-0410-8231-f00ffab90ce4

varnish-cache/bin/varnishd/cache_vcl.c
varnish-cache/include/vcl.h
varnish-cache/lib/libvcl/vcc_fixed_token.c
varnish-cache/lib/libvcl/vcc_gen_fixed_token.tcl

index a082f8f44058fb471bf3ae7075ecd0a3548af552..ce1b5a9e5c8fe73fda134d48dd3c0cc2bc4f872c 100644 (file)
@@ -53,7 +53,7 @@ struct vcls {
        VTAILQ_ENTRY(vcls)      list;
        char                    *name;
        void                    *dlh;
-       struct VCL_conf         *conf;
+       struct VCL_conf         conf[1];
 };
 
 /*
@@ -131,6 +131,7 @@ static int
 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 @@ VCL_Load(const char *fn, const char *name, struct cli *cli)
                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 @@ VCL_Load(const char *fn, const char *name, struct cli *cli)
                FREE_OBJ(vcl);
                return (1);
        }
-       vcl->conf->priv = vcl;
        REPLACE(vcl->name, name);
        VTAILQ_INSERT_TAIL(&vcl_head, vcl, list);
        LOCK(&vcl_mtx);
index 54745f1a89ebb5060adca60c643bedf444cf3422..f80aed7da94ec99848f32228aeef3b619691e0b6 100644 (file)
@@ -30,8 +30,6 @@ struct VCL_conf {
 
        unsigned        nhashcount;
 
-        void            *priv;
-
         vcl_init_f      *init_func;
         vcl_fini_f      *fini_func;
 
index 6c654659cf22bf5f62959adf7960acd58991c843..00fb1e47b4d4303fffb738b4cc808c7eb878dd40 100644 (file)
@@ -262,8 +262,6 @@ vcl_output_lang_h(struct vsb *sb)
        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");
index bb0771349d3547df9eaddf43ac05020c1cf1e56f..0f10b4a802c4c0b52531211836f39226e0bf720b 100755 (executable)
@@ -143,8 +143,6 @@ puts $fo {  unsigned        magic;
 
        unsigned        nhashcount;
 
-        void            *priv;
-
         vcl_init_f      *init_func;
         vcl_fini_f      *fini_func;
 }