Skip to content

Commit

Permalink
add some test code for memory bounds check
Browse files Browse the repository at this point in the history
  • Loading branch information
yamt committed Aug 14, 2024
1 parent 0be3938 commit c9967c7
Show file tree
Hide file tree
Showing 8 changed files with 97 additions and 0 deletions.
13 changes: 13 additions & 0 deletions test/integer_overflow/blit_1bpp_overflow.wat
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
(module
(func $blit (import "env" "blit") (param i32 i32 i32 i32 i32 i32))
(memory (import "env" "memory") 1 1)
(func (export "update")
i32.const 0
i32.const 0
i32.const 0
i32.const 0x10
i32.const 0x10000001
i32.const 0
call $blit
)
)
13 changes: 13 additions & 0 deletions test/integer_overflow/blit_2bpp_overflow.wat
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
(module
(func $blit (import "env" "blit") (param i32 i32 i32 i32 i32 i32))
(memory (import "env" "memory") 1 1)
(func (export "update")
i32.const 0
i32.const 0
i32.const 0
i32.const 0x8
i32.const 0x10000001
i32.const 1
call $blit
)
)
13 changes: 13 additions & 0 deletions test/out_of_bands_memory_access/blit_1bpp.wat
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
(module
(func $blit (import "env" "blit") (param i32 i32 i32 i32 i32 i32))
(memory (import "env" "memory") 1 1)
(func (export "update")
i32.const 65529
i32.const 0
i32.const 0
i32.const 8
i32.const 8
i32.const 0
call $blit
)
)
13 changes: 13 additions & 0 deletions test/out_of_bands_memory_access/blit_2bpp.wat
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
(module
(func $blit (import "env" "blit") (param i32 i32 i32 i32 i32 i32))
(memory (import "env" "memory") 1 1)
(func (export "update")
i32.const 65521
i32.const 0
i32.const 0
i32.const 8
i32.const 8
i32.const 1
call $blit
)
)
10 changes: 10 additions & 0 deletions test/out_of_bands_memory_access/tracef_double.wat
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
(module
(func $tracef (import "env" "tracef") (param i32 i32))
(memory (import "env" "memory") 1 1)
(func (export "update")
i32.const 50000
i32.const 65529
call $tracef
)
(data (i32.const 50000) "%f\00")
)
10 changes: 10 additions & 0 deletions test/out_of_bands_memory_access/tracef_fmt.wat
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
(module
(func $tracef (import "env" "tracef") (param i32 i32))
(memory (import "env" "memory") 1 1)
(func (export "update")
i32.const 65533
i32.const 0
call $tracef
)
(data (i32.const 65533) "xxx")
)
15 changes: 15 additions & 0 deletions test/out_of_bands_memory_access/tracef_str.wat
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
(module
(func $tracef (import "env" "tracef") (param i32 i32))
(memory (import "env" "memory") 1 1)
(func (export "update")
i32.const 40000
i32.const 65533
i32.store

i32.const 50000
i32.const 40000
call $tracef
)
(data (i32.const 50000) "%s\00")
(data (i32.const 65533) "xxx")
)
10 changes: 10 additions & 0 deletions test/out_of_bands_memory_access/tracef_strptr.wat
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
(module
(func $tracef (import "env" "tracef") (param i32 i32))
(memory (import "env" "memory") 1 1)
(func (export "update")
i32.const 50000
i32.const 65533
call $tracef
)
(data (i32.const 50000) "%s\00")
)

0 comments on commit c9967c7

Please sign in to comment.