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[..]))