[Pcre-svn] [597] code/trunk: Complete incomplete fix for UTF…

トップ ページ
このメッセージを削除
著者: Subversion repository
日付:  
To: pcre-svn
題目: [Pcre-svn] [597] code/trunk: Complete incomplete fix for UTF-8 caseless references of different lengths .
Revision: 597
          http://vcs.pcre.org/viewvc?view=rev&revision=597
Author:   ph10
Date:     2011-05-02 18:08:52 +0100 (Mon, 02 May 2011)


Log Message:
-----------
Complete incomplete fix for UTF-8 caseless references of different lengths.

Modified Paths:
--------------
    code/trunk/pcre_exec.c
    code/trunk/testdata/testinput1
    code/trunk/testdata/testinput4
    code/trunk/testdata/testoutput1
    code/trunk/testdata/testoutput4


Modified: code/trunk/pcre_exec.c
===================================================================
--- code/trunk/pcre_exec.c    2011-05-02 10:47:52 UTC (rev 596)
+++ code/trunk/pcre_exec.c    2011-05-02 17:08:52 UTC (rev 597)
@@ -193,6 +193,7 @@
     while (p < endptr)
       {
       int c, d;
+      if (eptr >= md->end_subject) return -1;
       GETCHARINC(c, eptr);
       GETCHARINC(d, p);
       if (c != d && c != UCD_OTHERCASE(d)) return -1;
@@ -204,16 +205,21 @@


   /* The same code works when not in UTF-8 mode and in UTF-8 mode when there
   is no UCP support. */
-
-  while (length-- > 0)
-    { if (md->lcc[*p++] != md->lcc[*eptr++]) return -1; }
+    {
+    if (eptr + length > md->end_subject) return -1; 
+    while (length-- > 0)
+      { if (md->lcc[*p++] != md->lcc[*eptr++]) return -1; }
+    }   
   }


/* In the caseful case, we can just compare the bytes, whether or not we
are in UTF-8 mode. */

else
- { while (length-- > 0) if (*p++ != *eptr++) return -1; }
+ {
+ if (eptr + length > md->end_subject) return -1;
+ while (length-- > 0) if (*p++ != *eptr++) return -1;
+ }

return eptr - eptr_start;
}

Modified: code/trunk/testdata/testinput1
===================================================================
--- code/trunk/testdata/testinput1    2011-05-02 10:47:52 UTC (rev 596)
+++ code/trunk/testdata/testinput1    2011-05-02 17:08:52 UTC (rev 597)
@@ -4079,4 +4079,10 @@
 /^\c/
     ?


+/(abc)\1/i
+ abc
+
+/(abc)\1/
+ abc
+
/-- End of testinput1 --/

Modified: code/trunk/testdata/testinput4
===================================================================
--- code/trunk/testdata/testinput4    2011-05-02 10:47:52 UTC (rev 596)
+++ code/trunk/testdata/testinput4    2011-05-02 17:08:52 UTC (rev 597)
@@ -644,4 +644,10 @@
 /A*/g8
     AAB\x{123}BAA


+/(abc)\1/8i
+ abc
+
+/(abc)\1/8
+ abc
+
/-- End of testinput4 --/

Modified: code/trunk/testdata/testoutput1
===================================================================
--- code/trunk/testdata/testoutput1    2011-05-02 10:47:52 UTC (rev 596)
+++ code/trunk/testdata/testoutput1    2011-05-02 17:08:52 UTC (rev 597)
@@ -6666,4 +6666,12 @@
     ?
  0: ?


+/(abc)\1/i
+ abc
+No match
+
+/(abc)\1/
+ abc
+No match
+
/-- End of testinput1 --/

Modified: code/trunk/testdata/testoutput4
===================================================================
--- code/trunk/testdata/testoutput4    2011-05-02 10:47:52 UTC (rev 596)
+++ code/trunk/testdata/testoutput4    2011-05-02 17:08:52 UTC (rev 597)
@@ -1128,4 +1128,12 @@
  0: AA
  0: 


+/(abc)\1/8i
+ abc
+No match
+
+/(abc)\1/8
+ abc
+No match
+
/-- End of testinput4 --/