Skip to content
This repository has been archived by the owner on Nov 6, 2020. It is now read-only.

Commit

Permalink
Fixed RETURNDATA size for built-ins
Browse files Browse the repository at this point in the history
  • Loading branch information
arkpar committed Oct 5, 2017
1 parent 223467c commit 6a1eea1
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions ethcore/src/executive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -416,13 +416,19 @@ impl<'a, B: 'a + StateBackend> Executive<'a, B> {

let cost = builtin.cost(data);
if cost <= params.gas {
if let Err(e) = builtin.execute(data, &mut output) {
let mut builtin_out_buffer = Vec::new();
let result = {
let mut builtin_output = BytesRef::Flexible(&mut builtin_out_buffer);
builtin.execute(data, &mut builtin_output)
};
if let Err(e) = result {
self.state.revert_to_checkpoint();
let evm_err: vm::Error = e.into();
tracer.trace_failed_call(trace_info, vec![], evm_err.clone().into());
Err(evm_err)
} else {
self.state.discard_checkpoint();
output.write(0, &builtin_out_buffer);

// trace only top level calls to builtins to avoid DDoS attacks
if self.depth == 0 {
Expand All @@ -439,9 +445,10 @@ impl<'a, B: 'a + StateBackend> Executive<'a, B> {
);
}

let out_len = builtin_out_buffer.len();
Ok(FinalizationResult {
gas_left: params.gas - cost,
return_data: ReturnData::new(output.to_owned(), 0, output.len()),
return_data: ReturnData::new(builtin_out_buffer, 0, out_len),
apply_state: true,
})
}
Expand Down

0 comments on commit 6a1eea1

Please sign in to comment.