Fixing CALLDATALOAD for big indexes
This commit is contained in:
		
							parent
							
								
									51f828ac37
								
							
						
					
					
						commit
						7bb963f866
					
				| @ -564,10 +564,11 @@ impl Interpreter { | |||||||
| 				stack.push(params.value.clone()); | 				stack.push(params.value.clone()); | ||||||
| 			}, | 			}, | ||||||
| 			instructions::CALLDATALOAD => { | 			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 max = id.wrapping_add(32); | ||||||
| 				let bound = cmp::min(params.data.len(), max); | 				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(); | 					let mut v = params.data[id..bound].to_vec(); | ||||||
| 					v.resize(32, 0); | 					v.resize(32, 0); | ||||||
| 					stack.push(U256::from(&v[..])) | 					stack.push(U256::from(&v[..])) | ||||||
|  | |||||||
| @ -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 json = Json::from_str(::std::str::from_utf8(json_data).unwrap()).expect("Json is invalid"); | ||||||
| 	let mut failed = Vec::new(); | 	let mut failed = Vec::new(); | ||||||
| 	for (name, test) in json.as_object().unwrap() { | 	for (name, test) in json.as_object().unwrap() { | ||||||
| 		// if name != "calldataload0" {
 | 		// if name != "calldataload_BigOffset" {
 | ||||||
| 			// continue;
 | 			// continue;
 | ||||||
| 		// }
 | 		// }
 | ||||||
| 		println!("name: {:?}", name); | 		println!("name: {:?}", name); | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user