diff options
author | Alon Zakai <azakai@google.com> | 2024-03-25 14:55:58 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-03-25 14:55:58 -0700 |
commit | 1125750c47890935eb1271491d765e46ea66b07c (patch) | |
tree | f15d2ed710a6c5aa6c2cd41ed7848f01243930e7 /test/lit/exec | |
parent | 47bcca6783b64b64560b1c1196a1f5e1a98e108a (diff) | |
download | binaryen-1125750c47890935eb1271491d765e46ea66b07c.tar.gz binaryen-1125750c47890935eb1271491d765e46ea66b07c.tar.bz2 binaryen-1125750c47890935eb1271491d765e46ea66b07c.zip |
StringNew: Trap on OOB start index (#6438)
Diffstat (limited to 'test/lit/exec')
-rw-r--r-- | test/lit/exec/strings.wast | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/test/lit/exec/strings.wast b/test/lit/exec/strings.wast index 3d2ab366d..106e1e214 100644 --- a/test/lit/exec/strings.wast +++ b/test/lit/exec/strings.wast @@ -296,6 +296,47 @@ (i32.const -1) ) ) + + ;; CHECK: [fuzz-exec] calling new_empty + ;; CHECK-NEXT: [fuzz-exec] note result: new_empty => string("") + (func $new_empty (export "new_empty") (result stringref) + ;; Make an empty string from an empty array. + (string.new_wtf16_array + (array.new_default $array16 + (i32.const 0) + ) + (i32.const 0) + (i32.const 0) + ) + ) + + ;; CHECK: [fuzz-exec] calling new_empty_oob + ;; CHECK-NEXT: [trap array oob] + (func $new_empty_oob (export "new_empty_oob") (result stringref) + ;; Try to make a string from an empty array that we slice at [1:0], which is + ;; out of bounds due to the starting index. + (string.new_wtf16_array + (array.new_default $array16 + (i32.const 0) + ) + (i32.const 1) + (i32.const 0) + ) + ) + + ;; CHECK: [fuzz-exec] calling new_empty_oob_2 + ;; CHECK-NEXT: [trap array oob] + (func $new_empty_oob_2 (export "new_empty_oob_2") (result stringref) + ;; Try to make a string from an empty array that we slice at [:1], which is + ;; out of bounds due to the ending index. + (string.new_wtf16_array + (array.new_default $array16 + (i32.const 0) + ) + (i32.const 0) + (i32.const 1) + ) + ) ) ;; CHECK: [fuzz-exec] calling new_wtf16_array ;; CHECK-NEXT: [fuzz-exec] note result: new_wtf16_array => string("ello") @@ -373,6 +414,15 @@ ;; CHECK: [fuzz-exec] calling slice-big ;; CHECK-NEXT: [fuzz-exec] note result: slice-big => string("defgh") + +;; CHECK: [fuzz-exec] calling new_empty +;; CHECK-NEXT: [fuzz-exec] note result: new_empty => string("") + +;; CHECK: [fuzz-exec] calling new_empty_oob +;; CHECK-NEXT: [trap array oob] + +;; CHECK: [fuzz-exec] calling new_empty_oob_2 +;; CHECK-NEXT: [trap array oob] ;; CHECK-NEXT: [fuzz-exec] comparing compare.1 ;; CHECK-NEXT: [fuzz-exec] comparing compare.10 ;; CHECK-NEXT: [fuzz-exec] comparing compare.2 @@ -394,6 +444,9 @@ ;; CHECK-NEXT: [fuzz-exec] comparing eq.5 ;; CHECK-NEXT: [fuzz-exec] comparing get_codeunit ;; CHECK-NEXT: [fuzz-exec] comparing get_length +;; CHECK-NEXT: [fuzz-exec] comparing new_empty +;; CHECK-NEXT: [fuzz-exec] comparing new_empty_oob +;; CHECK-NEXT: [fuzz-exec] comparing new_empty_oob_2 ;; CHECK-NEXT: [fuzz-exec] comparing new_wtf16_array ;; CHECK-NEXT: [fuzz-exec] comparing slice ;; CHECK-NEXT: [fuzz-exec] comparing slice-big |