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.
parent 6613cca6
...@@ -194,6 +194,7 @@ vmod_workspace_reserve(VRT_CTX, VCL_ENUM which, VCL_INT size) ...@@ -194,6 +194,7 @@ vmod_workspace_reserve(VRT_CTX, VCL_ENUM which, VCL_INT size)
r = WS_ReserveSize(ws, size); r = WS_ReserveSize(ws, size);
if (r == 0) if (r == 0)
return (0); return (0);
memset(WS_Reservation(ws), 0, r);
WS_Release(ws, 0); WS_Release(ws, 0);
return (r); return (r);
} }
......
...@@ -101,8 +101,8 @@ architecture. A failed allocation fails the transaction. ...@@ -101,8 +101,8 @@ architecture. A failed allocation fails the transaction.
$Function BYTES workspace_reserve(ENUM { client, backend, session, thread }, $Function BYTES workspace_reserve(ENUM { client, backend, session, thread },
INT size) INT size)
Attempt to reserve *size* bytes and release the reservation right Attempt to reserve *size* bytes, zero out that memory and release the
away. Return the size of the reservation. reservation right away. Return the size of the reservation.
See `vtc.workspace_alloc()`_ for semantics of the *size* argument. See `vtc.workspace_alloc()`_ for semantics of the *size* argument.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment