Skip to content

Commit

Permalink
VCC: Fix +glob with relative paths
Browse files Browse the repository at this point in the history
We preivously called glob() on the included file name regardless of whether it
was an absolute or relative path. As a result, relative paths were not appended
to vcl_path elements before checking if the glob expression matched anything.

It is not possible to (re)use VFIL_searchpath here, since VFIL_searchpath uses
access() to check that the file exists, and that would fail in this case.

Fixes: varnishcache#4249
  • Loading branch information
walid-git committed Jan 7, 2025
1 parent cbeeea5 commit 0753f6f
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions lib/libvcc/vcc_source.c
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,24 @@ vcc_include_glob_file(struct vcc *tl, const struct source *src_sp,
const char *filename, const struct token *parent_token)
{
glob_t g[1];
char **paths, **p;
unsigned u;
int i;

if (filename[0] != '/') {
paths = VFIL_concat(tl->vcl_path, filename);
p = paths;
while (*p != NULL) {
assert(*p[0] == '/');
vcc_include_glob_file(tl, src_sp, *p, parent_token);
free(*p);
*p = NULL;
p++;
}
free(paths);
return;
}

memset(g, 0, sizeof g);
i = glob(filename, 0, NULL, g);
switch (i) {
Expand Down

0 comments on commit 0753f6f

Please sign in to comment.