Skip to content

Commit

Permalink
Fix \C backtracking in UTF-8 issue for repeated character classes, wh…
Browse files Browse the repository at this point in the history
…ich were

overlooked when it was fixed for other repeats. 


git-svn-id: svn:https://vcs.exim.org/pcre/code/trunk@1725 2f5784b3-3f2a-0410-8824-cb99058d5e15
  • Loading branch information
ph10 committed Feb 20, 2018
1 parent 8dc7206 commit b68d679
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 2 deletions.
5 changes: 5 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ non-zero starting offset, unset capturing groups with lower numbers than a
group that did capture something were not being correctly returned as "unset"
(that is, with offset values of -1).

10. Matching the pattern /(*UTF)\C[^\v]+\x80/ against an 8-bit string
containing multi-code-unit characters caused bad behaviour and possibly a
crash. This issue was fixed for other kinds of repeat in release 8.37 by change
38, but repeating character classes were overlooked.


Version 8.41 05-July-2017
-------------------------
Expand Down
4 changes: 2 additions & 2 deletions pcre_exec.c
Original file line number Diff line number Diff line change
Expand Up @@ -3053,7 +3053,7 @@ for (;;)
{
RMATCH(eptr, ecode, offset_top, md, eptrb, RM18);
if (rrc != MATCH_NOMATCH) RRETURN(rrc);
if (eptr-- == pp) break; /* Stop if tried at original pos */
if (eptr-- <= pp) break; /* Stop if tried at original pos */
BACKCHAR(eptr);
}
}
Expand Down Expand Up @@ -3210,7 +3210,7 @@ for (;;)
{
RMATCH(eptr, ecode, offset_top, md, eptrb, RM21);
if (rrc != MATCH_NOMATCH) RRETURN(rrc);
if (eptr-- == pp) break; /* Stop if tried at original pos */
if (eptr-- <= pp) break; /* Stop if tried at original pos */
#ifdef SUPPORT_UTF
if (utf) BACKCHAR(eptr);
#endif
Expand Down
6 changes: 6 additions & 0 deletions testdata/testinput5
Original file line number Diff line number Diff line change
Expand Up @@ -798,4 +798,10 @@
/(?<=\K\x{17f})/8G+
\x{17f}\x{17f}\x{17f}\x{17f}\x{17f}

/\C[^\v]+\x80/8
[AΏBŀC]

/\C[^\d]+\x80/8
[AΏBŀC]

/-- End of testinput5 --/
Expand Down
8 changes: 8 additions & 0 deletions testdata/testoutput5
Original file line number Diff line number Diff line change
Expand Up @@ -1942,4 +1942,12 @@ Need char = 'z'
0: \x{17f}
0+

/\C[^\v]+\x80/8
[AΏBŀC]
No match

/\C[^\d]+\x80/8
[AΏBŀC]
No match

/-- End of testinput5 --/
Expand Down

0 comments on commit b68d679

Please sign in to comment.