Skip to content

Commit 1bf851f

Browse files
committed
Don't unwrap on service-provided data
Previously, this `unwrap` could have us panic if the service wouldn't provide a message including the `EncryptionMetadata`. Here we fix this by simply erroring out if the expected metadata is not present.
1 parent 995ca70 commit 1bf851f

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/util/storable_builder.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,9 @@ impl<T: EntropySource> StorableBuilder<T> {
6464
///
6565
/// [`PutObjectRequest`]: crate::types::PutObjectRequest
6666
pub fn deconstruct(&self, mut storable: Storable, aad: &[u8]) -> io::Result<(Vec<u8>, i64)> {
67-
let encryption_metadata = storable.encryption_metadata.unwrap();
67+
let encryption_metadata = storable
68+
.encryption_metadata
69+
.ok_or_else(|| Error::new(ErrorKind::InvalidData, "Invalid Metadata"))?;
6870
let mut cipher =
6971
ChaCha20Poly1305::new(&self.data_encryption_key, &encryption_metadata.nonce, aad);
7072

0 commit comments

Comments
 (0)