mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-30 06:08:00 +00:00
safe slice operation (#5471)
This commit is contained in:
@@ -92,6 +92,10 @@ impl StorageHasher for Twox64Concat {
|
||||
}
|
||||
impl ReversibleStorageHasher for Twox64Concat {
|
||||
fn reverse(x: &[u8]) -> &[u8] {
|
||||
if x.len() < 8 {
|
||||
crate::debug::error!("Invalid reverse: hash length too short");
|
||||
return &[]
|
||||
}
|
||||
&x[8..]
|
||||
}
|
||||
}
|
||||
@@ -110,6 +114,10 @@ impl StorageHasher for Blake2_128Concat {
|
||||
}
|
||||
impl ReversibleStorageHasher for Blake2_128Concat {
|
||||
fn reverse(x: &[u8]) -> &[u8] {
|
||||
if x.len() < 16 {
|
||||
crate::debug::error!("Invalid reverse: hash length too short");
|
||||
return &[]
|
||||
}
|
||||
&x[16..]
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user