[pcre/f19] Fix possible pcretest crash with a data line longer than 65536 bytes

Petr Pisar ppisar at fedoraproject.org
Mon May 13 12:46:37 UTC 2013


commit fc833cfff5f7f994cef909c6e83f9244ff42c0d8
Author: Petr Písař <ppisar at redhat.com>
Date:   Mon May 13 14:36:39 2013 +0200

    Fix possible pcretest crash with a data line longer than 65536 bytes

 ...t-crash-with-a-data-line-longer-than-6553.patch |   54 ++++++++++++++++++++
 pcre.spec                                          |    4 ++
 2 files changed, 58 insertions(+), 0 deletions(-)
---
diff --git a/pcre-8.33-RC1-Fix-pcretest-crash-with-a-data-line-longer-than-6553.patch b/pcre-8.33-RC1-Fix-pcretest-crash-with-a-data-line-longer-than-6553.patch
new file mode 100644
index 0000000..f2d4865
--- /dev/null
+++ b/pcre-8.33-RC1-Fix-pcretest-crash-with-a-data-line-longer-than-6553.patch
@@ -0,0 +1,54 @@
+From bf2c63fda75cca4ab3006b6ccdf0f18fafe4fca5 Mon Sep 17 00:00:00 2001
+From: ph10 <ph10 at 2f5784b3-3f2a-0410-8824-cb99058d5e15>
+Date: Fri, 10 May 2013 16:22:40 +0000
+Subject: [PATCH] Fix pcretest crash with a data line longer than 65536 bytes.
+
+git-svn-id: svn://vcs.exim.org/pcre/code/trunk@1327 2f5784b3-3f2a-0410-8824-cb99058d5e15
+
+Petr Pisar: Port to 8.31-RC1
+ 
+diff --git a/pcretest.c b/pcretest.c
+index 6ef3252..25f3853 100644
+--- a/pcretest.c
++++ b/pcretest.c
+@@ -4411,7 +4411,8 @@ while (!done)
+ 
+ #ifndef NOUTF
+     /* Check that the data is well-formed UTF-8 if we're in UTF mode. To create
+-       invalid input to pcre_exec, you must use \x?? or \x{} sequences. */
++    invalid input to pcre_exec, you must use \x?? or \x{} sequences. */
++        
+     if (use_utf)
+       {
+       pcre_uint8 *q;
+@@ -4429,21 +4430,23 @@ while (!done)
+ 
+ #ifdef SUPPORT_VALGRIND
+     /* Mark the dbuffer as addressable but undefined again. */
++     
+     if (dbuffer != NULL)
+       {
+       VALGRIND_MAKE_MEM_UNDEFINED(dbuffer, dbuffer_size * CHAR_SIZE);
+       }
+ #endif
+ 
+-    /* Allocate a buffer to hold the data line. len+1 is an upper bound on
+-       the number of pcre_uchar units that will be needed. */
+-    if (dbuffer == NULL || (size_t)len >= dbuffer_size)
++    /* Allocate a buffer to hold the data line; len+1 is an upper bound on
++    the number of pcre_uchar units that will be needed. */
++        
++    while (dbuffer == NULL || (size_t)len >= dbuffer_size)
+       {
+       dbuffer_size *= 2;
+       dbuffer = (pcre_uint8 *)realloc(dbuffer, dbuffer_size * CHAR_SIZE);
+       if (dbuffer == NULL)
+         {
+-        fprintf(stderr, "pcretest: malloc(%d) failed\n", (int)dbuffer_size);
++        fprintf(stderr, "pcretest: realloc(%d) failed\n", (int)dbuffer_size);
+         exit(1);
+         }
+       }
+-- 
+1.8.1.4
+
diff --git a/pcre.spec b/pcre.spec
index 4a193e8..63dd9b4 100644
--- a/pcre.spec
+++ b/pcre.spec
@@ -19,6 +19,8 @@ Patch2: pcre-8.32-Fix-forward-search-in-JIT-when-link-size-is-3-or-gre.patch
 Patch3: pcre-8.32-Fix-two-buffer-over-read-issues-in-16-and-32-bit-mod.patch
 # Fix pcregrep on empty line, in upstream after 8.33-RC1
 Patch4: pcre-8.33-RC1-Fix-pcregrep-so-that-it-can-find-empty-lines.patch
+# Grow buffer in pcretest properly, in upstream after 8.33-RC1
+Patch5: pcre-8.33-RC1-Fix-pcretest-crash-with-a-data-line-longer-than-6553.patch
 BuildRequires: readline-devel
 # New libtool to get rid of rpath
 BuildRequires: autoconf, automake, libtool
@@ -63,6 +65,7 @@ Utilities demonstrating PCRE capabilities like pcregrep or pcretest.
 %patch2 -p1 -b .forward_jit
 %patch3 -p1 -b .buffer_over_read
 %patch4 -p1 -b .pcregrep_empty_line
+%patch5 -p1 -b .pcretest_grow_buffer
 # Because of rpath patch
 libtoolize --copy --force && autoreconf -vif
 # One contributor's name is non-UTF-8
@@ -128,6 +131,7 @@ make check
 %changelog
 * Mon May 13 2013 Petr Pisar <ppisar at redhat.com> - 8.32-5
 - Fix bad handling of empty lines in pcregrep tool (bug #961789)
+- Fix possible pcretest crash with a data line longer than 65536 bytes
 
 * Mon Jan 28 2013 Petr Pisar <ppisar at redhat.com> - 8.32-4
 - Fix forward search in JIT when link size is 3 or greater


More information about the scm-commits mailing list