Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(185)

Unified Diff: test/unittests/wasm/module-decoder-unittest.cc

Issue 2574133002: [wasm] Enforce limits for maximums for many WebAssembly binary entities. (Closed)
Patch Set: Address review comments. Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « test/unittests/wasm/ast-decoder-unittest.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/unittests/wasm/module-decoder-unittest.cc
diff --git a/test/unittests/wasm/module-decoder-unittest.cc b/test/unittests/wasm/module-decoder-unittest.cc
index baf6909499ce22679e945ea22acd2ae4a4aca622..398ee15e4146924b11c3bd799f39a962cf8a02ee 100644
--- a/test/unittests/wasm/module-decoder-unittest.cc
+++ b/test/unittests/wasm/module-decoder-unittest.cc
@@ -7,6 +7,7 @@
#include "src/handles.h"
#include "src/objects-inl.h"
#include "src/wasm/module-decoder.h"
+#include "src/wasm/wasm-limits.h"
#include "src/wasm/wasm-macro-gen.h"
#include "src/wasm/wasm-opcodes.h"
@@ -310,7 +311,7 @@ TEST_F(WasmModuleVerifyTest, NGlobals) {
WASM_INIT_EXPR_F32(7.7), // init
};
- for (uint32_t i = 0; i < 1000000; i = i * 13 + 1) {
+ for (uint32_t i = 0; i < kV8MaxWasmGlobals; i = i * 13 + 1) {
std::vector<byte> buffer;
size_t size = SizeOfVarInt(i) + i * sizeof(data);
const byte globals[] = {kGlobalSectionCode, U32V_5(size)};
@@ -847,6 +848,31 @@ TEST_F(WasmSignatureDecodeTest, Ok_i_tt) {
}
}
+TEST_F(WasmSignatureDecodeTest, TooManyParams) {
+ static const byte data[] = {kWasmFunctionTypeForm,
+ WASM_I32V_3(kV8MaxWasmFunctionParams + 1),
+ kLocalI32, 0};
+ FunctionSig* sig =
+ DecodeWasmSignatureForTesting(zone(), data, data + sizeof(data));
+ EXPECT_FALSE(sig != nullptr);
+}
+
+TEST_F(WasmSignatureDecodeTest, TooManyReturns) {
+ bool prev = FLAG_wasm_mv_prototype;
+ for (int i = 0; i < 2; i++) {
+ FLAG_wasm_mv_prototype = i != 0;
+ const int max_return_count =
+ static_cast<int>(FLAG_wasm_mv_prototype ? kV8MaxWasmFunctionMultiReturns
+ : kV8MaxWasmFunctionReturns);
+ byte data[] = {kWasmFunctionTypeForm, 0, WASM_I32V_3(max_return_count + 1),
+ kLocalI32};
+ FunctionSig* sig =
+ DecodeWasmSignatureForTesting(zone(), data, data + sizeof(data));
+ EXPECT_EQ(nullptr, sig);
+ FLAG_wasm_mv_prototype = prev;
+ }
+}
+
TEST_F(WasmSignatureDecodeTest, Fail_off_end) {
byte data[256];
for (int p = 0; p <= 255; p = p + 1 + p * 3) {
« no previous file with comments | « test/unittests/wasm/ast-decoder-unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698