Blame SOURCES/pcre-8.33-RC1-Fix-pcretest-crash-with-a-data-line-longer-than-6553.patch

1e2217
From bf2c63fda75cca4ab3006b6ccdf0f18fafe4fca5 Mon Sep 17 00:00:00 2001
1e2217
From: ph10 <ph10@2f5784b3-3f2a-0410-8824-cb99058d5e15>
1e2217
Date: Fri, 10 May 2013 16:22:40 +0000
1e2217
Subject: [PATCH] Fix pcretest crash with a data line longer than 65536 bytes.
1e2217
1e2217
git-svn-id: svn://vcs.exim.org/pcre/code/trunk@1327 2f5784b3-3f2a-0410-8824-cb99058d5e15
1e2217
1e2217
Petr Pisar: Port to 8.31-RC1
1e2217
 
1e2217
diff --git a/pcretest.c b/pcretest.c
1e2217
index 6ef3252..25f3853 100644
1e2217
--- a/pcretest.c
1e2217
+++ b/pcretest.c
1e2217
@@ -4411,7 +4411,8 @@ while (!done)
1e2217
 
1e2217
 #ifndef NOUTF
1e2217
     /* Check that the data is well-formed UTF-8 if we're in UTF mode. To create
1e2217
-       invalid input to pcre_exec, you must use \x?? or \x{} sequences. */
1e2217
+    invalid input to pcre_exec, you must use \x?? or \x{} sequences. */
1e2217
+        
1e2217
     if (use_utf)
1e2217
       {
1e2217
       pcre_uint8 *q;
1e2217
@@ -4429,21 +4430,23 @@ while (!done)
1e2217
 
1e2217
 #ifdef SUPPORT_VALGRIND
1e2217
     /* Mark the dbuffer as addressable but undefined again. */
1e2217
+     
1e2217
     if (dbuffer != NULL)
1e2217
       {
1e2217
       VALGRIND_MAKE_MEM_UNDEFINED(dbuffer, dbuffer_size * CHAR_SIZE);
1e2217
       }
1e2217
 #endif
1e2217
 
1e2217
-    /* Allocate a buffer to hold the data line. len+1 is an upper bound on
1e2217
-       the number of pcre_uchar units that will be needed. */
1e2217
-    if (dbuffer == NULL || (size_t)len >= dbuffer_size)
1e2217
+    /* Allocate a buffer to hold the data line; len+1 is an upper bound on
1e2217
+    the number of pcre_uchar units that will be needed. */
1e2217
+        
1e2217
+    while (dbuffer == NULL || (size_t)len >= dbuffer_size)
1e2217
       {
1e2217
       dbuffer_size *= 2;
1e2217
       dbuffer = (pcre_uint8 *)realloc(dbuffer, dbuffer_size * CHAR_SIZE);
1e2217
       if (dbuffer == NULL)
1e2217
         {
1e2217
-        fprintf(stderr, "pcretest: malloc(%d) failed\n", (int)dbuffer_size);
1e2217
+        fprintf(stderr, "pcretest: realloc(%d) failed\n", (int)dbuffer_size);
1e2217
         exit(1);
1e2217
         }
1e2217
       }
1e2217
-- 
1e2217
1.8.1.4
1e2217