Skip to content

Commit

Permalink
vmod-var: check name for NULL in global_get
Browse files Browse the repository at this point in the history
Signed-off-by: Asad Sajjad Ahmed <asadsa@varnish-software.com>
  • Loading branch information
asadsa92 authored and gquintard committed Nov 20, 2021
1 parent fe41c48 commit c86bfd0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/tests/var/test02.vtc
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ varnish v1 -vcl+backend {
var.global_set("bar", "altered_barval");
}

sub vcl_recv {
var.global_get(req.http.NULL);
}

sub vcl_deliver {
set resp.http.x-foo = var.global_get("foo");
set resp.http.x-bar = var.global_get("bar");
Expand Down
3 changes: 3 additions & 0 deletions src/vmod_var.c
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,9 @@ vmod_global_get(const struct vrt_ctx *ctx, VCL_STRING name)
struct var *v;
const char *r = NULL;

if (!name)
return (NULL);

AZ(pthread_mutex_lock(&var_list_mtx));
VTAILQ_FOREACH(v, &global_vars, list) {
CHECK_OBJ_NOTNULL(v, VAR_MAGIC);
Expand Down

0 comments on commit c86bfd0

Please sign in to comment.