From 6348719003897152d9d2dc1a4c18fa86cc36c84c Mon Sep 17 00:00:00 2001 From: Carlos Abalde Date: Tue, 17 Sep 2024 14:20:28 +0200 Subject: [PATCH] Abort 'vcl_init' asap if a VMOD object instance cannot be created. See https://varnish-cache.org/lists/pipermail/varnish-dev/2024-September/009853.html & 721aa22be9265f8a6fd2b0593c491d50151cdb7f --- src/helpers.h | 3 +++ src/vmod_cfg_file.c | 4 ++++ src/vmod_cfg_rules.c | 4 ++++ src/vmod_cfg_script.c | 4 ++++ 4 files changed, 15 insertions(+) diff --git a/src/helpers.h b/src/helpers.h index d850851..876a353 100644 --- a/src/helpers.h +++ b/src/helpers.h @@ -44,4 +44,7 @@ extern vmod_state_t vmod_state; #define FAIL_WS(ctx, result) \ FAIL(ctx, result, "Workspace overflow") +#define FAIL_INSTANCE(ctx, result) \ + FAIL(ctx, result, "Failed to create instance") + #endif diff --git a/src/vmod_cfg_file.c b/src/vmod_cfg_file.c index 5a33ae4..c191e2e 100644 --- a/src/vmod_cfg_file.c +++ b/src/vmod_cfg_file.c @@ -358,6 +358,10 @@ vmod_file__init( } } + if (instance == NULL) { + FAIL_INSTANCE(ctx,); + } + *file = instance; } diff --git a/src/vmod_cfg_rules.c b/src/vmod_cfg_rules.c index 10027d2..383ba51 100644 --- a/src/vmod_cfg_rules.c +++ b/src/vmod_cfg_rules.c @@ -265,6 +265,10 @@ vmod_rules__init( } } + if (instance == NULL) { + FAIL_INSTANCE(ctx,); + } + *rules = instance; } diff --git a/src/vmod_cfg_script.c b/src/vmod_cfg_script.c index fba32ca..5add701 100644 --- a/src/vmod_cfg_script.c +++ b/src/vmod_cfg_script.c @@ -151,6 +151,10 @@ vmod_script__init( } } + if (instance == NULL) { + FAIL_INSTANCE(ctx,); + } + *script = instance; }