mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-09 20:11:09 +00:00
Guard some invalid node for proof decoding. (#12417)
* Guard some invalid node for proof decoding. * only forbid bitmap with no children. * change format * scale error. * small test Co-authored-by: parity-processbot <>
This commit is contained in:
@@ -304,8 +304,13 @@ const BITMAP_LENGTH: usize = 2;
|
||||
pub(crate) struct Bitmap(u16);
|
||||
|
||||
impl Bitmap {
|
||||
pub fn decode(mut data: &[u8]) -> Result<Self, codec::Error> {
|
||||
Ok(Bitmap(u16::decode(&mut data)?))
|
||||
pub fn decode(data: &[u8]) -> Result<Self, codec::Error> {
|
||||
let value = u16::decode(&mut &data[..])?;
|
||||
if value == 0 {
|
||||
Err("Bitmap without a child.".into())
|
||||
} else {
|
||||
Ok(Bitmap(value))
|
||||
}
|
||||
}
|
||||
|
||||
pub fn value_at(&self, i: usize) -> bool {
|
||||
|
||||
Reference in New Issue
Block a user