Commit 3feafcac authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Don't write to read-only structure members in the shared object

definition structure.

Fixes ticket 285



git-svn-id: http://www.varnish-cache.org/svn/trunk@3039 d4fa192b-c00b-0410-8231-f00ffab90ce4
parent 88962750
......@@ -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);
......
......@@ -30,8 +30,6 @@ struct VCL_conf {
unsigned nhashcount;
void *priv;
vcl_init_f *init_func;
vcl_fini_f *fini_func;
......
......@@ -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");
......
......@@ -143,8 +143,6 @@ puts $fo { unsigned magic;
unsigned nhashcount;
void *priv;
vcl_init_f *init_func;
vcl_fini_f *fini_func;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment