]>
Commit | Line | Data |
---|---|---|
b003a5ad JR |
1 | # Fix pointer arithmetic overflow introduced in upstream commit 4063ade8503ac8877a02fc4eae8ebbe242b9110b, |
2 | # which caused the following tests to fail on i486 and i686: | |
3 | # t/re/pat_rt_report_thr ........................................ FAILED at test 55 | |
4 | # Failed test 55 - UTF-8 regex matches above 32k; Bug 20020630.002 at re/pat_rt_report.t line 224 | |
5 | # <utf8 x 32000>; pos = 1 | |
6 | # Failed test 57 - UTF-8 regex matches above 32k; Bug 20020630.002 at re/pat_rt_report.t line 224 | |
7 | # <utf8 x 32768>; pos = 1 | |
8 | # Failed test 59 - UTF-8 regex matches above 32k; Bug 20020630.002 at re/pat_rt_report.t line 224 | |
9 | # <utf8 x 33000>; pos = 1 | |
10 | diff --git a/regexec.c b/regexec.c | |
11 | index bc38839..6199677 100644 | |
12 | --- a/regexec.c | |
13 | +++ b/regexec.c | |
14 | @@ -6662,7 +6662,7 @@ S_regrepeat(pTHX_ regexp *prog, char **startposp, const regnode *p, | |
15 | scan = *startposp; | |
16 | if (max == REG_INFTY) | |
17 | max = I32_MAX; | |
18 | - else if (! utf8_target && scan + max < loceol) | |
19 | + else if (! utf8_target && max < loceol - scan) | |
20 | loceol = scan + max; | |
21 | ||
22 | /* Here, for the case of a non-UTF-8 target we have adjusted <loceol> down | |
23 | @@ -6711,7 +6711,7 @@ S_regrepeat(pTHX_ regexp *prog, char **startposp, const regnode *p, | |
24 | scan = loceol; | |
25 | break; | |
26 | case CANY: /* Move <scan> forward <max> bytes, unless goes off end */ | |
27 | - if (utf8_target && scan + max < loceol) { | |
28 | + if (utf8_target && max < loceol - scan) { | |
29 | ||
30 | /* <loceol> hadn't been adjusted in the UTF-8 case */ | |
31 | scan += max; | |
32 | @@ -6730,7 +6730,7 @@ S_regrepeat(pTHX_ regexp *prog, char **startposp, const regnode *p, | |
33 | * can use UTF8_IS_INVARIANT() even if the pattern isn't UTF-8, as it's | |
34 | * true iff it doesn't matter if the argument is in UTF-8 or not */ | |
35 | if (UTF8_IS_INVARIANT(c) || (! utf8_target && ! is_utf8_pat)) { | |
36 | - if (utf8_target && scan + max < loceol) { | |
37 | + if (utf8_target && max < loceol - scan) { | |
38 | /* We didn't adjust <loceol> because is UTF-8, but ok to do so, | |
39 | * since here, to match at all, 1 char == 1 byte */ | |
40 | loceol = scan + max; | |
41 | @@ -6910,7 +6910,7 @@ S_regrepeat(pTHX_ regexp *prog, char **startposp, const regnode *p, | |
42 | /* FALLTHROUGH */ | |
43 | ||
44 | case POSIXA: | |
45 | - if (utf8_target && scan + max < loceol) { | |
46 | + if (utf8_target && max < loceol - scan) { | |
47 | ||
48 | /* We didn't adjust <loceol> at the beginning of this routine | |
49 | * because is UTF-8, but it is actually ok to do so, since here, to |