diff options
author | Justus Winter <justus@sequoia-pgp.org> | 2022-01-20 14:35:35 +0100 |
---|---|---|
committer | Justus Winter <justus@sequoia-pgp.org> | 2022-01-20 17:34:27 +0100 |
commit | 25e3d52b7e496405aaef187e49dd052ee1cecf05 (patch) | |
tree | fe5f60b57addabd00ea3abc7cfcee9e4ff0d0b2e /openpgp/src/crypto/aead.rs | |
parent | 515604d85834ed2fa239f0a5fbd15d8a422a1271 (diff) |
openpgp: Avoid unsafe, undefined behavior.
- Now that the chunk size is capped, just initialize the scratch
vector.
Diffstat (limited to 'openpgp/src/crypto/aead.rs')
-rw-r--r-- | openpgp/src/crypto/aead.rs | 4 |
1 files changed, 1 insertions, 3 deletions
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<W: io::Write> Encryptor<W> { 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<W: io::Write> Encryptor<W> { chunk_index: 0, bytes_encrypted: 0, buffer: Vec::with_capacity(chunk_size), - scratch, + scratch: vec![0; chunk_size], }) } |