Skip to content

Commit 93054e7

Browse files
authored
Check all types of partially-oob stores (WebAssembly#1385)
Follow-up to WebAssembly#1384 to add checks for all numeric type. Fixes WebAssembly#1250.
1 parent 941c6f3 commit 93054e7

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

test/core/memory_trap.wast

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@
2121
(assert_return (invoke "store" (i32.const -4) (i32.const 42)))
2222
(assert_return (invoke "load" (i32.const -4)) (i32.const 42))
2323
(assert_trap (invoke "store" (i32.const -3) (i32.const 0x12345678)) "out of bounds memory access")
24-
;; check that the oob store above does not store partial data.
25-
(assert_return (invoke "load" (i32.const -4)) (i32.const 42))
2624
(assert_trap (invoke "load" (i32.const -3)) "out of bounds memory access")
2725
(assert_trap (invoke "store" (i32.const -2) (i32.const 13)) "out of bounds memory access")
2826
(assert_trap (invoke "load" (i32.const -2)) "out of bounds memory access")
@@ -270,3 +268,15 @@
270268
;; No memory was changed
271269
(assert_return (invoke "i64.load" (i32.const 0xfff8)) (i64.const 0x6867666564636261))
272270
(assert_return (invoke "i64.load" (i32.const 0)) (i64.const 0x6867666564636261))
271+
272+
;; Check that out of bounds store do not store partial data.
273+
;; Zero last 8 bytes.
274+
(assert_return (invoke "i64.store" (i32.const 0xfff8) (i64.const 0)))
275+
(assert_trap (invoke "i32.store" (i32.const 0xfffd) (i32.const 0x12345678)) "out of bounds memory access")
276+
(assert_return (invoke "i32.load" (i32.const 0xfffc)) (i32.const 0))
277+
(assert_trap (invoke "i64.store" (i32.const 0xfff9) (i64.const 0x1234567890abcdef)) "out of bounds memory access")
278+
(assert_return (invoke "i64.load" (i32.const 0xfff8)) (i64.const 0))
279+
(assert_trap (invoke "f32.store" (i32.const 0xfffd) (f32.const 0x12345678)) "out of bounds memory access")
280+
(assert_return (invoke "f32.load" (i32.const 0xfffc)) (f32.const 0))
281+
(assert_trap (invoke "f64.store" (i32.const 0xfff9) (f64.const 0x1234567890abcdef)) "out of bounds memory access")
282+
(assert_return (invoke "f64.load" (i32.const 0xfff8)) (f64.const 0))

0 commit comments

Comments
 (0)