Additional bounds check in sbrk (#428)

Close #356

Signed-off-by: xermicus <cyrill@parity.io>
This commit is contained in:
xermicus
2025-12-03 16:00:19 +01:00
committed by GitHub
parent a9ccb1f9b4
commit 45ceab7dc7
4 changed files with 77 additions and 13 deletions
+8 -8
View File
@@ -1,10 +1,10 @@
{
"Baseline": 905,
"Computation": 2286,
"DivisionArithmetics": 14347,
"ERC20": 16929,
"Events": 1665,
"FibonacciIterative": 1447,
"Flipper": 2077,
"SHA1": 7721
"Baseline": 911,
"Computation": 2293,
"DivisionArithmetics": 14353,
"ERC20": 16936,
"Events": 1672,
"FibonacciIterative": 1454,
"Flipper": 2083,
"SHA1": 7727
}
+49
View File
@@ -619,3 +619,52 @@ fn code_block_with_nested_object_stops() {
}
.run();
}
#[test]
fn sbrk_bounds_checks() {
let code = &build_yul(&[(
"poc.yul",
r#"object "Test" {
code {
return(0x4, 0xffffffff)
stop()
}
object "Test_deployed" {
code {
stop()
}
}
}"#,
)])
.unwrap()["poc.yul:Test"];
let results = Specs {
actions: vec![
Instantiate {
origin: TestAddress::Alice,
value: 0,
gas_limit: Some(GAS_LIMIT),
storage_deposit_limit: None,
code: Code::Bytes(code.to_vec()),
data: Default::default(),
salt: OptionalHex::default(),
},
VerifyCall(VerifyCallExpectation {
success: false,
..Default::default()
}),
],
differential: false,
..Default::default()
}
.run();
let CallResult::Instantiate { result, .. } = results.last().unwrap() else {
unreachable!()
};
assert!(
format!("{result:?}").contains("ContractTrapped"),
"not seeing a trap means the contract did not catch the OOB"
);
}