summaryrefslogtreecommitdiff
path: root/ext/pcre/pcrelib/pcre_compile.c
diff options
context:
space:
mode:
authorNuno Lopes <nlopess@php.net>2008-01-29 20:18:02 +0000
committerNuno Lopes <nlopess@php.net>2008-01-29 20:18:02 +0000
commit3f7b92c06c6e4cbcd9bc949289b51756cfb658bf (patch)
tree595267e7ab7b87c1f31f693cd24da517114026f6 /ext/pcre/pcrelib/pcre_compile.c
parent99c56139c75b48914103bc2351b5422465f3f97e (diff)
downloadphp-git-3f7b92c06c6e4cbcd9bc949289b51756cfb658bf.tar.gz
upgrade to PCRE 7.6.
#changes to code are minimal. this fixes a security bug
Diffstat (limited to 'ext/pcre/pcrelib/pcre_compile.c')
-rw-r--r--ext/pcre/pcrelib/pcre_compile.c17
1 files changed, 15 insertions, 2 deletions
diff --git a/ext/pcre/pcrelib/pcre_compile.c b/ext/pcre/pcrelib/pcre_compile.c
index ef33cfc388..07b6369d6c 100644
--- a/ext/pcre/pcrelib/pcre_compile.c
+++ b/ext/pcre/pcrelib/pcre_compile.c
@@ -6,7 +6,7 @@
and semantics are as close as possible to those of the Perl 5 language.
Written by Philip Hazel
- Copyright (c) 1997-2007 University of Cambridge
+ Copyright (c) 1997-2008 University of Cambridge
-----------------------------------------------------------------------------
Redistribution and use in source and binary forms, with or without
@@ -2374,6 +2374,7 @@ uschar classbits[32];
BOOL class_utf8;
BOOL utf8 = (options & PCRE_UTF8) != 0;
uschar *class_utf8data;
+uschar *class_utf8data_base;
uschar utf8_char[6];
#else
BOOL utf8 = FALSE;
@@ -2685,6 +2686,7 @@ for (;; ptr++)
#ifdef SUPPORT_UTF8
class_utf8 = FALSE; /* No chars >= 256 */
class_utf8data = code + LINK_SIZE + 2; /* For UTF-8 items */
+ class_utf8data_base = class_utf8data; /* For resetting in pass 1 */
#endif
/* Process characters until ] is reached. By writing this as a "do" it
@@ -2700,6 +2702,18 @@ for (;; ptr++)
{ /* Braces are required because the */
GETCHARLEN(c, ptr, ptr); /* macro generates multiple statements */
}
+
+ /* In the pre-compile phase, accumulate the length of any UTF-8 extra
+ data and reset the pointer. This is so that very large classes that
+ contain a zillion UTF-8 characters no longer overwrite the work space
+ (which is on the stack). */
+
+ if (lengthptr != NULL)
+ {
+ *lengthptr += class_utf8data - class_utf8data_base;
+ class_utf8data = class_utf8data_base;
+ }
+
#endif
/* Inside \Q...\E everything is literal except \E */
@@ -5805,7 +5819,6 @@ to fill in forward references to subpatterns. */
uschar cworkspace[COMPILE_WORK_SIZE];
-
/* Set this early so that early errors get offset 0. */
ptr = (const uschar *)pattern;