Fix crash in pcre2test when displaying a wide character with a locale set.

This commit is contained in:
Philip.Hazel 2016-12-08 18:56:24 +00:00
parent 0e04c156a4
commit 156a5c4e5f
4 changed files with 31 additions and 4 deletions

View File

@ -201,6 +201,9 @@ pcre2test for testing it.
30. Fix out-of-bounds read for partial matching of /./ against an empty string 30. Fix out-of-bounds read for partial matching of /./ against an empty string
when the newline type is CRLF. when the newline type is CRLF.
31. Fix a bug in pcre2test that caused a crash when a locale was set either in
the current pattern or a previous one and a wide character was matched.
Version 10.22 29-July-2016 Version 10.22 29-July-2016
-------------------------- --------------------------

View File

@ -211,7 +211,7 @@ systems that differ in their output from isprint() even in the "C" locale. */
#define PRINTABLE(c) ((c) >= 32 && (c) < 127) #define PRINTABLE(c) ((c) >= 32 && (c) < 127)
#endif #endif
#define PRINTOK(c) ((locale_tables != NULL)? isprint(c) : PRINTABLE(c)) #define PRINTOK(c) ((use_tables != NULL && c < 256)? isprint(c) : PRINTABLE(c))
/* We have to include some of the library source files because we need /* We have to include some of the library source files because we need
to use some of the macros, internal structure definitions, and other internal to use some of the macros, internal structure definitions, and other internal
@ -833,6 +833,7 @@ static regex_t preg = { NULL, NULL, 0, 0, 0 };
static int *dfa_workspace = NULL; static int *dfa_workspace = NULL;
static const uint8_t *locale_tables = NULL; static const uint8_t *locale_tables = NULL;
static const uint8_t *use_tables = NULL;
static uint8_t locale_name[32]; static uint8_t locale_name[32];
/* We need buffers for building 16/32-bit strings; 8-bit strings don't need /* We need buffers for building 16/32-bit strings; 8-bit strings don't need
@ -4547,7 +4548,6 @@ process_pattern(void)
BOOL utf; BOOL utf;
uint32_t k; uint32_t k;
uint8_t *p = buffer; uint8_t *p = buffer;
const uint8_t *use_tables;
unsigned int delimiter = *p++; unsigned int delimiter = *p++;
int errorcode; int errorcode;
void *use_pat_context; void *use_pat_context;
@ -5058,8 +5058,8 @@ if ((pat_patctl.control2 & CTL_NL_SET) == 0 && local_newline_default != 0)
SETFLD(pat_context, newline_convention, local_newline_default); SETFLD(pat_context, newline_convention, local_newline_default);
} }
/* The nullcontext modifier is used to test calling pcre2_compile() with a NULL /* The null_context modifier is used to test calling pcre2_compile() with a
context. */ NULL context. */
use_pat_context = ((pat_patctl.control & CTL_NULLCONTEXT) != 0)? use_pat_context = ((pat_patctl.control & CTL_NULLCONTEXT) != 0)?
NULL : PTR(pat_context); NULL : PTR(pat_context);

11
testdata/testinput5 vendored
View File

@ -1744,4 +1744,15 @@
/XȀ/x,utf /XȀ/x,utf
# These three test a bug fix that was not clearing up after a locale setting
# when the test or a subsequent one matched a wide character.
//locale=C
/[\P{Yi}]/utf
\x{2f000}
/[\P{Yi}]/utf,locale=C
\x{2f000}
# End of testinput5 # End of testinput5

13
testdata/testoutput5 vendored
View File

@ -4188,4 +4188,17 @@ Failed: error 125 at offset 2: lookbehind assertion is not fixed length
/XȀ/x,utf /XȀ/x,utf
# These three test a bug fix that was not clearing up after a locale setting
# when the test or a subsequent one matched a wide character.
//locale=C
/[\P{Yi}]/utf
\x{2f000}
0: \x{2f000}
/[\P{Yi}]/utf,locale=C
\x{2f000}
0: \x{2f000}
# End of testinput5 # End of testinput5