From 25e3d52b7e496405aaef187e49dd052ee1cecf05 Mon Sep 17 00:00:00 2001 From: Justus Winter Date: Thu, 20 Jan 2022 14:35:35 +0100 Subject: openpgp: Avoid unsafe, undefined behavior. - Now that the chunk size is capped, just initialize the scratch vector. --- openpgp/src/crypto/aead.rs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'openpgp/src/crypto') diff --git a/openpgp/src/crypto/aead.rs b/openpgp/src/crypto/aead.rs index 5217c247..2193da04 100644 --- a/openpgp/src/crypto/aead.rs +++ b/openpgp/src/crypto/aead.rs @@ -573,8 +573,6 @@ impl Encryptor { format!("Invalid AEAD chunk size: {}", chunk_size)).into()); } - let mut scratch = Vec::with_capacity(chunk_size); - unsafe { scratch.set_len(chunk_size); } Ok(Encryptor { inner: Some(sink), @@ -596,7 +594,7 @@ impl Encryptor { chunk_index: 0, bytes_encrypted: 0, buffer: Vec::with_capacity(chunk_size), - scratch, + scratch: vec![0; chunk_size], }) } -- cgit v1.2.3