[master] 4e1788a7d VRT_TIME_string to trigger VCL failure for unformatable time
Nils Goroll
nils.goroll at uplex.de
Fri Apr 30 20:26:09 UTC 2021
commit 4e1788a7d612fd2c6f8c4279c4bcc8dc31b6f041
Author: Nils Goroll <nils.goroll at uplex.de>
Date: Fri Apr 30 21:25:13 2021 +0200
VRT_TIME_string to trigger VCL failure for unformatable time
as per pow-wow decision
Ref #3308
diff --git a/bin/varnishd/cache/cache_vrt.c b/bin/varnishd/cache/cache_vrt.c
index b87dae091..59ebaf697 100644
--- a/bin/varnishd/cache/cache_vrt.c
+++ b/bin/varnishd/cache/cache_vrt.c
@@ -837,17 +837,17 @@ VCL_STRING v_matchproto_()
VRT_TIME_string(VRT_CTX, VCL_TIME t)
{
char *p;
- uintptr_t snapshot;
CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC);
- snapshot = WS_Snapshot(ctx->ws);
p = WS_Alloc(ctx->ws, VTIM_FORMAT_SIZE);
- if (p != NULL) {
- VTIM_format(t, p);
- if (*p == '\0') {
- p = NULL;
- WS_Reset(ctx->ws, snapshot);
- }
+ if (p == NULL) {
+ VRT_fail(ctx, "Workspace overflow");
+ return (NULL);
+ }
+ VTIM_format(t, p);
+ if (*p == '\0') {
+ VRT_fail(ctx, "Unformatable VCL_TIME");
+ return (NULL);
}
return (p);
}
diff --git a/bin/varnishtest/tests/r03308.vtc b/bin/varnishtest/tests/r03308.vtc
index a97cb0cd5..f5cfaa8a1 100644
--- a/bin/varnishtest/tests/r03308.vtc
+++ b/bin/varnishtest/tests/r03308.vtc
@@ -16,5 +16,5 @@ varnish v1 -vcl+backend {
client c1 {
txreq
rxresp
- expect resp.http.ts == ""
+ expect resp.status == 503
} -run
More information about the varnish-commit
mailing list