From f84714e0b2a77ec3653466d25bbbc6d35d08a721 Mon Sep 17 00:00:00 2001 From: phk Date: Thu, 31 Jul 2008 10:01:36 +0000 Subject: [PATCH] Don't write to read-only structure members in the shared object 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 | 11 ++++++----- varnish-cache/include/vcl.h | 2 -- varnish-cache/lib/libvcl/vcc_fixed_token.c | 2 -- varnish-cache/lib/libvcl/vcc_gen_fixed_token.tcl | 2 -- 4 files changed, 6 insertions(+), 11 deletions(-) diff --git a/varnish-cache/bin/varnishd/cache_vcl.c b/varnish-cache/bin/varnishd/cache_vcl.c index a082f8f4..ce1b5a9e 100644 --- a/varnish-cache/bin/varnishd/cache_vcl.c +++ b/varnish-cache/bin/varnishd/cache_vcl.c @@ -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); diff --git a/varnish-cache/include/vcl.h b/varnish-cache/include/vcl.h index 54745f1a..f80aed7d 100644 --- a/varnish-cache/include/vcl.h +++ b/varnish-cache/include/vcl.h @@ -30,8 +30,6 @@ struct VCL_conf { unsigned nhashcount; - void *priv; - vcl_init_f *init_func; vcl_fini_f *fini_func; diff --git a/varnish-cache/lib/libvcl/vcc_fixed_token.c b/varnish-cache/lib/libvcl/vcc_fixed_token.c index 6c654659..00fb1e47 100644 --- a/varnish-cache/lib/libvcl/vcc_fixed_token.c +++ b/varnish-cache/lib/libvcl/vcc_fixed_token.c @@ -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"); diff --git a/varnish-cache/lib/libvcl/vcc_gen_fixed_token.tcl b/varnish-cache/lib/libvcl/vcc_gen_fixed_token.tcl index bb077134..0f10b4a8 100755 --- a/varnish-cache/lib/libvcl/vcc_gen_fixed_token.tcl +++ b/varnish-cache/lib/libvcl/vcc_gen_fixed_token.tcl @@ -143,8 +143,6 @@ puts $fo { unsigned magic; unsigned nhashcount; - void *priv; - vcl_init_f *init_func; vcl_fini_f *fini_func; } -- 2.39.5