Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disallow non-zero memidx when bulk memory disabled #1546

Merged
merged 1 commit into from
Sep 17, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/binary-reader.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2387,6 +2387,8 @@ Result BinaryReader::ReadDataSection(Offset section_size) {
for (Index i = 0; i < num_data_segments; ++i) {
uint32_t flags;
CHECK_RESULT(ReadU32Leb128(&flags, "data segment flags"));
ERROR_IF(flags != 0 && !options_.features.bulk_memory_enabled(),
"invalid memory index %d: bulk memory not allowed", flags);
ERROR_IF(flags > SegFlagMax, "invalid data segment flags: %#x", flags);
Index memory_index(0);
if (flags & SegExplicitIndex) {
Expand Down
18 changes: 18 additions & 0 deletions test/binary/bad-data-invalid-memidx.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
;;; TOOL: run-gen-wasm-bad
magic
version
section(MEMORY) {
count[1]
has_max[0]
initial[0]
}
section(DATA) {
count[1]
memory_index[1]
offset[i32.const 0 end]
data[str("")]
}
(;; STDERR ;;;
0000011: error: invalid memory index 1: bulk memory not allowed
0000011: error: invalid memory index 1: bulk memory not allowed
;;; STDERR ;;)
2 changes: 2 additions & 0 deletions test/binary/bad-segment-no-memory.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
;;; TOOL: run-gen-wasm-bad
;;; ARGS1: --enable-bulk-memory
;;; ARGS2: --enable-bulk-memory
magic
version
section(DATA) {
Expand Down