|
114 | 114 | "\0b" ;; end
|
115 | 115 | )
|
116 | 116 |
|
| 117 | +;; Data segment memory index can have non-minimal length |
| 118 | +(module binary |
| 119 | + "\00asm" "\01\00\00\00" |
| 120 | + "\05\03\01" ;; Memory section with 1 entry |
| 121 | + "\00\00" ;; no max, minimum 0 |
| 122 | + "\0b\07\01" ;; Data section with 1 entry |
| 123 | + "\80\00" ;; Memory index 0, encoded with 2 bytes |
| 124 | + "\41\00\0b\00" ;; (i32.const 0) with contents "" |
| 125 | +) |
| 126 | + |
| 127 | +;; Element segment table index can have non-minimal length |
| 128 | +(module binary |
| 129 | + "\00asm" "\01\00\00\00" |
| 130 | + "\04\04\01" ;; Table section with 1 entry |
| 131 | + "\70\00\00" ;; no max, minimum 0, anyfunc |
| 132 | + "\09\07\01" ;; Element section with 1 entry |
| 133 | + "\80\00" ;; Table index 0, encoded with 2 bytes |
| 134 | + "\41\00\0b\00" ;; (i32.const 0) with no elements |
| 135 | +) |
| 136 | + |
117 | 137 | ;; Unsigned LEB128 must not be overlong
|
118 | 138 | (assert_malformed
|
119 | 139 | (module binary
|
|
287 | 307 | "zero flag expected"
|
288 | 308 | )
|
289 | 309 |
|
| 310 | +;; call_indirect reserved byte should not be a "long" LEB128 zero. |
| 311 | +(assert_malformed |
| 312 | + (module binary |
| 313 | + "\00asm" "\01\00\00\00" |
| 314 | + "\01\04\01\60\00\00" ;; Type section |
| 315 | + "\03\02\01\00" ;; Function section |
| 316 | + "\04\04\01\70\00\00" ;; Table section |
| 317 | + "\0a\0a\01" ;; Code section |
| 318 | + |
| 319 | + ;; function 0 |
| 320 | + "\07\00" |
| 321 | + "\41\00" ;; i32.const 0 |
| 322 | + "\11\00" ;; call_indirect (type 0) |
| 323 | + "\80\00" ;; call_indirect reserved byte |
| 324 | + "\0b" ;; end |
| 325 | + ) |
| 326 | + "zero flag expected" |
| 327 | +) |
| 328 | + |
| 329 | +;; Same as above for 3, 4, and 5-byte zero encodings. |
| 330 | +(assert_malformed |
| 331 | + (module binary |
| 332 | + "\00asm" "\01\00\00\00" |
| 333 | + "\01\04\01\60\00\00" ;; Type section |
| 334 | + "\03\02\01\00" ;; Function section |
| 335 | + "\04\04\01\70\00\00" ;; Table section |
| 336 | + "\0a\0b\01" ;; Code section |
| 337 | + |
| 338 | + ;; function 0 |
| 339 | + "\08\00" |
| 340 | + "\41\00" ;; i32.const 0 |
| 341 | + "\11\00" ;; call_indirect (type 0) |
| 342 | + "\80\80\00" ;; call_indirect reserved byte |
| 343 | + "\0b" ;; end |
| 344 | + ) |
| 345 | + "zero flag expected" |
| 346 | +) |
| 347 | + |
| 348 | +(assert_malformed |
| 349 | + (module binary |
| 350 | + "\00asm" "\01\00\00\00" |
| 351 | + "\01\04\01\60\00\00" ;; Type section |
| 352 | + "\03\02\01\00" ;; Function section |
| 353 | + "\04\04\01\70\00\00" ;; Table section |
| 354 | + "\0a\0c\01" ;; Code section |
| 355 | + |
| 356 | + ;; function 0 |
| 357 | + "\09\00" |
| 358 | + "\41\00" ;; i32.const 0 |
| 359 | + "\11\00" ;; call_indirect (type 0) |
| 360 | + "\80\80\80\00" ;; call_indirect reserved byte |
| 361 | + "\0b" ;; end |
| 362 | + ) |
| 363 | + "zero flag expected" |
| 364 | +) |
| 365 | + |
| 366 | +(assert_malformed |
| 367 | + (module binary |
| 368 | + "\00asm" "\01\00\00\00" |
| 369 | + "\01\04\01\60\00\00" ;; Type section |
| 370 | + "\03\02\01\00" ;; Function section |
| 371 | + "\04\04\01\70\00\00" ;; Table section |
| 372 | + "\0a\0d\01" ;; Code section |
| 373 | + |
| 374 | + ;; function 0 |
| 375 | + "\0a\00" |
| 376 | + "\41\00" ;; i32.const 0 |
| 377 | + "\11\00" ;; call_indirect (type 0) |
| 378 | + "\80\80\80\80\00" ;; call_indirect reserved byte |
| 379 | + "\0b" ;; end |
| 380 | + ) |
| 381 | + "zero flag expected" |
| 382 | +) |
| 383 | + |
290 | 384 | ;; memory.grow reserved byte equal to zero.
|
291 | 385 | (assert_malformed
|
292 | 386 | (module binary
|
|
307 | 401 | "zero flag expected"
|
308 | 402 | )
|
309 | 403 |
|
| 404 | +;; memory.grow reserved byte should not be a "long" LEB128 zero. |
| 405 | +(assert_malformed |
| 406 | + (module binary |
| 407 | + "\00asm" "\01\00\00\00" |
| 408 | + "\01\04\01\60\00\00" ;; Type section |
| 409 | + "\03\02\01\00" ;; Function section |
| 410 | + "\05\03\01\00\00" ;; Memory section |
| 411 | + "\0a\0a\01" ;; Code section |
| 412 | + |
| 413 | + ;; function 0 |
| 414 | + "\08\00" |
| 415 | + "\41\00" ;; i32.const 0 |
| 416 | + "\40" ;; memory.grow |
| 417 | + "\80\00" ;; memory.grow reserved byte |
| 418 | + "\1a" ;; drop |
| 419 | + "\0b" ;; end |
| 420 | + ) |
| 421 | + "zero flag expected" |
| 422 | +) |
| 423 | + |
| 424 | +;; Same as above for 3, 4, and 5-byte zero encodings. |
| 425 | +(assert_malformed |
| 426 | + (module binary |
| 427 | + "\00asm" "\01\00\00\00" |
| 428 | + "\01\04\01\60\00\00" ;; Type section |
| 429 | + "\03\02\01\00" ;; Function section |
| 430 | + "\05\03\01\00\00" ;; Memory section |
| 431 | + "\0a\0b\01" ;; Code section |
| 432 | + |
| 433 | + ;; function 0 |
| 434 | + "\09\00" |
| 435 | + "\41\00" ;; i32.const 0 |
| 436 | + "\40" ;; memory.grow |
| 437 | + "\80\80\00" ;; memory.grow reserved byte |
| 438 | + "\1a" ;; drop |
| 439 | + "\0b" ;; end |
| 440 | + ) |
| 441 | + "zero flag expected" |
| 442 | +) |
| 443 | + |
| 444 | +(assert_malformed |
| 445 | + (module binary |
| 446 | + "\00asm" "\01\00\00\00" |
| 447 | + "\01\04\01\60\00\00" ;; Type section |
| 448 | + "\03\02\01\00" ;; Function section |
| 449 | + "\05\03\01\00\00" ;; Memory section |
| 450 | + "\0a\0c\01" ;; Code section |
| 451 | + |
| 452 | + ;; function 0 |
| 453 | + "\0a\00" |
| 454 | + "\41\00" ;; i32.const 0 |
| 455 | + "\40" ;; memory.grow |
| 456 | + "\80\80\80\00" ;; memory.grow reserved byte |
| 457 | + "\1a" ;; drop |
| 458 | + "\0b" ;; end |
| 459 | + ) |
| 460 | + "zero flag expected" |
| 461 | +) |
| 462 | + |
| 463 | +(assert_malformed |
| 464 | + (module binary |
| 465 | + "\00asm" "\01\00\00\00" |
| 466 | + "\01\04\01\60\00\00" ;; Type section |
| 467 | + "\03\02\01\00" ;; Function section |
| 468 | + "\05\03\01\00\00" ;; Memory section |
| 469 | + "\0a\0d\01" ;; Code section |
| 470 | + |
| 471 | + ;; function 0 |
| 472 | + "\0b\00" |
| 473 | + "\41\00" ;; i32.const 0 |
| 474 | + "\40" ;; memory.grow |
| 475 | + "\80\80\80\80\00" ;; memory.grow reserved byte |
| 476 | + "\1a" ;; drop |
| 477 | + "\0b" ;; end |
| 478 | + ) |
| 479 | + "zero flag expected" |
| 480 | +) |
| 481 | + |
310 | 482 | ;; memory.size reserved byte equal to zero.
|
311 | 483 | (assert_malformed
|
312 | 484 | (module binary
|
|
326 | 498 | "zero flag expected"
|
327 | 499 | )
|
328 | 500 |
|
| 501 | +;; memory.size reserved byte should not be a "long" LEB128 zero. |
| 502 | +(assert_malformed |
| 503 | + (module binary |
| 504 | + "\00asm" "\01\00\00\00" |
| 505 | + "\01\04\01\60\00\00" ;; Type section |
| 506 | + "\03\02\01\00" ;; Function section |
| 507 | + "\05\03\01\00\00" ;; Memory section |
| 508 | + "\0a\08\01" ;; Code section |
| 509 | + |
| 510 | + ;; function 0 |
| 511 | + "\06\00" |
| 512 | + "\3f" ;; memory.size |
| 513 | + "\80\00" ;; memory.size reserved byte |
| 514 | + "\1a" ;; drop |
| 515 | + "\0b" ;; end |
| 516 | + ) |
| 517 | + "zero flag expected" |
| 518 | +) |
| 519 | + |
| 520 | +;; Same as above for 3, 4, and 5-byte zero encodings. |
| 521 | +(assert_malformed |
| 522 | + (module binary |
| 523 | + "\00asm" "\01\00\00\00" |
| 524 | + "\01\04\01\60\00\00" ;; Type section |
| 525 | + "\03\02\01\00" ;; Function section |
| 526 | + "\05\03\01\00\00" ;; Memory section |
| 527 | + "\0a\09\01" ;; Code section |
| 528 | + |
| 529 | + ;; function 0 |
| 530 | + "\07\00" |
| 531 | + "\3f" ;; memory.size |
| 532 | + "\80\80\00" ;; memory.size reserved byte |
| 533 | + "\1a" ;; drop |
| 534 | + "\0b" ;; end |
| 535 | + ) |
| 536 | + "zero flag expected" |
| 537 | +) |
| 538 | + |
| 539 | +(assert_malformed |
| 540 | + (module binary |
| 541 | + "\00asm" "\01\00\00\00" |
| 542 | + "\01\04\01\60\00\00" ;; Type section |
| 543 | + "\03\02\01\00" ;; Function section |
| 544 | + "\05\03\01\00\00" ;; Memory section |
| 545 | + "\0a\0a\01" ;; Code section |
| 546 | + |
| 547 | + ;; function 0 |
| 548 | + "\08\00" |
| 549 | + "\3f" ;; memory.size |
| 550 | + "\80\80\80\00" ;; memory.size reserved byte |
| 551 | + "\1a" ;; drop |
| 552 | + "\0b" ;; end |
| 553 | + ) |
| 554 | + "zero flag expected" |
| 555 | +) |
| 556 | + |
| 557 | +(assert_malformed |
| 558 | + (module binary |
| 559 | + "\00asm" "\01\00\00\00" |
| 560 | + "\01\04\01\60\00\00" ;; Type section |
| 561 | + "\03\02\01\00" ;; Function section |
| 562 | + "\05\03\01\00\00" ;; Memory section |
| 563 | + "\0a\0b\01" ;; Code section |
| 564 | + |
| 565 | + ;; function 0 |
| 566 | + "\09\00" |
| 567 | + "\3f" ;; memory.size |
| 568 | + "\80\80\80\80\00" ;; memory.size reserved byte |
| 569 | + "\1a" ;; drop |
| 570 | + "\0b" ;; end |
| 571 | + ) |
| 572 | + "zero flag expected" |
| 573 | +) |
| 574 | + |
329 | 575 | ;; No more than 2^32 locals.
|
330 | 576 | (assert_malformed
|
331 | 577 | (module binary
|
|
0 commit comments