Skip to content

Commit 6630389

Browse files
author
Hugh Cunningham
committed
do not pre-allocate vector capacity in MultiRecipientBlob
the value we read for 'encrypted_keys_len' may not be a reasonable size if the bytes we're reading from weren't encrypted using the old method pre-allocating the vector to a random usize capacity may cause memory allocation errors
1 parent d0712d8 commit 6630389

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/multienc.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ impl MultiRecipientBlob<Vec<EncryptedKey>, Vec<u8>> {
305305
reader.read_exact(&mut encrypted_keys_len)?;
306306
let encrypted_keys_len = u32::from_le_bytes(encrypted_keys_len) as usize;
307307

308-
let mut encrypted_keys = Vec::with_capacity(encrypted_keys_len);
308+
let mut encrypted_keys = Vec::new();
309309
for _ in 0..encrypted_keys_len {
310310
let mut key = EncryptedKey::default();
311311
reader.read_exact(&mut key)?;

0 commit comments

Comments
 (0)