Skip to content

Commit

Permalink
vcc: Fix null pointer dereference if symbol lacks constructor informa…
Browse files Browse the repository at this point in the history
…tion

This issue is hidden by the fix in the previous commits, so we cannot test
for it directly any more. Applying this patch to
fa38843 exposes the "Constructor not found".

Fixes #2498
  • Loading branch information
nigoroll committed Nov 20, 2017
1 parent 0c7067a commit 9170b2e
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
11 changes: 11 additions & 0 deletions bin/varnishtest/tests/v00016.vtc
Expand Up @@ -102,3 +102,14 @@ varnish v1 -errvcl {Undefined acl foo} {
}
}
}

varnish v1 -errvcl {Symbol not found: 'foo'} {
backend b { .host = "127.0.0.1"; }

acl foo {
"127.0.0.1"/32;
}
sub vcl_init {
new bar = foo;
}
}
9 changes: 7 additions & 2 deletions lib/libvcc/vcc_vmod.c
Expand Up @@ -291,8 +291,12 @@ vcc_ParseNew(struct vcc *tl)

ExpectErr(tl, ID);
sy2 = VCC_SymbolTok(tl, NULL, tl->t, SYM_OBJECT, 0);
if (sy2 == NULL) {
VSB_printf(tl->sb, "Symbol not found: ");
if (sy2 == NULL || sy2->extra == NULL) {
if (sy2 == NULL)
p = "Symbol";
else if (sy2->extra == NULL)
p = "Constructor";
VSB_printf(tl->sb, "%s not found: ", p);
vcc_ErrToken(tl, tl->t);
VSB_printf(tl->sb, " at ");
vcc_ErrWhere(tl, tl->t);
Expand All @@ -301,6 +305,7 @@ vcc_ParseNew(struct vcc *tl)
vcc_NextToken(tl);

p = sy2->extra;
AN(p);

s_obj = p;
p += strlen(p) + 1;
Expand Down

0 comments on commit 9170b2e

Please sign in to comment.