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

Unified Diff: src/wasm/module-decoder.cc

Issue 1743773002: WebAssembly: skip unknown sections, add names (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix limit type Created 4 years, 10 months 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 | « src/wasm/decoder.h ('k') | src/wasm/wasm-module.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/wasm/module-decoder.cc
diff --git a/src/wasm/module-decoder.cc b/src/wasm/module-decoder.cc
index eada4c966daa10c74c4313f946dfa6d18ce16e09..4653e1d44bd7b53b145afb4bc8fbf8843231f6af 100644
--- a/src/wasm/module-decoder.cc
+++ b/src/wasm/module-decoder.cc
@@ -78,14 +78,21 @@ class ModuleDecoder : public Decoder {
// Decode the module sections.
while (pc_ < limit_) {
TRACE("DecodeSection\n");
- WasmSectionDeclCode section =
- static_cast<WasmSectionDeclCode>(consume_u8("section"));
- // Each section should appear at most once.
- if (section < kMaxModuleSectionCode) {
- CheckForPreviousSection(sections, section, false);
- sections[section] = true;
+ uint8_t section_u8 = consume_u8("section");
+
+ if (section_u8 >= kMaxModuleSectionCode) {
+ // Skip unknown section.
+ int length;
+ uint32_t section_bytes = consume_u32v(&length, "section size");
+ consume_bytes(section_bytes);
+ continue;
}
+ // Each section should appear at most once.
+ auto section = static_cast<WasmSectionDeclCode>(section_u8);
+ CheckForPreviousSection(sections, section, false);
+ sections[section] = true;
+
switch (section) {
case kDeclEnd:
// Terminate section decoding.
@@ -279,23 +286,8 @@ class ModuleDecoder : public Decoder {
}
break;
}
- case kDeclWLL: {
- // Reserved for experimentation by the Web Low-level Language project
- // which is augmenting the binary encoding with source code meta
- // information. This section does not affect the semantics of the code
- // and can be ignored by the runtime. https://github.com/JSStats/wll
- int length = 0;
- uint32_t section_size = consume_u32v(&length, "section size");
- if (pc_ + section_size > limit_ || pc_ + section_size < pc_) {
- error(pc_ - length, "invalid section size");
- break;
- }
- pc_ += section_size;
- break;
- }
- default:
- error(pc_ - 1, nullptr, "unrecognized section 0x%02x", section);
- break;
+ case kMaxModuleSectionCode:
+ UNREACHABLE(); // Already skipped unknown sections.
}
}
« no previous file with comments | « src/wasm/decoder.h ('k') | src/wasm/wasm-module.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698