Commit bfb55a6
avoid LIMIT_HEAP integer multiplication wrap around (#184)
Cherry-picked from 4d66adc.
If a LIMIT_HEAP value once converted to bytes is larger than UINT_MAX
would result in a bogus setting that could trigger a matching failure
as shown by the following:
PCRE2 version 10.42 2022-12-11
re> /(*LIMIT_HEAP=4194304)a/
data> a
Failed: error -63: heap limit exceeded
Remove the multiplication and instead keep track of the maximum heap
allowed in KB as was done originally.
Aditionally, add a check to avoid overflowing a PCRE2_SIZE while
doubling the heap used and that could result in a crash (only on
systems with a 32-bit PCRE2_SIZE and using non standard settings).
Unlike the original, this code avoids rounding the heapframes_size
to the frame_size at the allocation time, which simplifies the logic
and wasn't really needed.
Fixes: d90fb23 (Refactor match_data() to always use the heap instead
of having an initial frames vector on the stack..., 2022-07-27)
Closes: #1831 parent 52c0884 commit bfb55a6
2 files changed
+29
-13
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
858 | 858 | | |
859 | 859 | | |
860 | 860 | | |
861 | | - | |
| 861 | + | |
862 | 862 | | |
863 | 863 | | |
864 | 864 | | |
| |||
911 | 911 | | |
912 | 912 | | |
913 | 913 | | |
914 | | - | |
| 914 | + | |
915 | 915 | | |
916 | 916 | | |
917 | 917 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
665 | 665 | | |
666 | 666 | | |
667 | 667 | | |
668 | | - | |
| 668 | + | |
669 | 669 | | |
670 | | - | |
| 670 | + | |
671 | 671 | | |
672 | | - | |
673 | | - | |
674 | | - | |
| 672 | + | |
| 673 | + | |
| 674 | + | |
| 675 | + | |
| 676 | + | |
| 677 | + | |
| 678 | + | |
| 679 | + | |
| 680 | + | |
| 681 | + | |
| 682 | + | |
| 683 | + | |
| 684 | + | |
| 685 | + | |
| 686 | + | |
| 687 | + | |
| 688 | + | |
| 689 | + | |
675 | 690 | | |
676 | 691 | | |
677 | 692 | | |
| |||
6801 | 6816 | | |
6802 | 6817 | | |
6803 | 6818 | | |
6804 | | - | |
| 6819 | + | |
6805 | 6820 | | |
6806 | 6821 | | |
6807 | 6822 | | |
| |||
6816 | 6831 | | |
6817 | 6832 | | |
6818 | 6833 | | |
6819 | | - | |
| 6834 | + | |
6820 | 6835 | | |
6821 | 6836 | | |
6822 | 6837 | | |
| |||
6832 | 6847 | | |
6833 | 6848 | | |
6834 | 6849 | | |
6835 | | - | |
| 6850 | + | |
6836 | 6851 | | |
6837 | | - | |
6838 | | - | |
| 6852 | + | |
| 6853 | + | |
| 6854 | + | |
6839 | 6855 | | |
6840 | 6856 | | |
6841 | 6857 | | |
6842 | | - | |
| 6858 | + | |
6843 | 6859 | | |
6844 | 6860 | | |
6845 | 6861 | | |
| |||
0 commit comments