From 8642169304229dcd04a1cabff11e591e7b36c00c Mon Sep 17 00:00:00 2001 From: Andreas Rossberg Date: Tue, 22 Feb 2022 09:49:44 +0100 Subject: [PATCH 1/2] [test] Fix section size in binary test --- test/core/binary.wast | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/core/binary.wast b/test/core/binary.wast index e80d3e20b5..bc5c6d61a3 100644 --- a/test/core/binary.wast +++ b/test/core/binary.wast @@ -1774,7 +1774,7 @@ "\01\04\01" ;; type section "\60\00\00" ;; type 0 "\03\02\01\00" ;; func section - "\0a\12\01" ;; code section + "\0a\13\01" ;; code section "\11\00" ;; func 0 "\02\40" ;; block 0 "\41\01" ;; condition of if 0 From 441cef626382983b7f6bd4edb0f57ef3d4000ef8 Mon Sep 17 00:00:00 2001 From: Andreas Rossberg Date: Tue, 22 Feb 2022 11:24:50 +0100 Subject: [PATCH 2/2] More --- interpreter/binary/decode.ml | 2 +- test/core/binary.wast | 6 +++--- test/core/custom.wast | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/interpreter/binary/decode.ml b/interpreter/binary/decode.ml index 78b4667766..7ed4a9235e 100644 --- a/interpreter/binary/decode.ml +++ b/interpreter/binary/decode.ml @@ -110,7 +110,7 @@ let v128 s = V128.of_bits (get_string (Types.vec_size Types.V128Type) s) let len32 s = let pos = pos s in let n = vu32 s in - if I32.le_u n (Int32.of_int (len s)) then Int32.to_int n else + if I32.le_u n (Int32.of_int (len s - pos)) then Int32.to_int n else error s pos "length out of bounds" let bool s = (vu1 s = 1) diff --git a/test/core/binary.wast b/test/core/binary.wast index bc5c6d61a3..31bb24a937 100644 --- a/test/core/binary.wast +++ b/test/core/binary.wast @@ -1311,7 +1311,7 @@ "\60\00\00" ;; 1st type ;; "\60\00\00" ;; 2nd type (missed) ) - "unexpected end of section or function" + "length out of bounds" ) ;; 1 type declared, 2 given @@ -1600,7 +1600,7 @@ "\02\00\0b" ;; function body 0 "\02\00\0b" ;; function body 1 ) - "unexpected end of section or function" + "length out of bounds" ) ;; 1 export declared, 2 given @@ -1662,7 +1662,7 @@ "\03\02\01\00" ;; func section "\04\04\01" ;; table section "\70\00\01" ;; table 0 - "\09\07\02" ;; elem with inconsistent segment count (2 declared, 1 given) + "\09\0a\02" ;; elem with inconsistent segment count (2 declared, 1 given) "\00\41\00\0b\01\00" ;; elem 0 "\00\41\00" ;; elem 1 (partial) ;; "\0b\01\00" ;; elem 1 (missing part) diff --git a/test/core/custom.wast b/test/core/custom.wast index b2394f5e3b..12b0476503 100644 --- a/test/core/custom.wast +++ b/test/core/custom.wast @@ -86,7 +86,7 @@ "\00asm" "\01\00\00\00" "\00\26\10" "a custom section" "this is the payload" ) - "unexpected end" + "length out of bounds" ) (assert_malformed