[5.2] 6568a2a vrt_hash_blob: fail gracefully for out-of-workspace conditions
PÃ¥l Hermunn Johansen
hermunn at varnish-software.com
Thu Sep 7 06:59:05 UTC 2017
commit 6568a2a632493666ef2cad01b80fe8167e5d9f7f
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