From 7431a9909743afb0878fab16d813f85c8fb1bf40 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Petr=20P=C3=ADsa=C5=99?= <ppi...@redhat.com>
Date: Thu, 3 Nov 2016 12:59:22 +0100
Subject: Fix crash when matching UTF-8 string with non-UTF-8 substrings

---
 ...-anchored-floating-substrings-must-be-utf.patch | 56 ++++++++++++++++++++++
 perl.spec                                          |  7 +++
 2 files changed, 63 insertions(+)
 create mode 100644 
perl-5.24.0-perl-129350-anchored-floating-substrings-must-be-utf.patch

diff --git 
a/perl-5.24.0-perl-129350-anchored-floating-substrings-must-be-utf.patch 
b/perl-5.24.0-perl-129350-anchored-floating-substrings-must-be-utf.patch
new file mode 100644
index 0000000..9880f2d
--- /dev/null
+++ b/perl-5.24.0-perl-129350-anchored-floating-substrings-must-be-utf.patch
@@ -0,0 +1,56 @@
+From 62130748594f803da49b6abf3e352e51148a3886 Mon Sep 17 00:00:00 2001
+From: Hugo van der Sanden <h...@crypt.org>
+Date: Tue, 4 Oct 2016 14:40:11 +0100
+Subject: [PATCH] anchored/floating substrings must be utf8 if target is
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+Ported to 5.24.0:
+
+commit 2814f4b3549f665a6f9203ac9e890ae1e415e0dc
+Author: Hugo van der Sanden <h...@crypt.org>
+Date:   Tue Oct 4 14:40:11 2016 +0100
+
+    [perl #129350] anchored/floating substrings must be utf8 if target is
+
+    If the target is utf8 and either the anchored or floating substrings
+    are not, we need to create utf8 copies to check against. The state
+    of the two substrings may not be the same, but we were only testing
+    whichever we planned to check first.
+
+Signed-off-by: Petr Písař <ppi...@redhat.com>
+---
+ regexec.c     | 3 ++-
+ t/re/re_tests | 1 +
+ 2 files changed, 3 insertions(+), 1 deletion(-)
+
+diff --git a/regexec.c b/regexec.c
+index cdaa95c..38ff44a 100644
+--- a/regexec.c
++++ b/regexec.c
+@@ -703,7 +703,8 @@ Perl_re_intuit_start(pTHX_
+     reginfo->poscache_maxiter = 0;
+ 
+     if (utf8_target) {
+-      if (!prog->check_utf8 && prog->check_substr)
++        if ((!prog->anchored_utf8 && prog->anchored_substr)
++                || (!prog->float_utf8 && prog->float_substr))
+           to_utf8_substr(prog);
+       check = prog->check_utf8;
+     } else {
+diff --git a/t/re/re_tests b/t/re/re_tests
+index 7e8522d..2f4d00c 100644
+--- a/t/re/re_tests
++++ b/t/re/re_tests
+@@ -1968,6 +1968,7 @@ ab(?#Comment){2}c        abbc    y       $&      abbc
+ (?:.||)(?|)000000000@ 000000000@      y       $&      000000000@              
#  [perl #126405]
+ aa$|a(?R)a|a  aaa     y       $&      aaa             # [perl 128420] 
recursive matches
+ (?:\1|a)([bcd])\1(?:(?R)|e)\1 abbaccaddedcb   y       $&      abbaccaddedcb   
        # [perl 128420] recursive match with backreferences
++\b\z0*\x{100} .\x{100}        n       -       -       # [perl #129350] 
crashed in intuit_start
+ 
+ # Keep these lines at the end of the file
+ # vim: softtabstop=0 noexpandtab
+-- 
+2.7.4
+
diff --git a/perl.spec b/perl.spec
index d9a2d27..93d3884 100644
--- a/perl.spec
+++ b/perl.spec
@@ -199,6 +199,10 @@ Patch51:        
perl-5.25.4-clean-up-gv_fetchmethod_pvn_flags-rename-nsplit-to-l
 Patch52:        
perl-5.25.4-fix-129267-rework-gv_fetchmethod_pvn_flags-separator.patch
 Patch53:        
perl-5.25.4-perl-129267-Test-for-gv_fetchmethod-buffer-overrun.patch
 
+# Fix crash when matching UTF-8 string with non-UTF-8 substrings, RT#129350,
+# in upstream after 5.25.5
+Patch54:        
perl-5.24.0-perl-129350-anchored-floating-substrings-must-be-utf.patch
+
 # Link XS modules to libperl.so with EU::CBuilder on Linux, bug #960048
 Patch200:       
perl-5.16.3-Link-XS-modules-to-libperl.so-with-EU-CBuilder-on-Li.patch
 
@@ -2873,6 +2877,7 @@ Perl extension for Version Objects
 %patch51 -p1
 %patch52 -p1
 %patch53 -p1
+%patch54 -p1
 %patch200 -p1
 %patch201 -p1
 
@@ -2917,6 +2922,7 @@ perl -x patchlevel.h \
     'Fedora Patch51: Fix string overrun in Perl_gv_fetchmethod_pvn_flags 
(RT#129267)' \
     'Fedora Patch52: Fix string overrun in Perl_gv_fetchmethod_pvn_flags 
(RT#129267)' \
     'Fedora Patch53: Fix string overrun in Perl_gv_fetchmethod_pvn_flags 
(RT#129267)' \
+    'Fedora Patch54: Fix crash when matching UTF-8 string with non-UTF-8 
substrings (RT#129350)' \
     'Fedora Patch200: Link XS modules to libperl.so with EU::CBuilder on 
Linux' \
     'Fedora Patch201: Link XS modules to libperl.so with EU::MM on Linux' \
     %{nil}
@@ -5199,6 +5205,7 @@ popd
 - Fix crash in "evalbytes S" (RT#129196)
 - Fix crash in splice (RT#129164, RT#129166, RT#129167)
 - Fix string overrun in Perl_gv_fetchmethod_pvn_flags (RT#129267)
+- Fix crash when matching UTF-8 string with non-UTF-8 substrings (RT#129350)
 
 * Tue Aug 02 2016 Jitka Plesnikova <jples...@redhat.com> - 4:5.24.0-377
 - Avoid loading of modules from current directory, CVE-2016-1238, (bug 
#1360425)
-- 
cgit v0.12


        
http://pkgs.fedoraproject.org/cgit/perl.git/commit/?h=f25&id=7431a9909743afb0878fab16d813f85c8fb1bf40
_______________________________________________
perl-devel mailing list -- perl-devel@lists.fedoraproject.org
To unsubscribe send an email to perl-devel-le...@lists.fedoraproject.org

Reply via email to