Skip to content

Commit c21bd97

Browse files
author
Zoltán Herczeg
committed
Fix a crash which occurs when the character type of an invalid UTF character is decoded in JIT.
1 parent eedd9d8 commit c21bd97

File tree

3 files changed

+11
-0
lines changed

3 files changed

+11
-0
lines changed

ChangeLog

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,9 @@ If the limit is reached, it just gives up trying for this optimization.
6363
16. The control verb chain list must always be restored when exiting from a
6464
recurse function in JIT.
6565

66+
17. Fix a crash which occurs when the character type of an invalid UTF
67+
character is decoded in JIT.
68+
6669

6770
Version 10.34 21-November-2019
6871
------------------------------

src/pcre2_jit_compile.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7224,7 +7224,13 @@ cc = ccbegin;
72247224
if ((cc[-1] & XCL_NOT) != 0)
72257225
read_char(common, min, max, backtracks, READ_CHAR_UPDATE_STR_PTR);
72267226
else
7227+
{
7228+
#ifdef SUPPORT_UNICODE
7229+
read_char(common, min, max, (needstype || needsscript) ? backtracks : NULL, 0);
7230+
#else /* !SUPPORT_UNICODE */
72277231
read_char(common, min, max, NULL, 0);
7232+
#endif /* SUPPORT_UNICODE */
7233+
}
72287234

72297235
if ((cc[-1] & XCL_HASPROP) == 0)
72307236
{

src/pcre2_jit_test.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1965,6 +1965,8 @@ static struct invalid_utf8_regression_test_case invalid_utf8_regression_test_cas
19651965
{ PCRE2_UTF, CI, 0, 0, 0, 4, 8, { "#\xc7\x85#", NULL }, "\x80\x80#\xc7#\xc7\x85#" },
19661966
{ PCRE2_UTF, CI, 0, 0, 0, 7, 11, { "#\xc7\x85#", NULL }, "\x80\x80#\xc7\x80\x80\x80#\xc7\x85#" },
19671967

1968+
{ PCRE2_UTF | PCRE2_UCP, CI, 0, 0, 0, -1, -1, { "[\\s]", NULL }, "\xed\xa0\x80" },
1969+
19681970
/* These two are not invalid UTF tests, but this infrastructure fits better for them. */
19691971
{ 0, PCRE2_JIT_COMPLETE, 0, 0, 1, -1, -1, { "\\X{2}", NULL }, "\r\n\n" },
19701972
{ 0, PCRE2_JIT_COMPLETE, 0, 0, 1, -1, -1, { "\\R{2}", NULL }, "\r\n\n" },

0 commit comments

Comments
 (0)