summaryrefslogtreecommitdiffstats
path: root/usr.sbin/jail
diff options
context:
space:
mode:
authorhrs <hrs@FreeBSD.org>2015-07-08 00:51:53 +0000
committerhrs <hrs@FreeBSD.org>2015-07-08 00:51:53 +0000
commit3c6c216f16bc709c4ec041197fc43da17b24d02d (patch)
tree793949a3ee9cde5c77de5d6bfbbb2234921df17e /usr.sbin/jail
parent46b57cf01fac6726cd7e5fe17a69dee66f631ac8 (diff)
downloadFreeBSD-src-3c6c216f16bc709c4ec041197fc43da17b24d02d.zip
FreeBSD-src-3c6c216f16bc709c4ec041197fc43da17b24d02d.tar.gz
Fix offset calculation in variable substitution
in jail.conf. The following did not work correctly: A="A_${B}_C_${D}" B="BBBBB" D="DDDD_${E}_FFFFF" E="EEEEE" PR: 189139 Reviewed by: jamie Differential Revision: https://reviews.freebsd.org/D3018
Diffstat (limited to 'usr.sbin/jail')
-rw-r--r--usr.sbin/jail/config.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/usr.sbin/jail/config.c b/usr.sbin/jail/config.c
index 5820209..1dd04498 100644
--- a/usr.sbin/jail/config.c
+++ b/usr.sbin/jail/config.c
@@ -130,9 +130,8 @@ load_config(void)
struct cfjail *j, *tj, *wj;
struct cfparam *p, *vp, *tp;
struct cfstring *s, *vs, *ns;
- struct cfvar *v;
+ struct cfvar *v, *vv;
char *ep;
- size_t varoff;
int did_self, jseq, pgen;
if (!strcmp(cfname, "-")) {
@@ -191,7 +190,6 @@ load_config(void)
p->gen = ++pgen;
find_vars:
TAILQ_FOREACH(s, &p->val, tq) {
- varoff = 0;
while ((v = STAILQ_FIRST(&s->vars))) {
TAILQ_FOREACH(vp, &j->params, tq)
if (!strcmp(vp->name, v->name))
@@ -233,11 +231,13 @@ load_config(void)
goto bad_var;
}
s->s = erealloc(s->s, s->len + vs->len + 1);
- memmove(s->s + v->pos + varoff + vs->len,
- s->s + v->pos + varoff,
- s->len - (v->pos + varoff) + 1);
- memcpy(s->s + v->pos + varoff, vs->s, vs->len);
- varoff += vs->len;
+ memmove(s->s + v->pos + vs->len,
+ s->s + v->pos,
+ s->len - v->pos + 1);
+ memcpy(s->s + v->pos, vs->s, vs->len);
+ vv = v;
+ while ((vv = STAILQ_NEXT(vv, tq)))
+ vv->pos += vs->len;
s->len += vs->len;
while ((vs = TAILQ_NEXT(vs, tq))) {
ns = emalloc(sizeof(struct cfstring));
OpenPOWER on IntegriCloud