[master] 686b530d2 Avoid a potential PRIV_TASK collision in vmod_debug

Dridi Boukelmoune dridi.boukelmoune at gmail.com
Tue Feb 18 13:41:06 UTC 2020


commit 686b530d222465e2b12d5f874bb39a2634be5b46
Author: Dridi Boukelmoune <dridi.boukelmoune at gmail.com>
Date:   Tue Feb 18 14:22:46 2020 +0100

    Avoid a potential PRIV_TASK collision in vmod_debug
    
    You never know what the next test case will look like...

diff --git a/lib/libvmod_debug/vmod.vcc b/lib/libvmod_debug/vmod.vcc
index 5fe13d252..89cc648e4 100644
--- a/lib/libvmod_debug/vmod.vcc
+++ b/lib/libvmod_debug/vmod.vcc
@@ -269,12 +269,12 @@ Set the client socket' send buffer size to *sndbuf*. The previous, desired
 and actual values appear in the logs. Not currently implemented for backend
 transactions.
 
-$Function VOID store_ip(PRIV_TASK, IP)
+$Function VOID store_ip(IP)
 
 Store an IP address to be later found by ``debug.get_ip()`` in the same
 transaction.
 
-$Function IP get_ip(PRIV_TASK)
+$Function IP get_ip()
 
 Get the IP address previously stored by ``debug.store_ip()`` in the same
 transaction.
diff --git a/lib/libvmod_debug/vmod_debug.c b/lib/libvmod_debug/vmod_debug.c
index ddd3b1f1d..12929bbd3 100644
--- a/lib/libvmod_debug/vmod_debug.c
+++ b/lib/libvmod_debug/vmod_debug.c
@@ -922,29 +922,37 @@ xyzzy_sndbuf(VRT_CTX, VCL_BYTES arg)
 }
 
 VCL_VOID
-xyzzy_store_ip(VRT_CTX, struct vmod_priv *priv, VCL_IP ip)
+xyzzy_store_ip(VRT_CTX, VCL_IP ip)
 {
+	struct vmod_priv *priv;
 
 	CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC);
-	AN(priv);
+
+	priv = VRT_priv_task(ctx, xyzzy_store_ip);
+	if (priv == NULL) {
+		VRT_fail(ctx, "no priv task - out of ws?");
+		return;
+	}
+
 	AZ(priv->free);
 	assert(VSA_Sane(ip));
-
 	priv->priv = TRUST_ME(ip);
 }
 
 VCL_IP
-xyzzy_get_ip(VRT_CTX, struct vmod_priv *priv)
+xyzzy_get_ip(VRT_CTX)
 {
+	struct vmod_priv *priv;
 	VCL_IP ip;
 
 	CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC);
+
+	priv = VRT_priv_task(ctx, xyzzy_store_ip);
 	AN(priv);
 	AZ(priv->free);
 
 	ip = priv->priv;
 	assert(VSA_Sane(ip));
-
 	return (ip);
 }
 


More information about the varnish-commit mailing list