Skip to content

Commit 022589c

Browse files
Honryrossberg
authored andcommitted
[test] More tests for overlong LEB128 (#1016)
1 parent 5f240d1 commit 022589c

File tree

1 file changed

+179
-0
lines changed

1 file changed

+179
-0
lines changed

test/core/binary.wast

Lines changed: 179 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,185 @@
267267
)
268268
"integer representation too long"
269269
)
270+
(assert_malformed
271+
(module binary
272+
"\00asm" "\01\00\00\00"
273+
"\05\0a\01" ;; Memory section with 1 entry
274+
"\01\82\00" ;; minimum 2
275+
"\82\80\80\80\80\00" ;; max 2 with one byte too many
276+
)
277+
"integer representation too long"
278+
)
279+
(assert_malformed
280+
(module binary
281+
"\00asm" "\01\00\00\00"
282+
"\05\03\01" ;; Memory section with 1 entry
283+
"\00\00" ;; no max, minimum 0
284+
"\0b\0b\01" ;; Data section with 1 entry
285+
"\80\80\80\80\80\00" ;; Memory index 0 with one byte too many
286+
"\41\00\0b\00" ;; (i32.const 0) with contents ""
287+
)
288+
"integer representation too long"
289+
)
290+
(assert_malformed
291+
(module binary
292+
"\00asm" "\01\00\00\00"
293+
"\04\04\01" ;; Table section with 1 entry
294+
"\70\00\00" ;; no max, minimum 0, funcref
295+
"\09\0b\01" ;; Element section with 1 entry
296+
"\80\80\80\80\80\00" ;; Table index 0 with one byte too many
297+
"\41\00\0b\00" ;; (i32.const 0) with no elements
298+
)
299+
"integer representation too long"
300+
)
301+
(assert_malformed
302+
(module binary
303+
"\00asm" "\01\00\00\00"
304+
"\00" ;; custom section
305+
"\83\80\80\80\80\00" ;; section size 3 with one byte too many
306+
"\01" ;; name byte count
307+
"1" ;; name
308+
"2" ;; sequence of bytes
309+
)
310+
"integer representation too long"
311+
)
312+
(assert_malformed
313+
(module binary
314+
"\00asm" "\01\00\00\00"
315+
"\00" ;; custom section
316+
"\05" ;; section size
317+
"\83\80\80\80\80\00" ;; name byte count 3 with one byte too many
318+
"123" ;; name
319+
"4" ;; sequence of bytes
320+
)
321+
"integer representation too long"
322+
)
323+
(assert_malformed
324+
(module binary
325+
"\00asm" "\01\00\00\00"
326+
"\01\08\01" ;; type section
327+
"\60" ;; func type
328+
"\82\80\80\80\80\00" ;; num params 2 with one byte too many
329+
"\7f\7e" ;; param type
330+
"\01" ;; num result
331+
"\7f" ;; result type
332+
)
333+
"integer representation too long"
334+
)
335+
(assert_malformed
336+
(module binary
337+
"\00asm" "\01\00\00\00"
338+
"\01\08\01" ;; type section
339+
"\60" ;; func type
340+
"\02" ;; num params
341+
"\7f\7e" ;; param type
342+
"\81\80\80\80\80\00" ;; num result 1 with one byte too many
343+
"\7f" ;; result type
344+
)
345+
"integer representation too long"
346+
)
347+
(assert_malformed
348+
(module binary
349+
"\00asm" "\01\00\00\00"
350+
"\01\05\01" ;; type section
351+
"\60\01\7f\00" ;; function type
352+
"\02\1b\01" ;; import section
353+
"\88\80\80\80\80\00" ;; module name length 8 with one byte too many
354+
"\73\70\65\63\74\65\73\74" ;; module name
355+
"\09" ;; entity name length
356+
"\70\72\69\6e\74\5f\69\33\32" ;; entity name
357+
"\00" ;; import kind
358+
"\00" ;; import signature index
359+
)
360+
"integer representation too long"
361+
)
362+
(assert_malformed
363+
(module binary
364+
"\00asm" "\01\00\00\00"
365+
"\01\05\01" ;; type section
366+
"\60\01\7f\00" ;; function type
367+
"\02\1b\01" ;; import section
368+
"\08" ;; module name length
369+
"\73\70\65\63\74\65\73\74" ;; module name
370+
"\89\80\80\80\80\00" ;; entity name length 9 with one byte too many
371+
"\70\72\69\6e\74\5f\69\33\32" ;; entity name
372+
"\00" ;; import kind
373+
"\00" ;; import signature index
374+
)
375+
"integer representation too long"
376+
)
377+
(assert_malformed
378+
(module binary
379+
"\00asm" "\01\00\00\00"
380+
"\01\05\01" ;; type section
381+
"\60\01\7f\00" ;; function type
382+
"\02\1b\01" ;; import section
383+
"\08" ;; module name length
384+
"\73\70\65\63\74\65\73\74" ;; module name
385+
"\09" ;; entity name length 9
386+
"\70\72\69\6e\74\5f\69\33\32" ;; entity name
387+
"\00" ;; import kind
388+
"\80\80\80\80\80\00" ;; import signature index 0 with one byte too many
389+
)
390+
"integer representation too long"
391+
)
392+
(assert_malformed
393+
(module binary
394+
"\00asm" "\01\00\00\00"
395+
"\01\04\01" ;; type section
396+
"\60\00\00" ;; function type
397+
"\03\03\01" ;; function section
398+
"\80\80\80\80\80\00" ;; function 0 signature index with one byte too many
399+
"\0a\04\01" ;; code section
400+
"\02\00\0b" ;; function body
401+
)
402+
"integer representation too long"
403+
)
404+
(assert_malformed
405+
(module binary
406+
"\00asm" "\01\00\00\00"
407+
"\01\04\01" ;; type section
408+
"\60\00\00" ;; fun type
409+
"\03\02\01\00" ;; function section
410+
"\07\0b\01" ;; export section
411+
"\82\80\80\80\80\00" ;; string length 2 with one byte too many
412+
"\66\31" ;; export name f1
413+
"\00" ;; export kind
414+
"\00" ;; export func index
415+
"\0a\04\01" ;; code section
416+
"\02\00\0b" ;; function body
417+
)
418+
"integer representation too long"
419+
)
420+
(assert_malformed
421+
(module binary
422+
"\00asm" "\01\00\00\00"
423+
"\01\04\01" ;; type section
424+
"\60\00\00" ;; fun type
425+
"\03\02\01\00" ;; function section
426+
"\07\0b\01" ;; export section
427+
"\02" ;; string length 2
428+
"\66\31" ;; export name f1
429+
"\00" ;; export kind
430+
"\80\80\80\80\80\00" ;; export func index 0 with one byte too many
431+
"\0a\04\01" ;; code section
432+
"\02\00\0b" ;; function body
433+
)
434+
"integer representation too long"
435+
)
436+
(assert_malformed
437+
(module binary
438+
"\00asm" "\01\00\00\00"
439+
"\01\04\01" ;; type section
440+
"\60\00\00" ;; fun type
441+
"\03\02\01\00" ;; function section
442+
"\0a" ;; code section
443+
"\05" ;; section size
444+
"\81\80\80\80\80\00" ;; num functions 1 with one byte too many
445+
"\02\00\0b" ;; function body
446+
)
447+
"integer representation too long"
448+
)
270449
(assert_malformed
271450
(module binary
272451
"\00asm" "\01\00\00\00"

0 commit comments

Comments
 (0)