authorgravatar for thatlemon@gmail.comLemonBoy <thatlemon@gmail.com> 2021-05-20 15:28:59+02:00
committergravatar for thatlemon@gmail.comLemonBoy <thatlemon@gmail.com> 2021-05-20 15:28:59+02:00
logec9a44b2a59a9061e1979be5268dd657cd5402fd
tree9dc2eaa0fd82e58ec83c58c6bcf5c7bc5db1659b
parentabfe7f96dd45e22d43c3e14ed64e1fbb8e94b419

std: Make atfork handler more robust

The atfork handler is executed even when fork()-ing threads that have never initialized their local csprng. Handle this case gracefully instead of raising a runtime error. Fixes #8841

1 files changed, 3 insertions(+), 0 deletions(-)

lib/std/crypto/tlcsprng.zig+3
......@@ -150,6 +150,9 @@ fn setupPthreadAtforkAndFill(buffer: []u8) void {
150150}
151151
152152fn childAtForkHandler() callconv(.C) void {
153 // The atfork handler is global, this function may be called after
154 // fork()-ing threads that never initialized the CSPRNG context.
155 if (wipe_mem.len == 0) return;
153156 std.crypto.utils.secureZero(u8, wipe_mem);
154157}
155158