From fb4857abed31a9f63cf3addf53456fdabb269638 Mon Sep 17 00:00:00 2001 From: Christian Parpart Date: Thu, 2 Aug 2018 15:34:14 +0200 Subject: evmasm/Instruction: fixes undefined behavior of advancing iterator beyond the end of a container. Usually the STL doesn't check whether or not the developer advances beyond its container's end, but MSVC does (found out by running soltest in debug mode on Win32 / VS2017). --- libevmasm/Instruction.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'libevmasm/Instruction.cpp') diff --git a/libevmasm/Instruction.cpp b/libevmasm/Instruction.cpp index f9bbad2c..37c5fdd4 100644 --- a/libevmasm/Instruction.cpp +++ b/libevmasm/Instruction.cpp @@ -21,6 +21,7 @@ #include "./Instruction.h" +#include #include #include #include @@ -325,13 +326,20 @@ void dev::solidity::eachInstruction( size_t additional = 0; if (isValidInstruction(instr)) additional = instructionInfo(instr).additional; + u256 data; - for (size_t i = 0; i < additional; ++i) + + // fill the data with the additional data bytes from the instruction stream + while (additional > 0 && next(it) < _mem.end()) { data <<= 8; - if (++it < _mem.end()) - data |= *it; + data |= *++it; + --additional; } + + // pad the remaining number of additional octets with zeros + data <<= 8 * additional; + _onInstruction(instr, data); } } -- cgit v1.2.3 From 7d9692c31d411a66ea194480bf3963cb97e2c257 Mon Sep 17 00:00:00 2001 From: chriseth Date: Thu, 9 Aug 2018 01:12:39 +0200 Subject: Explicitly use std::next to avoid boost version. --- libevmasm/Instruction.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'libevmasm/Instruction.cpp') diff --git a/libevmasm/Instruction.cpp b/libevmasm/Instruction.cpp index 37c5fdd4..d5b82e75 100644 --- a/libevmasm/Instruction.cpp +++ b/libevmasm/Instruction.cpp @@ -330,7 +330,7 @@ void dev::solidity::eachInstruction( u256 data; // fill the data with the additional data bytes from the instruction stream - while (additional > 0 && next(it) < _mem.end()) + while (additional > 0 && std::next(it) < _mem.end()) { data <<= 8; data |= *++it; -- cgit v1.2.3 From c6bd2979b1265cb81d35124a2785e3828658f7cc Mon Sep 17 00:00:00 2001 From: Jared Wasinger Date: Tue, 31 Jul 2018 00:54:43 +0000 Subject: Add assembly support for EXTCODEHASH (EIP-1052) --- libevmasm/Instruction.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'libevmasm/Instruction.cpp') diff --git a/libevmasm/Instruction.cpp b/libevmasm/Instruction.cpp index d5b82e75..46f6c628 100644 --- a/libevmasm/Instruction.cpp +++ b/libevmasm/Instruction.cpp @@ -73,6 +73,7 @@ const std::map dev::solidity::c_instructions = { "EXTCODECOPY", Instruction::EXTCODECOPY }, { "RETURNDATASIZE", Instruction::RETURNDATASIZE }, { "RETURNDATACOPY", Instruction::RETURNDATACOPY }, + { "EXTCODEHASH", Instruction::EXTCODEHASH }, { "BLOCKHASH", Instruction::BLOCKHASH }, { "COINBASE", Instruction::COINBASE }, { "TIMESTAMP", Instruction::TIMESTAMP }, @@ -216,6 +217,7 @@ static const std::map c_instructionInfo = { Instruction::EXTCODECOPY, { "EXTCODECOPY", 0, 4, 0, true, Tier::ExtCode } }, { Instruction::RETURNDATASIZE, {"RETURNDATASIZE", 0, 0, 1, false, Tier::Base } }, { Instruction::RETURNDATACOPY, {"RETURNDATACOPY", 0, 3, 0, true, Tier::VeryLow } }, + { Instruction::EXTCODEHASH, { "EXTCODEHASH", 0, 1, 1, false, Tier::ExtCode } }, { Instruction::BLOCKHASH, { "BLOCKHASH", 0, 1, 1, false, Tier::Ext } }, { Instruction::COINBASE, { "COINBASE", 0, 0, 1, false, Tier::Base } }, { Instruction::TIMESTAMP, { "TIMESTAMP", 0, 0, 1, false, Tier::Base } }, -- cgit v1.2.3 From 6a1e79a8e3fa8e8135de32b2b16eca93de5fb14c Mon Sep 17 00:00:00 2001 From: Alex Beregszaszi Date: Tue, 25 Sep 2018 22:49:26 +0100 Subject: Set the price of EXTCODEHASH properly --- libevmasm/Instruction.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'libevmasm/Instruction.cpp') diff --git a/libevmasm/Instruction.cpp b/libevmasm/Instruction.cpp index 46f6c628..cf98c938 100644 --- a/libevmasm/Instruction.cpp +++ b/libevmasm/Instruction.cpp @@ -217,7 +217,7 @@ static const std::map c_instructionInfo = { Instruction::EXTCODECOPY, { "EXTCODECOPY", 0, 4, 0, true, Tier::ExtCode } }, { Instruction::RETURNDATASIZE, {"RETURNDATASIZE", 0, 0, 1, false, Tier::Base } }, { Instruction::RETURNDATACOPY, {"RETURNDATACOPY", 0, 3, 0, true, Tier::VeryLow } }, - { Instruction::EXTCODEHASH, { "EXTCODEHASH", 0, 1, 1, false, Tier::ExtCode } }, + { Instruction::EXTCODEHASH, { "EXTCODEHASH", 0, 1, 1, false, Tier::Balance } }, { Instruction::BLOCKHASH, { "BLOCKHASH", 0, 1, 1, false, Tier::Ext } }, { Instruction::COINBASE, { "COINBASE", 0, 0, 1, false, Tier::Base } }, { Instruction::TIMESTAMP, { "TIMESTAMP", 0, 0, 1, false, Tier::Base } }, -- cgit v1.2.3