[Pcre-svn] [657] code/trunk: Fix \g+ bug when the number tha…

Top Page
Delete this message
Author: Subversion repository
Date:  
To: pcre-svn
Subject: [Pcre-svn] [657] code/trunk: Fix \g+ bug when the number that follows is too big.
Revision: 657
          http://www.exim.org/viewvc/pcre2?view=rev&revision=657
Author:   ph10
Date:     2017-01-31 17:15:30 +0000 (Tue, 31 Jan 2017)
Log Message:
-----------
Fix \g+ bug when the number that follows is too big.


Modified Paths:
--------------
    code/trunk/ChangeLog
    code/trunk/src/pcre2_compile.c
    code/trunk/testdata/testinput2
    code/trunk/testdata/testoutput2


Modified: code/trunk/ChangeLog
===================================================================
--- code/trunk/ChangeLog    2017-01-17 15:21:11 UTC (rev 656)
+++ code/trunk/ChangeLog    2017-01-31 17:15:30 UTC (rev 657)
@@ -330,7 +330,7 @@
 modules.


 52. Minor fixed to pcre2grep from Jason Hood:
-    * fixes some spacing;
+    * fixed some spacing;
     * Windows doesn't usually use single quotes, so I've added a define
       to use appropriate quotes [in an example];
     * LC_ALL was displayed as "LCC_ALL";


Modified: code/trunk/src/pcre2_compile.c
===================================================================
--- code/trunk/src/pcre2_compile.c    2017-01-17 15:21:11 UTC (rev 656)
+++ code/trunk/src/pcre2_compile.c    2017-01-31 17:15:30 UTC (rev 657)
@@ -1220,9 +1220,20 @@


*errorcodeptr = 0;

-if (allow_sign >= 0 && ptr < ptrend &&
-    (*ptr == CHAR_PLUS || *ptr == CHAR_MINUS))
-  sign = (*ptr++ == CHAR_MINUS)? -1 : +1;
+if (allow_sign >= 0 && ptr < ptrend)
+  {
+  if (*ptr == CHAR_PLUS)
+    {
+    sign = +1;
+    max_value -= allow_sign;
+    ptr++; 
+    }
+  else if (*ptr == CHAR_MINUS)
+    { 
+    sign = -1;        
+    ptr++; 
+    } 
+  } 


if (ptr >= ptrend || !IS_DIGIT(*ptr)) return FALSE;
while (ptr < ptrend && IS_DIGIT(*ptr))

Modified: code/trunk/testdata/testinput2
===================================================================
--- code/trunk/testdata/testinput2    2017-01-17 15:21:11 UTC (rev 656)
+++ code/trunk/testdata/testinput2    2017-01-31 17:15:30 UTC (rev 657)
@@ -4959,4 +4959,8 @@
 /abcd/auto_callout
     abcd\=callout_error=255:2


+/()(\g+65534)/
+
+/()(\g+65533)/
+
# End of testinput2

Modified: code/trunk/testdata/testoutput2
===================================================================
--- code/trunk/testdata/testoutput2    2017-01-17 15:21:11 UTC (rev 656)
+++ code/trunk/testdata/testoutput2    2017-01-31 17:15:30 UTC (rev 657)
@@ -15446,6 +15446,12 @@
  +1 ^^       b
 Failed: error -37: callout error code


+/()(\g+65534)/
+Failed: error 161 at offset 11: group number is too big
+
+/()(\g+65533)/
+Failed: error 115 at offset 10: reference to non-existent subpattern
+
# End of testinput2
Error -63: PCRE2_ERROR_BADDATA (unknown error number)
Error -62: bad serialized data