[master] c23ef4c3d Avoid panic in VRT_CacheReqBody if called from outside vcl_recv {}

Nils Goroll nils.goroll at uplex.de
Fri Jun 24 14:49:02 UTC 2022


commit c23ef4c3d874871061792add005fdfda9912db43
Author: Nils Goroll <nils.goroll at uplex.de>
Date:   Fri Jun 24 16:42:03 2022 +0200

    Avoid panic in VRT_CacheReqBody if called from outside vcl_recv {}

diff --git a/bin/varnishd/cache/cache_vrt.c b/bin/varnishd/cache/cache_vrt.c
index bd856193c..ef43a3ade 100644
--- a/bin/varnishd/cache/cache_vrt.c
+++ b/bin/varnishd/cache/cache_vrt.c
@@ -973,12 +973,12 @@ VRT_CacheReqBody(VRT_CTX, VCL_BYTES maxsize)
 {
 
 	CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC);
-	CHECK_OBJ_NOTNULL(ctx->req, REQ_MAGIC);
 	if (ctx->method != VCL_MET_RECV) {
 		VSLb(ctx->vsl, SLT_VCL_Error,
 		    "req.body can only be cached in vcl_recv{}");
 		return (-1);
 	}
+	CHECK_OBJ_NOTNULL(ctx->req, REQ_MAGIC);
 	return (VRB_Cache(ctx->req, maxsize));
 }
 


More information about the varnish-commit mailing list