mirror of
https://github.com/fluencelabs/parity-wasm
synced 2025-04-25 15:22:17 +00:00
add more for i32
This commit is contained in:
parent
4d4dfb621e
commit
59b61c6ef6
BIN
res/cases/v1/err-leb-i32-too-long.wasm
Normal file
BIN
res/cases/v1/err-leb-i32-too-long.wasm
Normal file
Binary file not shown.
@ -287,6 +287,14 @@ impl Deserialize for VarInt32 {
|
||||
if (b >> 7) == 0 {
|
||||
if shift < 32 && b & 0b0100_0000 == 0b0100_0000 {
|
||||
res |= (1i32 << shift).wrapping_neg();
|
||||
} else if shift >= 32 && b & 0b0100_0000 == 0b0100_0000 {
|
||||
if (!(b | 0b1000_0000)).leading_zeros() < 4 {
|
||||
return Err(Error::InvalidVarInt32);
|
||||
}
|
||||
} else if shift >= 32 && b & 0b0100_0000 == 0 {
|
||||
if b.leading_zeros() < 4 {
|
||||
return Err(Error::InvalidVarInt32);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -758,6 +766,24 @@ mod tests {
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn varint64_bad_extended() {
|
||||
let res = deserialize_buffer::<VarInt64>(&[0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x6f][..]);
|
||||
assert!(res.is_err());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn varint32_bad_extended() {
|
||||
let res = deserialize_buffer::<VarInt32>(&[0x80, 0x80, 0x80, 0x80, 0x6f][..]);
|
||||
assert!(res.is_err());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn varint32_bad_extended2() {
|
||||
let res = deserialize_buffer::<VarInt32>(&[0x80, 0x80, 0x80, 0x80, 0x41][..]);
|
||||
assert!(res.is_err());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn varint64_max() {
|
||||
varint64_serde_test(
|
||||
|
Loading…
x
Reference in New Issue
Block a user