未验证 提交 e22c9bda 编写于 作者: M Matt Witherspoon 提交者: GitHub

Merge pull request #3600 from wanderingbort/feature/more-bad-wasms

more bad wasms for regression testing
......@@ -64,7 +64,9 @@ namespace eosio { namespace chain {
Serialization::MemoryInputStream stream((const U8*)code.data(), code.size());
WASM::serialize(stream, module);
module.userSections.clear();
} catch(Serialization::FatalSerializationException& e) {
} catch(const Serialization::FatalSerializationException& e) {
EOS_ASSERT(false, wasm_serialization_error, e.message.c_str());
} catch(const IR::ValidationException& e) {
EOS_ASSERT(false, wasm_serialization_error, e.message.c_str());
}
......@@ -76,7 +78,9 @@ namespace eosio { namespace chain {
Serialization::ArrayOutputStream outstream;
WASM::serialize(outstream, module);
bytes = outstream.getBytes();
} catch(Serialization::FatalSerializationException& e) {
} catch(const Serialization::FatalSerializationException& e) {
EOS_ASSERT(false, wasm_serialization_error, e.message.c_str());
} catch(const IR::ValidationException& e) {
EOS_ASSERT(false, wasm_serialization_error, e.message.c_str());
}
it = instantiation_cache.emplace(code_id, runtime_interface->instantiate_module((const char*)bytes.data(), bytes.size(), parse_initial_memory(module))).first;
......
......@@ -36,7 +36,9 @@ namespace eosio { namespace chain {
try {
Serialization::MemoryInputStream stream((U8*)code.data(), code.size());
WASM::serialize(stream, module);
} catch(Serialization::FatalSerializationException& e) {
} catch(const Serialization::FatalSerializationException& e) {
EOS_ASSERT(false, wasm_serialization_error, e.message.c_str());
} catch(const IR::ValidationException& e) {
EOS_ASSERT(false, wasm_serialization_error, e.message.c_str());
}
......
......@@ -48,11 +48,15 @@ namespace eosio { namespace chain {
WASM::serialize(stream,module);
return stream.getBytes();
}
catch(Serialization::FatalSerializationException exception)
catch(const Serialization::FatalSerializationException& exception)
{
ss << "Error serializing WebAssembly binary file:" << std::endl;
ss << exception.message << std::endl;
FC_ASSERT( !"error converting to wasm", "${msg}", ("msg",ss.get()) );
} catch(const IR::ValidationException& e) {
ss << "Error validating WebAssembly binary file:" << std::endl;
ss << e.message << std::endl;
FC_ASSERT( !"error converting to wasm", "${msg}", ("msg",ss.get()) );
}
} FC_CAPTURE_AND_RETHROW( (wast) ) } /// wast_to_wasm
......
......@@ -113,7 +113,9 @@ std::unique_ptr<wasm_instantiated_module_interface> wavm_runtime::instantiate_mo
try {
Serialization::MemoryInputStream stream((const U8*)code_bytes, code_size);
WASM::serialize(stream, *module);
} catch(Serialization::FatalSerializationException& e) {
} catch(const Serialization::FatalSerializationException& e) {
EOS_ASSERT(false, wasm_serialization_error, e.message.c_str());
} catch(const IR::ValidationException& e) {
EOS_ASSERT(false, wasm_serialization_error, e.message.c_str());
}
......
......@@ -1571,6 +1571,17 @@ INCBIN(fuzz10, "fuzz10.wasm");
INCBIN(fuzz11, "fuzz11.wasm");
INCBIN(fuzz12, "fuzz12.wasm");
//INCBIN(fuzz13, "fuzz13.wasm");
INCBIN(big_allocation, "big_allocation.wasm");
INCBIN(crash_section_size_too_big, "crash_section_size_too_big.wasm");
INCBIN(leak_no_destructor, "leak_no_destructor.wasm");
INCBIN(leak_readExports, "leak_readExports.wasm");
INCBIN(leak_readFunctions, "leak_readFunctions.wasm");
INCBIN(leak_readFunctions_2, "leak_readFunctions_2.wasm");
INCBIN(leak_readFunctions_3, "leak_readFunctions_3.wasm");
INCBIN(leak_readGlobals, "leak_readGlobals.wasm");
INCBIN(leak_readImports, "leak_readImports.wasm");
INCBIN(leak_wasm_binary_cpp_L1249, "leak_wasm_binary_cpp_L1249.wasm");
INCBIN(readFunctions_slowness_out_of_memory, "readFunctions_slowness_out_of_memory.wasm");
BOOST_FIXTURE_TEST_CASE( fuzz, TESTER ) try {
produce_blocks(2);
......@@ -1638,6 +1649,51 @@ BOOST_FIXTURE_TEST_CASE( fuzz, TESTER ) try {
}
*/
{
vector<uint8_t> wasm(gbig_allocationData, gbig_allocationData + gbig_allocationSize);
BOOST_CHECK_THROW(set_code(N(fuzzy), wasm), wasm_serialization_error);
}
{
vector<uint8_t> wasm(gcrash_section_size_too_bigData, gcrash_section_size_too_bigData + gcrash_section_size_too_bigSize);
BOOST_CHECK_THROW(set_code(N(fuzzy), wasm), wasm_serialization_error);
}
{
vector<uint8_t> wasm(gleak_no_destructorData, gleak_no_destructorData + gleak_no_destructorSize);
BOOST_CHECK_THROW(set_code(N(fuzzy), wasm), wasm_serialization_error);
}
{
vector<uint8_t> wasm(gleak_readExportsData, gleak_readExportsData + gleak_readExportsSize);
BOOST_CHECK_THROW(set_code(N(fuzzy), wasm), wasm_serialization_error);
}
{
vector<uint8_t> wasm(gleak_readFunctionsData, gleak_readFunctionsData + gleak_readFunctionsSize);
BOOST_CHECK_THROW(set_code(N(fuzzy), wasm), wasm_serialization_error);
}
{
vector<uint8_t> wasm(gleak_readFunctions_2Data, gleak_readFunctions_2Data + gleak_readFunctions_2Size);
BOOST_CHECK_THROW(set_code(N(fuzzy), wasm), wasm_serialization_error);
}
{
vector<uint8_t> wasm(gleak_readFunctions_3Data, gleak_readFunctions_3Data + gleak_readFunctions_3Size);
BOOST_CHECK_THROW(set_code(N(fuzzy), wasm), wasm_serialization_error);
}
{
vector<uint8_t> wasm(gleak_readGlobalsData, gleak_readGlobalsData + gleak_readGlobalsSize);
BOOST_CHECK_THROW(set_code(N(fuzzy), wasm), wasm_serialization_error);
}
{
vector<uint8_t> wasm(gleak_readImportsData, gleak_readImportsData + gleak_readImportsSize);
BOOST_CHECK_THROW(set_code(N(fuzzy), wasm), wasm_serialization_error);
}
{
vector<uint8_t> wasm(gleak_wasm_binary_cpp_L1249Data, gleak_wasm_binary_cpp_L1249Data + gleak_wasm_binary_cpp_L1249Size);
BOOST_CHECK_THROW(set_code(N(fuzzy), wasm), wasm_serialization_error);
}
{
vector<uint8_t> wasm(greadFunctions_slowness_out_of_memoryData, greadFunctions_slowness_out_of_memoryData + greadFunctions_slowness_out_of_memorySize);
BOOST_CHECK_THROW(set_code(N(fuzzy), wasm), wasm_serialization_error);
}
produce_blocks(1);
} FC_LOG_AND_RETHROW()
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册