1;; Unsigned LEB128 can have non-minimal length
2(module binary
3 "\00asm" "\01\00\00\00"
4 "\05\04\01" ;; Memory section with 1 entry
5 "\00\82\00" ;; no max, minimum 2
6)
7(module binary
8 "\00asm" "\01\00\00\00"
9 "\05\07\01" ;; Memory section with 1 entry
10 "\00\82\80\80\80\00" ;; no max, minimum 2
11)
12(module binary
13 "\00asm" "\01\00\00\00"
14 "\05\06\01" ;; Memory section with 1 entry
15 "\01\82\00" ;; minimum 2
16 "\82\00" ;; max 2
17)
18(module binary
19 "\00asm" "\01\00\00\00"
20 "\05\09\01" ;; Memory section with 1 entry
21 "\01\82\00" ;; minimum 2
22 "\82\80\80\80\00" ;; max 2
23)
24(module binary
25 "\00asm" "\01\00\00\00"
26 "\05\03\01" ;; Memory section with 1 entry
27 "\00\00" ;; no max, minimum 0
28 "\0b\07\01" ;; Data section with 1 entry
29 "\80\00" ;; Memory index 0, encoded with 2 bytes
30 "\41\00\0b\00" ;; (i32.const 0) with contents ""
31)
32(module binary
33 "\00asm" "\01\00\00\00"
34 "\04\04\01" ;; Table section with 1 entry
35 "\70\00\00" ;; no max, minimum 0, funcref
36 "\09\07\01" ;; Element section with 1 entry
37 "\80\00" ;; Table index 0, encoded with 2 bytes
38 "\41\00\0b\00" ;; (i32.const 0) with no elements
39)
40(module binary
41 "\00asm" "\01\00\00\00"
42 "\00" ;; custom section
43 "\8a\00" ;; section size 10, encoded with 2 bytes
44 "\01" ;; name byte count
45 "1" ;; name
46 "23456789" ;; sequence of bytes
47)
48(module binary
49 "\00asm" "\01\00\00\00"
50 "\00" ;; custom section
51 "\0b" ;; section size
52 "\88\00" ;; name byte count 8, encoded with 2 bytes
53 "12345678" ;; name
54 "9" ;; sequence of bytes
55)
56(module binary
57 "\00asm" "\01\00\00\00"
58 "\01\08\01" ;; type section
59 "\60" ;; func type
60 "\82\00" ;; num params 2, encoded with 2 bytes
61 "\7f\7e" ;; param type
62 "\01" ;; num results
63 "\7f" ;; result type
64)
65(module binary
66 "\00asm" "\01\00\00\00"
67 "\01\08\01" ;; type section
68 "\60" ;; func type
69 "\02" ;; num params
70 "\7f\7e" ;; param type
71 "\81\00" ;; num results 1, encoded with 2 bytes
72 "\7f" ;; result type
73)
74(module binary
75 "\00asm" "\01\00\00\00"
76 "\01\05\01" ;; type section
77 "\60\01\7f\00" ;; function type
78 "\02\17\01" ;; import section
79 "\88\00" ;; module name length 8, encoded with 2 bytes
80 "\73\70\65\63\74\65\73\74" ;; module name
81 "\09" ;; entity name length
82 "\70\72\69\6e\74\5f\69\33\32" ;; entity name
83 "\00" ;; import kind
84 "\00" ;; import signature index
85)
86(module binary
87 "\00asm" "\01\00\00\00"
88 "\01\05\01" ;; type section
89 "\60\01\7f\00" ;; function type
90 "\02\17\01" ;; import section
91 "\08" ;; module name length
92 "\73\70\65\63\74\65\73\74" ;; module name
93 "\89\00" ;; entity name length 9, encoded with 2 bytes
94 "\70\72\69\6e\74\5f\69\33\32" ;; entity name
95 "\00" ;; import kind
96 "\00" ;; import signature index
97)
98(module binary
99 "\00asm" "\01\00\00\00"
100 "\01\05\01" ;; type section
101 "\60\01\7f\00" ;; function type
102 "\02\17\01" ;; import section
103 "\08" ;; module name length
104 "\73\70\65\63\74\65\73\74" ;; module name
105 "\09" ;; entity name length 9
106 "\70\72\69\6e\74\5f\69\33\32" ;; entity name
107 "\00" ;; import kind
108 "\80\00" ;; import signature index, encoded with 2 bytes
109)
110(module binary
111 "\00asm" "\01\00\00\00"
112 "\01\04\01" ;; type section
113 "\60\00\00" ;; function type
114 "\03\03\01" ;; function section
115 "\80\00" ;; function 0 signature index, encoded with 2 bytes
116 "\0a\04\01" ;; code section
117 "\02\00\0b" ;; function body
118)
119(module binary
120 "\00asm" "\01\00\00\00"
121 "\01\04\01" ;; type section
122 "\60\00\00" ;; fun type
123 "\03\02\01\00" ;; function section
124 "\07\07\01" ;; export section
125 "\82\00" ;; string length 2, encoded with 2 bytes
126 "\66\31" ;; export name f1
127 "\00" ;; export kind
128 "\00" ;; export func index
129 "\0a\04\01" ;; code section
130 "\02\00\0b" ;; function body
131)
132(module binary
133 "\00asm" "\01\00\00\00"
134 "\01\04\01" ;; type section
135 "\60\00\00" ;; fun type
136 "\03\02\01\00" ;; function section
137 "\07\07\01" ;; export section
138 "\02" ;; string length 2
139 "\66\31" ;; export name f1
140 "\00" ;; export kind
141 "\80\00" ;; export func index, encoded with 2 bytes
142 "\0a\04\01" ;; code section
143 "\02\00\0b" ;; function body
144)
145(module binary
146 "\00asm" "\01\00\00\00"
147 "\01\04\01" ;; type section
148 "\60\00\00" ;; fun type
149 "\03\02\01\00" ;; function section
150 "\0a" ;; code section
151 "\05" ;; section size
152 "\81\00" ;; num functions, encoded with 2 bytes
153 "\02\00\0b" ;; function body
154)
155
156;; Signed LEB128 can have non-minimal length
157(module binary
158 "\00asm" "\01\00\00\00"
159 "\06\07\01" ;; Global section with 1 entry
160 "\7f\00" ;; i32, immutable
161 "\41\80\00" ;; i32.const 0
162 "\0b" ;; end
163)
164(module binary
165 "\00asm" "\01\00\00\00"
166 "\06\07\01" ;; Global section with 1 entry
167 "\7f\00" ;; i32, immutable
168 "\41\ff\7f" ;; i32.const -1
169 "\0b" ;; end
170)
171(module binary
172 "\00asm" "\01\00\00\00"
173 "\06\0a\01" ;; Global section with 1 entry
174 "\7f\00" ;; i32, immutable
175 "\41\80\80\80\80\00" ;; i32.const 0
176 "\0b" ;; end
177)
178(module binary
179 "\00asm" "\01\00\00\00"
180 "\06\0a\01" ;; Global section with 1 entry
181 "\7f\00" ;; i32, immutable
182 "\41\ff\ff\ff\ff\7f" ;; i32.const -1
183 "\0b" ;; end
184)
185
186(module binary
187 "\00asm" "\01\00\00\00"
188 "\06\07\01" ;; Global section with 1 entry
189 "\7e\00" ;; i64, immutable
190 "\42\80\00" ;; i64.const 0 with unused bits set
191 "\0b" ;; end
192)
193(module binary
194 "\00asm" "\01\00\00\00"
195 "\06\07\01" ;; Global section with 1 entry
196 "\7e\00" ;; i64, immutable
197 "\42\ff\7f" ;; i64.const -1 with unused bits unset
198 "\0b" ;; end
199)
200(module binary
201 "\00asm" "\01\00\00\00"
202 "\06\0f\01" ;; Global section with 1 entry
203 "\7e\00" ;; i64, immutable
204 "\42\80\80\80\80\80\80\80\80\80\00" ;; i64.const 0 with unused bits set
205 "\0b" ;; end
206)
207(module binary
208 "\00asm" "\01\00\00\00"
209 "\06\0f\01" ;; Global section with 1 entry
210 "\7e\00" ;; i64, immutable
211 "\42\ff\ff\ff\ff\ff\ff\ff\ff\ff\7f" ;; i64.const -1 with unused bits unset
212 "\0b" ;; end
213)
214
215;; Unsigned LEB128 must not be overlong
216(assert_malformed
217 (module binary
218 "\00asm" "\01\00\00\00"
219 "\05\08\01" ;; Memory section with 1 entry
220 "\00\82\80\80\80\80\00" ;; no max, minimum 2 with one byte too many
221 )
222 "integer representation too long"
223)
224(assert_malformed
225 (module binary
226 "\00asm" "\01\00\00\00"
227 "\05\0a\01" ;; Memory section with 1 entry
228 "\01\82\00" ;; minimum 2
229 "\82\80\80\80\80\00" ;; max 2 with one byte too many
230 )
231 "integer representation too long"
232)
233(assert_malformed
234 (module binary
235 "\00asm" "\01\00\00\00"
236 "\05\03\01" ;; Memory section with 1 entry
237 "\00\00" ;; no max, minimum 0
238 "\0b\0b\01" ;; Data section with 1 entry
239 "\80\80\80\80\80\00" ;; Memory index 0 with one byte too many
240 "\41\00\0b\00" ;; (i32.const 0) with contents ""
241 )
242 "integer representation too long"
243)
244(assert_malformed
245 (module binary
246 "\00asm" "\01\00\00\00"
247 "\04\04\01" ;; Table section with 1 entry
248 "\70\00\00" ;; no max, minimum 0, funcref
249 "\09\0b\01" ;; Element section with 1 entry
250 "\80\80\80\80\80\00" ;; Table index 0 with one byte too many
251 "\41\00\0b\00" ;; (i32.const 0) with no elements
252 )
253 "integer representation too long"
254)
255(assert_malformed
256 (module binary
257 "\00asm" "\01\00\00\00"
258 "\00" ;; custom section
259 "\83\80\80\80\80\00" ;; section size 3 with one byte too many
260 "\01" ;; name byte count
261 "1" ;; name
262 "2" ;; sequence of bytes
263 )
264 "integer representation too long"
265)
266(assert_malformed
267 (module binary
268 "\00asm" "\01\00\00\00"
269 "\00" ;; custom section
270 "\0A" ;; section size
271 "\83\80\80\80\80\00" ;; name byte count 3 with one byte too many
272 "123" ;; name
273 "4" ;; sequence of bytes
274 )
275 "integer representation too long"
276)
277(assert_malformed
278 (module binary
279 "\00asm" "\01\00\00\00"
280 "\01\0c\01" ;; type section
281 "\60" ;; func type
282 "\82\80\80\80\80\00" ;; num params 2 with one byte too many
283 "\7f\7e" ;; param type
284 "\01" ;; num result
285 "\7f" ;; result type
286 )
287 "integer representation too long"
288)
289(assert_malformed
290 (module binary
291 "\00asm" "\01\00\00\00"
292 "\01\08\01" ;; type section
293 "\60" ;; func type
294 "\02" ;; num params
295 "\7f\7e" ;; param type
296 "\81\80\80\80\80\00" ;; num result 1 with one byte too many
297 "\7f" ;; result type
298 )
299 "integer representation too long"
300)
301(assert_malformed
302 (module binary
303 "\00asm" "\01\00\00\00"
304 "\01\05\01" ;; type section
305 "\60\01\7f\00" ;; function type
306 "\02\1b\01" ;; import section
307 "\88\80\80\80\80\00" ;; module name length 8 with one byte too many
308 "\73\70\65\63\74\65\73\74" ;; module name
309 "\09" ;; entity name length
310 "\70\72\69\6e\74\5f\69\33\32" ;; entity name
311 "\00" ;; import kind
312 "\00" ;; import signature index
313 )
314 "integer representation too long"
315)
316(assert_malformed
317 (module binary
318 "\00asm" "\01\00\00\00"
319 "\01\05\01" ;; type section
320 "\60\01\7f\00" ;; function type
321 "\02\1b\01" ;; import section
322 "\08" ;; module name length
323 "\73\70\65\63\74\65\73\74" ;; module name
324 "\89\80\80\80\80\00" ;; entity name length 9 with one byte too many
325 "\70\72\69\6e\74\5f\69\33\32" ;; entity name
326 "\00" ;; import kind
327 "\00" ;; import signature index
328 )
329 "integer representation too long"
330)
331(assert_malformed
332 (module binary
333 "\00asm" "\01\00\00\00"
334 "\01\05\01" ;; type section
335 "\60\01\7f\00" ;; function type
336 "\02\1b\01" ;; import section
337 "\08" ;; module name length
338 "\73\70\65\63\74\65\73\74" ;; module name
339 "\09" ;; entity name length 9
340 "\70\72\69\6e\74\5f\69\33\32" ;; entity name
341 "\00" ;; import kind
342 "\80\80\80\80\80\00" ;; import signature index 0 with one byte too many
343 )
344 "integer representation too long"
345)
346(assert_malformed
347 (module binary
348 "\00asm" "\01\00\00\00"
349 "\01\04\01" ;; type section
350 "\60\00\00" ;; function type
351 "\03\03\01" ;; function section
352 "\80\80\80\80\80\00" ;; function 0 signature index with one byte too many
353 "\0a\04\01" ;; code section
354 "\02\00\0b" ;; function body
355 )
356 "integer representation too long"
357)
358(assert_malformed
359 (module binary
360 "\00asm" "\01\00\00\00"
361 "\01\04\01" ;; type section
362 "\60\00\00" ;; fun type
363 "\03\02\01\00" ;; function section
364 "\07\0b\01" ;; export section
365 "\82\80\80\80\80\00" ;; string length 2 with one byte too many
366 "\66\31" ;; export name f1
367 "\00" ;; export kind
368 "\00" ;; export func index
369 "\0a\04\01" ;; code section
370 "\02\00\0b" ;; function body
371 )
372 "integer representation too long"
373)
374(assert_malformed
375 (module binary
376 "\00asm" "\01\00\00\00"
377 "\01\04\01" ;; type section
378 "\60\00\00" ;; fun type
379 "\03\02\01\00" ;; function section
380 "\07\0b\01" ;; export section
381 "\02" ;; string length 2
382 "\66\31" ;; export name f1
383 "\00" ;; export kind
384 "\80\80\80\80\80\00" ;; export func index 0 with one byte too many
385 "\0a\04\01" ;; code section
386 "\02\00\0b" ;; function body
387 )
388 "integer representation too long"
389)
390(assert_malformed
391 (module binary
392 "\00asm" "\01\00\00\00"
393 "\01\04\01" ;; type section
394 "\60\00\00" ;; fun type
395 "\03\02\01\00" ;; function section
396 "\0a" ;; code section
397 "\05" ;; section size
398 "\81\80\80\80\80\00" ;; num functions 1 with one byte too many
399 "\02\00\0b" ;; function body
400 )
401 "integer representation too long"
402)
403(assert_malformed
404 (module binary
405 "\00asm" "\01\00\00\00"
406 "\01\04\01\60\00\00" ;; Type section
407 "\03\02\01\00" ;; Function section
408 "\05\03\01\00\01" ;; Memory section
409 "\0a\11\01" ;; Code section
410 ;; function 0
411 "\0f\01\01" ;; local type count
412 "\7f" ;; i32
413 "\41\00" ;; i32.const 0
414 "\28" ;; i32.load
415 "\02" ;; alignment 2
416 "\82\80\80\80\80\00" ;; offset 2 with one byte too many
417 "\1a" ;; drop
418 "\0b" ;; end
419 )
420 "integer representation too long"
421)
422(assert_malformed
423 (module binary
424 "\00asm" "\01\00\00\00"
425 "\01\04\01\60\00\00" ;; Type section
426 "\03\02\01\00" ;; Function section
427 "\05\03\01\00\01" ;; Memory section
428 "\0a\11\01" ;; Code section
429 ;; function 0
430 "\0f\01\01" ;; local type count
431 "\7f" ;; i32
432 "\41\00" ;; i32.const 0
433 "\28" ;; i32.load
434 "\82\80\80\80\80\00" ;; alignment 2 with one byte too many
435 "\00" ;; offset 0
436 "\1a" ;; drop
437 "\0b" ;; end
438 )
439 "integer representation too long"
440)
441(assert_malformed
442 (module binary
443 "\00asm" "\01\00\00\00"
444 "\01\04\01\60\00\00" ;; Type section
445 "\03\02\01\00" ;; Function section
446 "\05\03\01\00\01" ;; Memory section
447 "\0a\12\01" ;; Code section
448 ;; function 0
449 "\10\01\01" ;; local type count
450 "\7f" ;; i32
451 "\41\00" ;; i32.const 0
452 "\41\03" ;; i32.const 3
453 "\36" ;; i32.store
454 "\82\80\80\80\80\00" ;; alignment 2 with one byte too many
455 "\03" ;; offset 3
456 "\0b" ;; end
457 )
458 "integer representation too long"
459)
460(assert_malformed
461 (module binary
462 "\00asm" "\01\00\00\00"
463 "\01\04\01\60\00\00" ;; Type section
464 "\03\02\01\00" ;; Function section
465 "\05\03\01\00\01" ;; Memory section
466 "\0a\12\01" ;; Code section
467 ;; function 0
468 "\10\01\01" ;; local type count
469 "\7f" ;; i32
470 "\41\00" ;; i32.const 0
471 "\41\03" ;; i32.const 3
472 "\36" ;; i32.store
473 "\02" ;; alignment 2
474 "\82\80\80\80\80\00" ;; offset 2 with one byte too many
475 "\0b" ;; end
476 )
477 "integer representation too long"
478)
479
480;; Signed LEB128 must not be overlong
481(assert_malformed
482 (module binary
483 "\00asm" "\01\00\00\00"
484 "\06\0b\01" ;; Global section with 1 entry
485 "\7f\00" ;; i32, immutable
486 "\41\80\80\80\80\80\00" ;; i32.const 0 with one byte too many
487 "\0b" ;; end
488 )
489 "integer representation too long"
490)
491(assert_malformed
492 (module binary
493 "\00asm" "\01\00\00\00"
494 "\06\0b\01" ;; Global section with 1 entry
495 "\7f\00" ;; i32, immutable
496 "\41\ff\ff\ff\ff\ff\7f" ;; i32.const -1 with one byte too many
497 "\0b" ;; end
498 )
499 "integer representation too long"
500)
501
502(assert_malformed
503 (module binary
504 "\00asm" "\01\00\00\00"
505 "\06\10\01" ;; Global section with 1 entry
506 "\7e\00" ;; i64, immutable
507 "\42\80\80\80\80\80\80\80\80\80\80\00" ;; i64.const 0 with one byte too many
508 "\0b" ;; end
509 )
510 "integer representation too long"
511)
512(assert_malformed
513 (module binary
514 "\00asm" "\01\00\00\00"
515 "\06\10\01" ;; Global section with 1 entry
516 "\7e\00" ;; i64, immutable
517 "\42\ff\ff\ff\ff\ff\ff\ff\ff\ff\ff\7f" ;; i64.const -1 with one byte too many
518 "\0b" ;; end
519 )
520 "integer representation too long"
521)
522
523;; Unsigned LEB128s zero-extend
524(assert_malformed
525 (module binary
526 "\00asm" "\01\00\00\00"
527 "\05\07\01" ;; Memory section with 1 entry
528 "\00\82\80\80\80\70" ;; no max, minimum 2 with unused bits set
529 )
530 "integer too large"
531)
532(assert_malformed
533 (module binary
534 "\00asm" "\01\00\00\00"
535 "\05\07\01" ;; Memory section with 1 entry
536 "\00\82\80\80\80\40" ;; no max, minimum 2 with some unused bits set
537 )
538 "integer too large"
539)
540(assert_malformed
541 (module binary
542 "\00asm" "\01\00\00\00"
543 "\05\09\01" ;; Memory section with 1 entry
544 "\01\82\00" ;; minimum 2
545 "\82\80\80\80\10" ;; max 2 with unused bits set
546 )
547 "integer too large"
548)
549(assert_malformed
550 (module binary
551 "\00asm" "\01\00\00\00"
552 "\05\09\01" ;; Memory section with 1 entry
553 "\01\82\00" ;; minimum 2
554 "\82\80\80\80\40" ;; max 2 with some unused bits set
555 )
556 "integer too large"
557)
558(assert_malformed
559 (module binary
560 "\00asm" "\01\00\00\00"
561 "\05\03\01" ;; Memory section with 1 entry
562 "\00\00" ;; no max, minimum 0
563 "\0b\0a\01" ;; Data section with 1 entry
564 "\80\80\80\80\10" ;; Memory index 0 with unused bits set
565 "\41\00\0b\00" ;; (i32.const 0) with contents ""
566 )
567 "integer too large"
568)
569(assert_malformed
570 (module binary
571 "\00asm" "\01\00\00\00"
572 "\04\04\01" ;; Table section with 1 entry
573 "\70\00\00" ;; no max, minimum 0, funcref
574 "\09\0a\01" ;; Element section with 1 entry
575 "\80\80\80\80\10" ;; Table index 0 with unused bits set
576 "\41\00\0b\00" ;; (i32.const 0) with no elements
577 )
578 "integer too large"
579)
580(assert_malformed
581 (module binary
582 "\00asm" "\01\00\00\00"
583 "\00" ;; custom section
584 "\83\80\80\80\10" ;; section size 3 with unused bits set
585 "\01" ;; name byte count
586 "1" ;; name
587 "2" ;; sequence of bytes
588 )
589 "integer too large"
590)
591(assert_malformed
592 (module binary
593 "\00asm" "\01\00\00\00"
594 "\00" ;; custom section
595 "\09" ;; section size
596 "\83\80\80\80\40" ;; name byte count 3 with unused bits set
597 "123" ;; name
598 "4" ;; sequence of bytes
599 )
600 "integer too large"
601)
602(assert_malformed
603 (module binary
604 "\00asm" "\01\00\00\00"
605 "\01\0b\01" ;; type section
606 "\60" ;; func type
607 "\82\80\80\80\10" ;; num params 2 with unused bits set
608 "\7f\7e" ;; param type
609 "\01" ;; num result
610 "\7f" ;; result type
611 )
612 "integer too large"
613)
614(assert_malformed
615 (module binary
616 "\00asm" "\01\00\00\00"
617 "\01\0b\01" ;; type section
618 "\60" ;; func type
619 "\02" ;; num params
620 "\7f\7e" ;; param type
621 "\81\80\80\80\40" ;; num result 1 with unused bits set
622 "\7f" ;; result type
623 )
624 "integer too large"
625)
626(assert_malformed
627 (module binary
628 "\00asm" "\01\00\00\00"
629 "\01\05\01" ;; type section
630 "\60\01\7f\00" ;; function type
631 "\02\1a\01" ;; import section
632 "\88\80\80\80\10" ;; module name length 8 with unused bits set
633 "\73\70\65\63\74\65\73\74" ;; module name
634 "\09" ;; entity name length
635 "\70\72\69\6e\74\5f\69\33\32" ;; entity name
636 "\00" ;; import kind
637 "\00" ;; import signature index
638 )
639 "integer too large"
640)
641(assert_malformed
642 (module binary
643 "\00asm" "\01\00\00\00"
644 "\01\05\01" ;; type section
645 "\60\01\7f\00" ;; function type
646 "\02\1a\01" ;; import section
647 "\08" ;; module name length
648 "\73\70\65\63\74\65\73\74" ;; module name
649 "\89\80\80\80\40" ;; entity name length 9 with unused bits set
650 "\70\72\69\6e\74\5f\69\33\32" ;; entity name
651 "\00" ;; import kind
652 "\00" ;; import signature index
653 )
654 "integer too large"
655)
656(assert_malformed
657(module binary
658 "\00asm" "\01\00\00\00"
659 "\01\05\01" ;; type section
660 "\60\01\7f\00" ;; function type
661 "\02\1a\01" ;; import section
662 "\08" ;; module name length
663 "\73\70\65\63\74\65\73\74" ;; module name
664 "\09" ;; entity name length 9
665 "\70\72\69\6e\74\5f\69\33\32" ;; entity name
666 "\00" ;; import kind
667 "\80\80\80\80\10" ;; import signature index 0 with unused bits set
668)
669 "integer too large"
670)
671(assert_malformed
672 (module binary
673 "\00asm" "\01\00\00\00"
674 "\01\04\01" ;; type section
675 "\60\00\00" ;; function type
676 "\03\06\01" ;; function section
677 "\80\80\80\80\10" ;; function 0 signature index with unused bits set
678 "\0a\04\01" ;; code section
679 "\02\00\0b" ;; function body
680 )
681 "integer too large"
682)
683
684(assert_malformed
685 (module binary
686 "\00asm" "\01\00\00\00"
687 "\01\04\01" ;; type section
688 "\60\00\00" ;; fun type
689 "\03\02\01\00" ;; function section
690 "\07\0a\01" ;; export section
691 "\82\80\80\80\10" ;; string length 2 with unused bits set
692 "\66\31" ;; export name f1
693 "\00" ;; export kind
694 "\00" ;; export func index
695 "\0a\04\01" ;; code section
696 "\02\00\0b" ;; function body
697 )
698 "integer too large"
699)
700(assert_malformed
701 (module binary
702 "\00asm" "\01\00\00\00"
703 "\01\04\01" ;; type section
704 "\60\00\00" ;; fun type
705 "\03\02\01\00" ;; function section
706 "\07\0a\01" ;; export section
707 "\02" ;; string length 2
708 "\66\31" ;; export name f1
709 "\00" ;; export kind
710 "\80\80\80\80\10" ;; export func index with unused bits set
711 "\0a\04\01" ;; code section
712 "\02\00\0b" ;; function body
713 )
714 "integer too large"
715)
716(assert_malformed
717 (module binary
718 "\00asm" "\01\00\00\00"
719 "\01\04\01" ;; type section
720 "\60\00\00" ;; fun type
721 "\03\02\01\00" ;; function section
722 "\0a" ;; code section
723 "\08" ;; section size
724 "\81\80\80\80\10" ;; num functions 1 with unused bits set
725 "\02\00\0b" ;; function body
726 )
727 "integer too large"
728)
729(assert_malformed
730 (module binary
731 "\00asm" "\01\00\00\00"
732 "\01\04\01\60\00\00" ;; Type section
733 "\03\02\01\00" ;; Function section
734 "\05\03\01\00\01" ;; Memory section
735 "\0a\10\01" ;; Code section
736 ;; function 0
737 "\0e\01\01" ;; local type count
738 "\7f" ;; i32
739 "\41\00" ;; i32.const 0
740 "\28" ;; i32.load
741 "\02" ;; alignment 2
742 "\82\80\80\80\10" ;; offset 2 with unused bits set
743 "\1a" ;; drop
744 "\0b" ;; end
745 )
746 "integer too large"
747)
748(assert_malformed
749 (module binary
750 "\00asm" "\01\00\00\00"
751 "\01\04\01\60\00\00" ;; Type section
752 "\03\02\01\00" ;; Function section
753 "\05\03\01\00\01" ;; Memory section
754 "\0a\10\01" ;; Code section
755 ;; function 0
756 "\0e\01\01" ;; local type count
757 "\7f" ;; i32
758 "\41\00" ;; i32.const 0
759 "\28" ;; i32.load
760 "\02" ;; alignment 2
761 "\82\80\80\80\40" ;; offset 2 with some unused bits set
762 "\1a" ;; drop
763 "\0b" ;; end
764 )
765 "integer too large"
766)
767(assert_malformed
768 (module binary
769 "\00asm" "\01\00\00\00"
770 "\01\04\01\60\00\00" ;; Type section
771 "\03\02\01\00" ;; Function section
772 "\05\03\01\00\01" ;; Memory section
773 "\0a\10\01" ;; Code section
774 "\0e\01\01" ;; local type count
775 "\7f" ;; i32
776 "\41\00" ;; i32.const 0
777 "\28" ;; i32.load
778 "\82\80\80\80\10" ;; alignment 2 with unused bits set
779 "\00" ;; offset 0
780 "\1a" ;; drop
781 "\0b" ;; end
782 )
783 "integer too large"
784)
785(assert_malformed
786 (module binary
787 "\00asm" "\01\00\00\00"
788 "\01\04\01\60\00\00" ;; Type section
789 "\03\02\01\00" ;; Function section
790 "\05\03\01\00\01" ;; Memory section
791 "\0a\10\01" ;; Code section
792 ;; function 0
793 "\0e\01\01" ;; local type count
794 "\7f" ;; i32
795 "\41\00" ;; i32.const 0
796 "\28" ;; i32.load
797 "\82\80\80\80\40" ;; alignment 2 with some unused bits set
798 "\00" ;; offset 0
799 "\1a" ;; drop
800 "\0b" ;; end
801 )
802 "integer too large"
803)
804(assert_malformed
805 (module binary
806 "\00asm" "\01\00\00\00"
807 "\01\04\01\60\00\00" ;; Type section
808 "\03\02\01\00" ;; Function section
809 "\05\03\01\00\01" ;; Memory section
810 "\0a\11\01" ;; Code section
811 ;; function 0
812 "\0f\01\01" ;; local type count
813 "\7f" ;; i32
814 "\41\00" ;; i32.const 0
815 "\41\03" ;; i32.const 3
816 "\36" ;; i32.store
817 "\82\80\80\80\10" ;; alignment 2 with unused bits set
818 "\03" ;; offset 3
819 "\0b" ;; end
820 )
821 "integer too large"
822)
823(assert_malformed
824 (module binary
825 "\00asm" "\01\00\00\00"
826 "\01\04\01\60\00\00" ;; Type section
827 "\03\02\01\00" ;; Function section
828 "\05\03\01\00\01" ;; Memory section
829 "\0a\11\01" ;; Code section
830 ;; function 0
831 "\0f\01\01" ;; local type count
832 "\7f" ;; i32
833 "\41\00" ;; i32.const 0
834 "\41\03" ;; i32.const 3
835 "\36" ;; i32.store
836 "\82\80\80\80\40" ;; alignment 2 with some unused bits set
837 "\03" ;; offset 3
838 "\0b" ;; end
839 )
840 "integer too large"
841)
842(assert_malformed
843 (module binary
844 "\00asm" "\01\00\00\00"
845 "\01\04\01\60\00\00" ;; Type section
846 "\03\02\01\00" ;; Function section
847 "\05\03\01\00\01" ;; Memory section
848 "\0a\11\01" ;; Code section
849 ;; function 0
850 "\0f\01\01" ;; local type count
851 "\7f" ;; i32
852 "\41\00" ;; i32.const 0
853 "\41\03" ;; i32.const 3
854 "\36" ;; i32.store
855 "\03" ;; alignment 2
856 "\82\80\80\80\10" ;; offset 2 with unused bits set
857 "\0b" ;; end
858 )
859 "integer too large"
860)
861(assert_malformed
862 (module binary
863 "\00asm" "\01\00\00\00"
864 "\01\04\01\60\00\00" ;; Type section
865 "\03\02\01\00" ;; Function section
866 "\05\03\01\00\01" ;; Memory section
867 "\0a\11\01" ;; Code section
868
869 ;; function 0
870 "\0f\01\01" ;; local type count
871 "\7f" ;; i32
872 "\41\00" ;; i32.const 0
873 "\41\03" ;; i32.const 3
874 "\36" ;; i32.store
875 "\02" ;; alignment 2
876 "\82\80\80\80\40" ;; offset 2 with some unused bits set
877 "\0b" ;; end
878 )
879 "integer too large"
880)
881
882;; Signed LEB128s sign-extend
883(assert_malformed
884 (module binary
885 "\00asm" "\01\00\00\00"
886 "\06\0a\01" ;; Global section with 1 entry
887 "\7f\00" ;; i32, immutable
888 "\41\80\80\80\80\70" ;; i32.const 0 with unused bits set
889 "\0b" ;; end
890 )
891 "integer too large"
892)
893(assert_malformed
894 (module binary
895 "\00asm" "\01\00\00\00"
896 "\06\0a\01" ;; Global section with 1 entry
897 "\7f\00" ;; i32, immutable
898 "\41\ff\ff\ff\ff\0f" ;; i32.const -1 with unused bits unset
899 "\0b" ;; end
900 )
901 "integer too large"
902)
903(assert_malformed
904 (module binary
905 "\00asm" "\01\00\00\00"
906 "\06\0a\01" ;; Global section with 1 entry
907 "\7f\00" ;; i32, immutable
908 "\41\80\80\80\80\1f" ;; i32.const 0 with some unused bits set
909 "\0b" ;; end
910 )
911 "integer too large"
912)
913(assert_malformed
914 (module binary
915 "\00asm" "\01\00\00\00"
916 "\06\0a\01" ;; Global section with 1 entry
917 "\7f\00" ;; i32, immutable
918 "\41\ff\ff\ff\ff\4f" ;; i32.const -1 with some unused bits unset
919 "\0b" ;; end
920 )
921 "integer too large"
922)
923
924(assert_malformed
925 (module binary
926 "\00asm" "\01\00\00\00"
927 "\06\0f\01" ;; Global section with 1 entry
928 "\7e\00" ;; i64, immutable
929 "\42\80\80\80\80\80\80\80\80\80\7e" ;; i64.const 0 with unused bits set
930 "\0b" ;; end
931 )
932 "integer too large"
933)
934(assert_malformed
935 (module binary
936 "\00asm" "\01\00\00\00"
937 "\06\0f\01" ;; Global section with 1 entry
938 "\7e\00" ;; i64, immutable
939 "\42\ff\ff\ff\ff\ff\ff\ff\ff\ff\01" ;; i64.const -1 with unused bits unset
940 "\0b" ;; end
941 )
942 "integer too large"
943)
944(assert_malformed
945 (module binary
946 "\00asm" "\01\00\00\00"
947 "\06\0f\01" ;; Global section with 1 entry
948 "\7e\00" ;; i64, immutable
949 "\42\80\80\80\80\80\80\80\80\80\02" ;; i64.const 0 with some unused bits set
950 "\0b" ;; end
951 )
952 "integer too large"
953)
954(assert_malformed
955 (module binary
956 "\00asm" "\01\00\00\00"
957 "\06\0f\01" ;; Global section with 1 entry
958 "\7e\00" ;; i64, immutable
959 "\42\ff\ff\ff\ff\ff\ff\ff\ff\ff\41" ;; i64.const -1 with some unused bits unset
960 "\0b" ;; end
961 )
962 "integer too large"
963)
View as plain text