1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108
|
;; unaligned utf16 string
(assert_trap
(component
(component $c
(core module $m
(func (export "") (param i32 i32))
(func (export "realloc") (param i32 i32 i32 i32) (result i32) i32.const 0)
(memory (export "memory") 1)
)
(core instance $m (instantiate $m))
(func (export "a") (param "a" string)
(canon lift (core func $m "") (realloc (func $m "realloc")) (memory $m "memory"))
)
)
(component $c2
(import "a" (func $f (param "a" string)))
(core module $libc
(memory (export "memory") 1)
)
(core instance $libc (instantiate $libc))
(core func $f (canon lower (func $f) string-encoding=utf16 (memory $libc "memory")))
(core module $m
(import "" "" (func $f (param i32 i32)))
(func $start (call $f (i32.const 1) (i32.const 0)))
(start $start)
)
(core instance (instantiate $m (with "" (instance (export "" (func $f))))))
)
(instance $c (instantiate $c))
(instance $c2 (instantiate $c2 (with "a" (func $c "a"))))
)
"unreachable")
;; unaligned latin1+utf16 string, even with the latin1 encoding
(assert_trap
(component
(component $c
(core module $m
(func (export "") (param i32 i32))
(func (export "realloc") (param i32 i32 i32 i32) (result i32) i32.const 0)
(memory (export "memory") 1)
)
(core instance $m (instantiate $m))
(func (export "a") (param "a" string)
(canon lift (core func $m "") (realloc (func $m "realloc")) (memory $m "memory"))
)
)
(component $c2
(import "a" (func $f (param "a" string)))
(core module $libc
(memory (export "memory") 1)
)
(core instance $libc (instantiate $libc))
(core func $f (canon lower (func $f) string-encoding=latin1+utf16 (memory $libc "memory")))
(core module $m
(import "" "" (func $f (param i32 i32)))
(func $start (call $f (i32.const 1) (i32.const 0)))
(start $start)
)
(core instance (instantiate $m (with "" (instance (export "" (func $f))))))
)
(instance $c (instantiate $c))
(instance $c2 (instantiate $c2 (with "a" (func $c "a"))))
)
"unreachable")
;; out of bounds utf8->utf8 string
(assert_trap
(component
(component $c
(core module $m
(func (export "") (param i32 i32))
(func (export "realloc") (param i32 i32 i32 i32) (result i32) i32.const 0)
(memory (export "memory") 1)
)
(core instance $m (instantiate $m))
(func (export "a") (param "a" string)
(canon lift (core func $m "") (realloc (func $m "realloc")) (memory $m "memory")
string-encoding=utf8)
)
)
(component $c2
(import "a" (func $f (param "a" string)))
(core module $libc
(memory (export "memory") 1)
)
(core instance $libc (instantiate $libc))
(core func $f (canon lower (func $f) string-encoding=utf8 (memory $libc "memory")))
(core module $m
(import "" "" (func $f (param i32 i32)))
(func $start (call $f (i32.const 0x8000_0000) (i32.const 1)))
(start $start)
)
(core instance (instantiate $m (with "" (instance (export "" (func $f))))))
)
(instance $c (instantiate $c))
(instance $c2 (instantiate $c2 (with "a" (func $c "a"))))
)
"unreachable")
|