Commit e5e1f21
committed
Fix integer overflow in binary reader stack decoding on 32-bit platforms
In `decode_stack_pop_push()` and `decode_stack_suffix()`, the final stack
depth was computed as a `size_t` addition (e.g. `keep + push`). On 32-bit
platforms where `size_t` is 32-bit, a crafted .pyb file could provide
values that cause this addition to wrap around to a small value, bypassing
the subsequent capacity check. This could lead to a heap buffer overflow
via `memmove()` writing to an attacker-controlled offset.
Fix by computing `final_depth` as `uint64_t`, which cannot wrap on either
32-bit or 64-bit platforms since the operands are at most 32-bit each.
The capacity check then correctly rejects the overflowed value.1 parent f6f2faf commit e5e1f21
1 file changed
+20
-12
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
601 | 601 | | |
602 | 602 | | |
603 | 603 | | |
| 604 | + | |
| 605 | + | |
| 606 | + | |
| 607 | + | |
| 608 | + | |
| 609 | + | |
| 610 | + | |
| 611 | + | |
| 612 | + | |
| 613 | + | |
| 614 | + | |
| 615 | + | |
| 616 | + | |
| 617 | + | |
604 | 618 | | |
605 | 619 | | |
606 | 620 | | |
| |||
658 | 672 | | |
659 | 673 | | |
660 | 674 | | |
661 | | - | |
662 | | - | |
663 | | - | |
664 | | - | |
665 | | - | |
666 | | - | |
| 675 | + | |
| 676 | + | |
| 677 | + | |
667 | 678 | | |
668 | 679 | | |
669 | 680 | | |
| |||
713 | 724 | | |
714 | 725 | | |
715 | 726 | | |
716 | | - | |
717 | | - | |
718 | | - | |
719 | | - | |
720 | | - | |
721 | | - | |
| 727 | + | |
| 728 | + | |
| 729 | + | |
722 | 730 | | |
723 | 731 | | |
724 | 732 | | |
| |||
0 commit comments