Revision: 1518
http://vcs.pcre.org/viewvc?view=rev&revision=1518
Author: ph10
Date: 2015-02-06 16:10:27 +0000 (Fri, 06 Feb 2015)
Log Message:
-----------
Catch auto-possessification potential loop for bad UTF pattern with
NO_UTF_CHECK.
Modified Paths:
--------------
code/trunk/ChangeLog
code/trunk/pcre_compile.c
Modified: code/trunk/ChangeLog
===================================================================
--- code/trunk/ChangeLog 2015-02-06 12:10:13 UTC (rev 1517)
+++ code/trunk/ChangeLog 2015-02-06 16:10:27 UTC (rev 1518)
@@ -23,6 +23,10 @@
5. Fixed a memory leak during matching that could occur for a subpattern
subroutine call (recursive or otherwise) if the number of captured groups
that had to be saved was greater than ten.
+
+6. Catch a bad opcode during auto-possessification after compiling a bad UTF
+ string with NO_UTF_CHECK. This is a tidyup, not a bug fix, as passing bad
+ UTF with NO_UTF_CHECK is documented as having an undefined outcome.
Version 8.36 26-September-2014
Modified: code/trunk/pcre_compile.c
===================================================================
--- code/trunk/pcre_compile.c 2015-02-06 12:10:13 UTC (rev 1517)
+++ code/trunk/pcre_compile.c 2015-02-06 16:10:27 UTC (rev 1518)
@@ -3610,6 +3610,14 @@
{
c = *code;
+ /* When a pattern with bad UTF-8 encoding is compiled with NO_UTF_CHECK,
+ it may compile without complaining, but may get into a loop here if the code
+ pointer points to a bad value. This is, of course a documentated possibility,
+ when NO_UTF_CHECK is set, so it isn't a bug, but we can detect this case and
+ just give up on this optimization. */
+
+ if (c >= OP_TABLE_LENGTH) return;
+
if (c >= OP_STAR && c <= OP_TYPEPOSUPTO)
{
c -= get_repeat_base(c) - OP_STAR;