| author | |
| committer | |
| log | ec9a44b2a59a9061e1979be5268dd657cd5402fd |
| tree | 9dc2eaa0fd82e58ec83c58c6bcf5c7bc5db1659b |
| parent | abfe7f96dd45e22d43c3e14ed64e1fbb8e94b419 |
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 #88411 files changed, 3 insertions(+), 0 deletions(-)
lib/std/crypto/tlcsprng.zig+3| ... | ... | @@ -150,6 +150,9 @@ fn setupPthreadAtforkAndFill(buffer: []u8) void { |
| 150 | 150 | } |
| 151 | 151 | |
| 152 | 152 | fn 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; | |
| 153 | 156 | std.crypto.utils.secureZero(u8, wipe_mem); |
| 154 | 157 | } |
| 155 | 158 |