Skip to content

Commit 94e1c00

Browse files
committed
Diagnose negative repeat value in pcre2test subject line
1 parent 3a1ad41 commit 94e1c00

File tree

4 files changed

+12
-2
lines changed

4 files changed

+12
-2
lines changed

ChangeLog

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,9 @@ pointers had out of place PCRE2_CALL_CONVENTION in src/pcre2.h.*. These
7575
produced errors when building for Windows with #define PCRE2_CALL_CONVENTION
7676
__stdcall.
7777

78+
20. A negative repeat value in a pcre2test subject line was not being
79+
diagnosed, leading to infinite looping.
80+
7881

7982
Version 10.40 15-April-2022
8083
---------------------------

src/pcre2test.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6844,9 +6844,9 @@ while ((c = *p++) != 0)
68446844
}
68456845

68466846
i = (int32_t)li;
6847-
if (i-- == 0)
6847+
if (i-- <= 0)
68486848
{
6849-
fprintf(outfile, "** Zero repeat not allowed\n");
6849+
fprintf(outfile, "** Zero or negative repeat not allowed\n");
68506850
return PR_OK;
68516851
}
68526852

testdata/testinput2

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5932,4 +5932,7 @@ a)"xI
59325932
/[Aa]{2,3}/BI
59335933
aabcd
59345934

5935+
--
5936+
\[X]{-10}
5937+
59355938
# End of testinput2

testdata/testoutput2

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17746,6 +17746,10 @@ Subject length lower bound = 2
1774617746
aabcd
1774717747
0: aa
1774817748

17749+
--
17750+
\[X]{-10}
17751+
** Zero or negative repeat not allowed
17752+
1774917753
# End of testinput2
1775017754
Error -70: PCRE2_ERROR_BADDATA (unknown error number)
1775117755
Error -62: bad serialized data

0 commit comments

Comments
 (0)