Skip to content

Commit

Permalink
Fix bad patch in 05206d6. The interpreter was handling NOTEOL incorre…
Browse files Browse the repository at this point in the history
…ctly in general after trying to fix it in invalid UTF subjects.
  • Loading branch information
PhilipHazel committed Nov 22, 2023
1 parent 45dcb3d commit 57ee073
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 5 deletions.
3 changes: 2 additions & 1 deletion src/pcre2_intmodedep.h
Original file line number Diff line number Diff line change
Expand Up @@ -880,7 +880,8 @@ typedef struct match_block {
PCRE2_SPTR start_code; /* For use when recursing */
PCRE2_SPTR start_subject; /* Start of the subject string */
PCRE2_SPTR check_subject; /* Where UTF-checked from */
PCRE2_SPTR end_subject; /* End of the subject string */
PCRE2_SPTR end_subject; /* Usable end of the subject string */
PCRE2_SPTR true_end_subject; /* Actual end of the subject string */
PCRE2_SPTR end_match_ptr; /* Subject position at end match */
PCRE2_SPTR start_used_ptr; /* Earliest consulted character */
PCRE2_SPTR last_used_ptr; /* Latest consulted character */
Expand Down
7 changes: 3 additions & 4 deletions src/pcre2_match.c
Original file line number Diff line number Diff line change
Expand Up @@ -6076,12 +6076,10 @@ fprintf(stderr, "++ %2ld op=%3d %s\n", Fecode - mb->start_code, *Fecode,
if ((mb->poptions & PCRE2_DOLLAR_ENDONLY) == 0) goto ASSERT_NL_OR_EOS;

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

case OP_EOD:
if (Feptr < mb->end_subject || (mb->moptions & PCRE2_NOTEOL) != 0)
RRETURN(MATCH_NOMATCH);
if (Feptr < mb->true_end_subject) RRETURN(MATCH_NOMATCH);
if (mb->partial != 0)
{
mb->hitend = TRUE;
Expand Down Expand Up @@ -6891,6 +6889,7 @@ mb->callout_data = mcontext->callout_data;
mb->start_subject = subject;
mb->start_offset = start_offset;
mb->end_subject = end_subject;
mb->true_end_subject = true_end_subject;
mb->hasthen = (re->flags & PCRE2_HASTHEN) != 0;
mb->allowemptypartial = (re->max_lookbehind > 0) ||
(re->flags & PCRE2_MATCH_EMPTY) != 0;
Expand Down
4 changes: 4 additions & 0 deletions testdata/testinput2
Original file line number Diff line number Diff line change
Expand Up @@ -6055,4 +6055,8 @@ a)"xI

/(*ACCEPT)+/B,auto_callout

/a\z/
a
a\=noteol

# End of testinput2
6 changes: 6 additions & 0 deletions testdata/testoutput2
Original file line number Diff line number Diff line change
Expand Up @@ -17946,6 +17946,12 @@ No match
End
------------------------------------------------------------------

/a\z/
a
0: a
a\=noteol
0: a

# End of testinput2
Error -70: PCRE2_ERROR_BADDATA (unknown error number)
Error -62: bad serialized data
Expand Down

0 comments on commit 57ee073

Please sign in to comment.