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

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