Replace call to drop with zeroization.

Signed-off-by: Daira Hopwood <daira@jacaranda.org>
(cherry picked from commit 0e073a53ee)
This commit is contained in:
Daira Hopwood 2022-01-10 02:39:25 +00:00
parent cfa4590c75
commit 619a9a1d47
3 changed files with 6 additions and 1 deletions

1
Cargo.lock generated
View File

@ -815,6 +815,7 @@ dependencies = [
"zcash_note_encryption",
"zcash_primitives",
"zcash_proofs",
"zeroize",
]
[[package]]

View File

@ -49,6 +49,7 @@ zcash_note_encryption = "0.1"
zcash_primitives = "0.5"
zcash_proofs = "0.5"
ed25519-zebra = "3"
zeroize = "1.4.2"
# Metrics
hyper = { version = "=0.14.2", default-features = false, features = ["server", "tcp", "http1"] }

View File

@ -4,6 +4,7 @@ use std::{
ffi::{CStr, CString},
ptr, slice,
};
use zeroize::Zeroize;
use zcash_primitives::zip339;
@ -63,7 +64,9 @@ pub extern "C" fn zip339_free_phrase(phrase: *const c_char) {
if !phrase.is_null() {
unsafe {
// It is correct to cast away const here; the memory is not actually immutable.
drop(CString::from_raw(phrase as *mut c_char));
CString::from_raw(phrase as *mut c_char)
.into_bytes()
.zeroize();
}
}
}