Skip to content
Merged
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
63 changes: 63 additions & 0 deletions test/core/data.wast
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,69 @@
"unknown memory"
)

;; Data segment with memory index 1 (only memory 0 available)
(assert_invalid
(module binary
"\00asm" "\01\00\00\00"
"\05\03\01" ;; memory section
"\00\00" ;; memory 0
"\0b\06\01" ;; data section
"\01\41\00\0b" ;; data segment 0 for memory 1
"\00" ;; empty vec(byte)
)
"unknown memory 1"
)

;; Data segment with memory index 1 (no memory section)
(assert_invalid
(module binary
"\00asm" "\01\00\00\00"
"\0b\06\01" ;; data section
"\01\41\00\0b" ;; data segment 0 for memory 1
"\00" ;; empty vec(byte)
)
"unknown memory 1"
)

;; Data segment with memory index 1 and vec(byte) as above,
;; only memory 0 available.
(assert_invalid
(module binary
"\00asm" "\01\00\00\00"
"\05\03\01" ;; memory section
"\00\00" ;; memory 0
"\0b\44\01" ;; data section
"\01" ;; memory index
"\41\00\0b" ;; offset constant expression
"\3e" ;; vec(byte) length
"\00\01\02\03\04\05\06\07\08\09\0a\0b\0c\0d\0e\0f"
"\10\11\12\13\14\15\16\17\18\19\1a\1b\1c\1d\1e\1f"
"\20\21\22\23\24\25\26\27\28\29\2a\2b\2c\2d\2e\2f"
"\30\31\32\33\34\35\36\37\38\39\3a\3b\3c\3d"
)
"unknown memory 1"
)

;; Data segment with memory index 1 and specially crafted vec(byte) after.
;; This is to detect incorrect validation where memory index is interpreted
;; as a flag followed by "\41" interpreted as the size of vec(byte)
;; with the expected number of bytes following.
(assert_invalid
(module binary
"\00asm" "\01\00\00\00"
"\0b\44\01" ;; data section
"\01" ;; memory index
"\41\00\0b" ;; offset constant expression
"\3e" ;; vec(byte) length
"\00\01\02\03\04\05\06\07\08\09\0a\0b\0c\0d\0e\0f"
"\10\11\12\13\14\15\16\17\18\19\1a\1b\1c\1d\1e\1f"
"\20\21\22\23\24\25\26\27\28\29\2a\2b\2c\2d\2e\2f"
"\30\31\32\33\34\35\36\37\38\39\3a\3b\3c\3d"
)
"unknown memory 1"
)


;; Invalid offsets

(assert_invalid
Expand Down