Fixing CALLDATALOAD for big indexes

This commit is contained in:
Tomusdrw 2016-01-15 20:19:46 +01:00
parent 51f828ac37
commit 7bb963f866
2 changed files with 4 additions and 3 deletions

View File

@ -564,10 +564,11 @@ impl Interpreter {
stack.push(params.value.clone());
},
instructions::CALLDATALOAD => {
let id = stack.pop_back().low_u64() as usize;
let big_id = stack.pop_back();
let id = big_id.low_u64() as usize;
let max = id.wrapping_add(32);
let bound = cmp::min(params.data.len(), max);
if id < bound {
if id < bound && big_id < U256::from(params.data.len()) {
let mut v = params.data[id..bound].to_vec();
v.resize(32, 0);
stack.push(U256::from(&v[..]))

View File

@ -168,7 +168,7 @@ fn do_json_test_for(vm: &VMType, json_data: &[u8]) -> Vec<String> {
let json = Json::from_str(::std::str::from_utf8(json_data).unwrap()).expect("Json is invalid");
let mut failed = Vec::new();
for (name, test) in json.as_object().unwrap() {
// if name != "calldataload0" {
// if name != "calldataload_BigOffset" {
// continue;
// }
println!("name: {:?}", name);