[master] 2b4ed68c8 vtc.workspace_reserve() zero memory like vtc.workspace_alloc()

Nils Goroll nils.goroll at uplex.de
Tue Dec 14 07:46:05 UTC 2021


commit 2b4ed68c847d03e5c337933131d9bd972069b3b2
Author: Nils Goroll <nils.goroll at uplex.de>
Date:   Tue Dec 14 08:07:26 2021 +0100

    vtc.workspace_reserve() zero memory like vtc.workspace_alloc()
    
    This is useful to ensure that workspace does not, by chance or
    accident, contain data and, in particular, magic numbers from
    previous workspace use.

diff --git a/vmod/vmod_vtc.c b/vmod/vmod_vtc.c
index 7c09e79c3..31412c06c 100644
--- a/vmod/vmod_vtc.c
+++ b/vmod/vmod_vtc.c
@@ -194,6 +194,7 @@ vmod_workspace_reserve(VRT_CTX, VCL_ENUM which, VCL_INT size)
 	r = WS_ReserveSize(ws, size);
 	if (r == 0)
 		return (0);
+	memset(WS_Reservation(ws), 0, r);
 	WS_Release(ws, 0);
 	return (r);
 }
diff --git a/vmod/vmod_vtc.vcc b/vmod/vmod_vtc.vcc
index 17a823f2c..833a163a4 100644
--- a/vmod/vmod_vtc.vcc
+++ b/vmod/vmod_vtc.vcc
@@ -101,8 +101,8 @@ architecture. A failed allocation fails the transaction.
 $Function BYTES workspace_reserve(ENUM { client, backend, session, thread },
 	INT size)
 
-Attempt to reserve *size* bytes and release the reservation right
-away. Return the size of the reservation.
+Attempt to reserve *size* bytes, zero out that memory and release the
+reservation right away. Return the size of the reservation.
 
 See `vtc.workspace_alloc()`_ for semantics of the *size* argument.
 


More information about the varnish-commit mailing list