[master] 86caf8c vrt_hash_blob: fail gracefully for out-of-workspace conditions
Nils Goroll
nils.goroll at uplex.de
Mon Sep 4 20:01:06 CEST 2017
commit 86caf8ca5f34ab1a0b648f1f7c4394f07e81d2d3
Author: Nils Goroll <nils.goroll at uplex.de>
Date: Mon Sep 4 19:21:12 2017 +0200
vrt_hash_blob: fail gracefully for out-of-workspace conditions
No, we do not want to bring back panics for out-of-ws
Ref: #2402
diff --git a/bin/varnishd/cache/cache_vrt_var.c b/bin/varnishd/cache/cache_vrt_var.c
index de52389..0edf6d4 100644
--- a/bin/varnishd/cache/cache_vrt_var.c
+++ b/bin/varnishd/cache/cache_vrt_var.c
@@ -772,11 +772,17 @@ static struct vmod_priv *
vrt_hash_blob(VRT_CTX, uint8_t *digest)
{
struct vmod_priv *p;
+ void *d;
+
p = (void *)WS_Alloc(ctx->ws, sizeof *p);
- AN(p);
+ d = WS_Copy(ctx->ws, digest, DIGEST_LEN);
+ if (p == NULL || d == NULL) {
+ VRT_fail(ctx, "Workspace overflow ((be)req.hash)");
+ return (NULL);
+ }
memset(p, 0, sizeof *p);
p->len = DIGEST_LEN;
- p->priv = WS_Copy(ctx->ws, digest, DIGEST_LEN);
+ p->priv = d;
return (p);
}
More information about the varnish-commit
mailing list