Skip to content

Commit 57ee073

Browse files
committed
Fix bad patch in 05206d6. The interpreter was handling NOTEOL incorrectly in general after trying to fix it in invalid UTF subjects.
1 parent 45dcb3d commit 57ee073

File tree

4 files changed

+15
-5
lines changed

4 files changed

+15
-5
lines changed

src/pcre2_intmodedep.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -880,7 +880,8 @@ typedef struct match_block {
880880
PCRE2_SPTR start_code; /* For use when recursing */
881881
PCRE2_SPTR start_subject; /* Start of the subject string */
882882
PCRE2_SPTR check_subject; /* Where UTF-checked from */
883-
PCRE2_SPTR end_subject; /* End of the subject string */
883+
PCRE2_SPTR end_subject; /* Usable end of the subject string */
884+
PCRE2_SPTR true_end_subject; /* Actual end of the subject string */
884885
PCRE2_SPTR end_match_ptr; /* Subject position at end match */
885886
PCRE2_SPTR start_used_ptr; /* Earliest consulted character */
886887
PCRE2_SPTR last_used_ptr; /* Latest consulted character */

src/pcre2_match.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6076,12 +6076,10 @@ fprintf(stderr, "++ %2ld op=%3d %s\n", Fecode - mb->start_code, *Fecode,
60766076
if ((mb->poptions & PCRE2_DOLLAR_ENDONLY) == 0) goto ASSERT_NL_OR_EOS;
60776077

60786078
/* Fall through */
6079-
/* Unconditional end of subject assertion (\z). We must check NOTEOL
6080-
because it gets set for invalid UTF fragments. */
6079+
/* Unconditional end of subject assertion (\z). */
60816080

60826081
case OP_EOD:
6083-
if (Feptr < mb->end_subject || (mb->moptions & PCRE2_NOTEOL) != 0)
6084-
RRETURN(MATCH_NOMATCH);
6082+
if (Feptr < mb->true_end_subject) RRETURN(MATCH_NOMATCH);
60856083
if (mb->partial != 0)
60866084
{
60876085
mb->hitend = TRUE;
@@ -6891,6 +6889,7 @@ mb->callout_data = mcontext->callout_data;
68916889
mb->start_subject = subject;
68926890
mb->start_offset = start_offset;
68936891
mb->end_subject = end_subject;
6892+
mb->true_end_subject = true_end_subject;
68946893
mb->hasthen = (re->flags & PCRE2_HASTHEN) != 0;
68956894
mb->allowemptypartial = (re->max_lookbehind > 0) ||
68966895
(re->flags & PCRE2_MATCH_EMPTY) != 0;

testdata/testinput2

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6055,4 +6055,8 @@ a)"xI
60556055

60566056
/(*ACCEPT)+/B,auto_callout
60576057

6058+
/a\z/
6059+
a
6060+
a\=noteol
6061+
60586062
# End of testinput2

testdata/testoutput2

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17946,6 +17946,12 @@ No match
1794617946
End
1794717947
------------------------------------------------------------------
1794817948

17949+
/a\z/
17950+
a
17951+
0: a
17952+
a\=noteol
17953+
0: a
17954+
1794917955
# End of testinput2
1795017956
Error -70: PCRE2_ERROR_BADDATA (unknown error number)
1795117957
Error -62: bad serialized data

0 commit comments

Comments
 (0)