Skip to content

zeroize: fix ignored zeroize_c_string test - #1587

Open
bardiharborow wants to merge 3 commits into
RustCrypto:masterfrom
bardiharborow:zeroize-fix-cstring-test
Open

bardiharborow wants to merge 3 commits into
RustCrypto:masterfrom
bardiharborow:zeroize-fix-cstring-test

Conversation

@bardiharborow

Copy link
Copy Markdown

The test read the CString's original buffer after zeroize(), but that buffer may already be freed by then, which is UB. Check the result directly instead, and check the original buffer with the proxy allocator in tests/alloc.rs.

Fixes #774

`ProxyAllocator::dealloc` asserted that the registered allocation was
zeroized, but `GlobalAlloc` methods must not unwind, so a failure
aborted the whole test binary with no diagnostic. Record the failure in
a flag instead, and check it from the test thread in `assert_checked`,
which also checks that the registered allocation was actually freed.

Signed-off-by: Bardi Harborow <bardi@bardiharborow.com>
`REG_PTR` is a global, so tests which register an allocation with it
must not run concurrently. Add a mutex for such tests to hold, in
preparation for adding more of them.

Signed-off-by: Bardi Harborow <bardi@bardiharborow.com>
The test read the CString's original buffer after `zeroize()`, but
that buffer may already be freed by then, which is UB. Replace it with
`cstring_zeroize_test` in `tests/alloc.rs`, which checks the original
buffer with the proxy allocator when it is freed.

Signed-off-by: Bardi Harborow <bardi@bardiharborow.com>
@bardiharborow
bardiharborow force-pushed the zeroize-fix-cstring-test branch from a06e6f9 to ff4b5c6 Compare November 3, 2026 07:23
@bardiharborow
bardiharborow marked this pull request as ready for review November 3, 2026 07:24

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

zeroize: tests::zeroize_c_string fails on i386

1 participant