Blob Blame History Raw
From 73e780844e0ee885244ca4b3beda82fa082953b9 Mon Sep 17 00:00:00 2001
From: ph10 <ph10@6239d852-aaf2-0410-a92c-79f79f948069>
Date: Thu, 8 Dec 2016 17:55:26 +0000
Subject: [PATCH] Fix buffer overflow in partial match test for CRLF in empty
 buffer.
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Petr Pisar: Ported to 10.21:

commit ec26c8fe3e0a6ee93060ecd7accaa0803dac2ee1
Author: ph10 <ph10@6239d852-aaf2-0410-a92c-79f79f948069>
Date:   Thu Dec 8 17:55:26 2016 +0000

    Fix buffer overflow in partial match test for CRLF in empty buffer.

    git-svn-id: svn://vcs.exim.org/pcre2/code/trunk@612 6239d852-aaf2-0410-a92c-79f79f948069

Signed-off-by: Petr Písař <ppisar@redhat.com>
---
 src/pcre2_match.c    | 2 +-
 testdata/testinput2  | 3 +++
 testdata/testoutput2 | 4 ++++
 3 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/src/pcre2_match.c b/src/pcre2_match.c
index f5275c7..bd3e436 100644
--- a/src/pcre2_match.c
+++ b/src/pcre2_match.c
@@ -2382,7 +2382,7 @@ for (;;)
     case OP_ANY:
     if (IS_NEWLINE(eptr)) RRETURN(MATCH_NOMATCH);
     if (mb->partial != 0 &&
-        eptr + 1 >= mb->end_subject &&
+        eptr == mb->end_subject - 1 &&
         NLBLOCK->nltype == NLTYPE_FIXED &&
         NLBLOCK->nllen == 2 &&
         UCHAR21TEST(eptr) == NLBLOCK->nl[0])
diff --git a/testdata/testinput2 b/testdata/testinput2
index 67d486b..cf463c9 100644
--- a/testdata/testinput2
+++ b/testdata/testinput2
@@ -4813,4 +4813,7 @@ a)"xI
 
 /(?=.*[A-Z])/I
 
+/./newline=crlf
+\=ph
+
 # End of testinput2 
diff --git a/testdata/testoutput2 b/testdata/testoutput2
index 4c5e648..8674698 100644
--- a/testdata/testoutput2
+++ b/testdata/testoutput2
@@ -15208,4 +15208,8 @@ Capturing subpattern count = 0
 May match empty string
 Subject length lower bound = 0
 
+/./newline=crlf
+\=ph
+No match
+
 # End of testinput2 
-- 
2.7.4