Fix returning unset groups in POSIX interface if REG_STARTEND a non-zero starting offset

This commit is contained in:
Petr Písař 2018-02-20 10:59:28 +01:00
parent 131eb75ebc
commit 6d944117b6
2 changed files with 50 additions and 1 deletions

View File

@ -0,0 +1,41 @@
From 8dc7206187ef9e9486fb5f102b85400ae9795dd1 Mon Sep 17 00:00:00 2001
From: ph10 <ph10@2f5784b3-3f2a-0410-8824-cb99058d5e15>
Date: Mon, 19 Feb 2018 16:35:05 +0000
Subject: [PATCH] Fix POSIX API bug when REG_STARTEND is used with a non-zero
starting offset and there are unset groups within the matching group list.
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
git-svn-id: svn://vcs.exim.org/pcre/code/trunk@1724 2f5784b3-3f2a-0410-8824-cb99058d5e15
Petr Písař: Ported to 8.41.
---
pcreposix.c | 6 +++---
diff --git a/pcreposix.c b/pcreposix.c
index 7b404a7..a76d6bf 100644
--- a/pcreposix.c
+++ b/pcreposix.c
@@ -6,7 +6,7 @@
and semantics are as close as possible to those of the Perl 5 language.
Written by Philip Hazel
- Copyright (c) 1997-2017 University of Cambridge
+ Copyright (c) 1997-2018 University of Cambridge
-----------------------------------------------------------------------------
Redistribution and use in source and binary forms, with or without
@@ -389,8 +389,8 @@ if (rc >= 0)
{
for (i = 0; i < (size_t)rc; i++)
{
- pmatch[i].rm_so = ovector[i*2] + so;
- pmatch[i].rm_eo = ovector[i*2+1] + so;
+ pmatch[i].rm_so = (ovector[i*2] < 0)? -1 : ovector[i*2] + so;
+ pmatch[i].rm_eo = (ovector[i*2+1] < 0)? -1: ovector[i*2+1] + so;
}
if (allocated_ovector) free(ovector);
for (; i < nmatch; i++) pmatch[i].rm_so = pmatch[i].rm_eo = -1;
--
2.13.6

View File

@ -2,7 +2,7 @@
#%%global rcversion RC1
Name: pcre
Version: 8.41
Release: %{?rcversion:0.}5%{?rcversion:.%rcversion}%{?dist}.2
Release: %{?rcversion:0.}6%{?rcversion:.%rcversion}%{?dist}
%global myversion %{version}%{?rcversion:-%rcversion}
Summary: Perl-compatible regular expression library
## Source package only:
@ -50,6 +50,9 @@ Patch6: pcre-8.41-Fix-wrong-first-character-when-a-backreference-with-.patch
# Fix out-of-bounds read for partial matching of /./ against an empty string
# when the newline type is CRLF, upstream bug #2226, in upstream after 8.41
Patch7: pcre-8.41-Fix-out-of-bounds-read-for-partial-matching-of-.-aga.patch
# Fix returning unset groups in POSIX interface if REG_STARTEND a non-zero
# starting offset, upstream bug #2244, in upstream after 8.41
Patch8: pcre-8.41-Fix-POSIX-API-bug-when-REG_STARTEND-is-used-with-a-n.patch
BuildRequires: readline-devel
BuildRequires: autoconf
BuildRequires: automake
@ -139,6 +142,7 @@ Utilities demonstrating PCRE capabilities like pcregrep or pcretest.
%patch5 -p1
%patch6 -p1
%patch7 -p1
%patch8 -p1
# Because of rpath patch
libtoolize --copy --force
autoreconf -vif
@ -233,6 +237,10 @@ make %{?_smp_mflags} check VERBOSE=yes
%{_mandir}/man1/pcretest.*
%changelog
* Tue Feb 20 2018 Petr Pisar <ppisar@redhat.com> - 8.41-6
- Fix returning unset groups in POSIX interface if REG_STARTEND a non-zero
starting offset (upstream bug #2244)
* Thu Feb 08 2018 Fedora Release Engineering <releng@fedoraproject.org> - 8.41-5.2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_28_Mass_Rebuild