Skip to content

Commit 4eb070f

Browse files
committed
core/storage: Eliminate unwrap() from encryption.rs
1 parent 9e092c1 commit 4eb070f

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

core/storage/encryption.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,11 +94,15 @@ impl EncryptionKey {
9494

9595
match bytes.len() {
9696
16 => {
97-
let key: [u8; 16] = bytes.try_into().unwrap();
97+
let key: [u8; 16] = bytes.try_into().map_err(|_| {
98+
LimboError::Corrupt("Failed to convert bytes to 16-byte key".into())
99+
})?;
98100
Ok(Self::Key128(key))
99101
}
100102
32 => {
101-
let key: [u8; 32] = bytes.try_into().unwrap();
103+
let key: [u8; 32] = bytes.try_into().map_err(|_| {
104+
LimboError::Corrupt("Failed to convert bytes to 32-byte key".into())
105+
})?;
102106
Ok(Self::Key256(key))
103107
}
104108
_ => Err(LimboError::InvalidArgument(format!(

0 commit comments

Comments
 (0)