File tree Expand file tree Collapse file tree 2 files changed +14
-1
lines changed
crates/matrix-sdk-store-encryption Expand file tree Collapse file tree 2 files changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -6,6 +6,13 @@ All notable changes to this project will be documented in this file.
6
6
7
7
## [ Unreleased] - ReleaseDate
8
8
9
+ ### Bug Fixes
10
+
11
+ - Remove the usage of an unwrap in the ` StoreCipher::import_with_key ` method.
12
+ This could have lead to panics if the second argument was an invalid
13
+ ` StoreCipher ` export.
14
+ ([ #4506 ] ( https://github.com/matrix-org/matrix-rust-sdk/pull/4506 ) )
15
+
9
16
## [ 0.9.0] - 2024-12-18
10
17
11
18
No notable changes in this release.
Original file line number Diff line number Diff line change @@ -334,7 +334,7 @@ impl StoreCipher {
334
334
/// # anyhow::Ok(()) };
335
335
/// ```
336
336
pub fn import_with_key ( key : & [ u8 ; 32 ] , encrypted : & [ u8 ] ) -> Result < Self , Error > {
337
- let encrypted: EncryptedStoreCipher = rmp_serde:: from_slice ( encrypted) . unwrap ( ) ;
337
+ let encrypted: EncryptedStoreCipher = rmp_serde:: from_slice ( encrypted) ? ;
338
338
339
339
if let KdfInfo :: Pbkdf2ToChaCha20Poly1305 { .. } = encrypted. kdf_info {
340
340
return Err ( Error :: KdfMismatch ) ;
@@ -903,6 +903,12 @@ mod tests {
903
903
Ok ( ( ) )
904
904
}
905
905
906
+ #[ test]
907
+ fn test_importing_invalid_store_cipher_does_not_panic ( ) {
908
+ // This used to panic, we're testing that we're getting a real error.
909
+ assert ! ( StoreCipher :: import_with_key( & [ 0 ; 32 ] , & [ 0 ; 64 ] ) . is_err( ) )
910
+ }
911
+
906
912
#[ test]
907
913
fn encrypting_values ( ) -> Result < ( ) , Error > {
908
914
let event = json ! ( {
You can’t perform that action at this time.
0 commit comments