-
Notifications
You must be signed in to change notification settings - Fork 138
Add unsafe test to check that dropped values are zeroized #1180
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
zeroize/tests/zeroize.rs
Outdated
bytes | ||
); | ||
} | ||
// Check that the memory is cleared after the scope ends |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can use drop_in_place
to invoke the drop handler (see other tests in the same module)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I saw those tests but felt that, given how magic drop_in_place
is, readers would likely be mroe familiar with a plain old scope ending. Do you disagree?
I guess the original question still stands: is something like this acceptable? I'm on the fence myself, hence the draft. |
Personally, while I am fine with having such test, I don't see much worth in it. I will leave the final decision to @tarcieri. As a small suggestion, it may be worth to slightly modify how the test is implemented. Instead of reading leaked memory in the test itself, it may be better to allocate a known size (e.g. 1024 bytes) using |
Test that zeroization actually occurs when a boxed value goes out of scope.
Uses unsafe code, likely relies on UB and adds a custom allocator, hence the draft: is something like this acceptable?
c.f. iqlusioninc/crates#1310