Skip to content
Snippets Groups Projects
Commit 1363675a authored by thiolliere's avatar thiolliere Committed by GitHub
Browse files

safe slice operation (#5471)

parent 2e76e2a7
No related merge requests found
......@@ -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..]
}
}
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment