Update to 10.30

This commit is contained in:
Sandro Mani 2017-08-15 17:26:44 +02:00
parent 5d50807043
commit 11e63f42be
17 changed files with 9 additions and 1580 deletions

1
.gitignore vendored
View File

@ -1 +1,2 @@
/pcre2-10.23.tar.bz2
/pcre2-10.30.tar.bz2

View File

@ -3,8 +3,8 @@
%global pkgname pcre2
Name: mingw-%{pkgname}
Version: 10.23
Release: 3%{?dist}
Version: 10.30
Release: 1%{?dist}
Summary: MinGW Windows %{pkgname} library
License: BSD
@ -14,51 +14,6 @@ Source: ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/%{pkgname}-
## Patches taken from native package ##
# Do no set RPATH if libdir is not /usr/lib
Patch0: pcre2-10.10-Fix-multilib.patch
# Handle memmory allocation failures in pcre2test tool, in upstream after 10.23
Patch1: pcre2-10.23-Check-malloc-returns-in-pcre2test.patch
# Fix CVE-2017-7186 (a crash when finding a Unicode property for a character
# with a code point greater than 0x10ffff in UTF-32 library while UTF mode is
# disabled), upstream bug #2052, in upstream after 10.23
Patch2: pcre2-10.23-Fix-32-bit-non-UTF-property-test-crash.patch
# Fix an internal error for a forward reference in a lookbehind with
# PCRE2_ANCHORED, # oss-fuzz bug #865, in upstream after 10.23
Patch3: pcre2-10.23-Fix-crash-for-forward-reference-in-lookbehind-with-P.patch
# Fix a pcre2test bug for global match with zero terminated subject,
# upstream bug #2063, in upstream after 10.23
Patch4: pcre2-10.23-Fix-pcre2test-bug-for-global-match-with-zero-termina.patch
# Close serialization file in pcre2test after any error, upstream bug #2074,
# in upstream after 10.23
Patch5: pcre2-10.23-Close-serialization-file-in-pcre2test-after-any-erro.patch
# Fix a memory leak in pcre2_serialize_decode() when the input is invalid,
# upstream bug #2075, in upsream after 10.23.
Patch6: pcre2-10.23-Fix-memory-leak-when-deserializing-invalid-data-Bugz.patch
# Fix a potential NULL dereference in pcre2_callout_enumerate() if called with
# a NULL pattern pointer when Unicode support is available, upstream bug #2076,
# in upstream after 10.23
Patch7: pcre2-10.23-Fix-NULL-deference-if-pcre2_callout_enumerate-is-cal.patch
# 1/2 Fix 32-bit error buffer size bug in pcre2test, upstream bug #2079,
# in upstream after 10.23
Patch8: pcre2-10.23-Fix-32-bit-error-buffer-size-bug-in-pcre2test-Bugzil.patch
# 2/2 Fix 32-bit error buffer size bug in pcre2test, upstream bug #2079,
# in upstream after 10.23
Patch9: pcre2-10.23-Previous-patch-was-not-quite-complete.patch
# Fix DFA match for a possessively repeated character class, upstream bug #2086,
# in upstream after 10.23
Patch10: pcre2-10.23-Fix-misbehaving-DFA-match-for-possessively-repeated-.patch
# Use a memory allocator from the pattern if no context is supplied to
# pcre2_match(), in upsream after 10.23
Patch11: pcre2-10.23-Fix-bug-introduced-at-10.21-use-memory-allocator-fro.patch
# Fix CVE-2017-7186 in JIT mode (a crash when finding a Unicode property for
# a character with a code point greater than 0x10ffff in UTF-32 library while
# UTF mode is disabled), bug #1434504, upstream bug #2052,
# in upstream after 10.23
Patch12: pcre2-10.23-Fix-character-type-detection-when-32-bit-and-UCP-are.patch
# Fix an incorrect cast in UTF validation, upstream bug #2090,
# in upstream after 10.23
Patch13: pcre2-10.23-Correct-an-incorrect-cast.patch
# Fix a pcre2test crash on multiple push statements, upstream bug #2109,
# in upstream after 10.23
Patch14: pcre2-10.23-Fix-crash-when-more-than-one-kind-of-push-was-set-in.patch
## MinGW specific patches ##
# Fix implicitly defined functions due to overly relaxed platform detection in macros
@ -181,7 +136,7 @@ chmod 0644 %{buildroot}%{mingw64_libdir}/*.dll.a
%{mingw32_bindir}/libpcre2-8-0.dll
%{mingw32_bindir}/libpcre2-16-0.dll
%{mingw32_bindir}/libpcre2-32-0.dll
%{mingw32_bindir}/libpcre2-posix-1.dll
%{mingw32_bindir}/libpcre2-posix-2.dll
%{mingw32_libdir}/libpcre2-8.dll.a
%{mingw32_libdir}/libpcre2-16.dll.a
%{mingw32_libdir}/libpcre2-32.dll.a
@ -206,7 +161,7 @@ chmod 0644 %{buildroot}%{mingw64_libdir}/*.dll.a
%{mingw64_bindir}/libpcre2-8-0.dll
%{mingw64_bindir}/libpcre2-16-0.dll
%{mingw64_bindir}/libpcre2-32-0.dll
%{mingw64_bindir}/libpcre2-posix-1.dll
%{mingw64_bindir}/libpcre2-posix-2.dll
%{mingw64_libdir}/libpcre2-8.dll.a
%{mingw64_libdir}/libpcre2-16.dll.a
%{mingw64_libdir}/libpcre2-32.dll.a
@ -224,6 +179,9 @@ chmod 0644 %{buildroot}%{mingw64_libdir}/*.dll.a
%changelog
* Tue Aug 15 2017 Sandro Mani <manisandro@gmail.com> - 10.30-1
- Update to 10.30
* Wed Jul 26 2017 Fedora Release Engineering <releng@fedoraproject.org> - 10.23-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Mass_Rebuild

View File

@ -1,105 +0,0 @@
From 86c1fb487cd84b1971d4446e58ddb1602c95fdc3 Mon Sep 17 00:00:00 2001
From: ph10 <ph10@6239d852-aaf2-0410-a92c-79f79f948069>
Date: Thu, 23 Feb 2017 17:05:43 +0000
Subject: [PATCH] Check malloc returns in pcre2test.
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
git-svn-id: svn://vcs.exim.org/pcre2/code/trunk@669 6239d852-aaf2-0410-a92c-79f79f948069
Petr Písař: Ported to 10.23.
---
ChangeLog | 9 +++++++++
configure.ac | 6 +++---
src/pcre2.h | 6 +++---
src/pcre2test.c | 22 +++++++++++++++++++---
testdata/testinput2 | 3 +++
testdata/testoutput2 | 4 ++++
6 files changed, 41 insertions(+), 9 deletions(-)
diff --git a/src/pcre2test.c b/src/pcre2test.c
index 241c22c..01457e8 100644
--- a/src/pcre2test.c
+++ b/src/pcre2test.c
@@ -1365,8 +1365,7 @@ are supported. */
(test_mode == PCRE8_MODE && G(x,8)->f r (y)) || \
(test_mode == PCRE16_MODE && G(x,16)->f r (y)) || \
(test_mode == PCRE32_MODE && G(x,32)->f r (y)))
-
-
+
/* ----- Two out of three modes are supported ----- */
@@ -1775,7 +1774,7 @@ the three different cases. */
#define TESTFLD(x,f,r,y) ( \
(test_mode == G(G(PCRE,BITONE),_MODE) && G(x,BITONE)->f r (y)) || \
(test_mode == G(G(PCRE,BITTWO),_MODE) && G(x,BITTWO)->f r (y)))
-
+
#endif /* Two out of three modes */
@@ -6169,7 +6168,16 @@ if ((pat_patctl.control & CTL_POSIX) != 0)
if (msg[0] == 0) fprintf(outfile, "\n");
if (dat_datctl.oveccount > 0)
+ {
pmatch = (regmatch_t *)malloc(sizeof(regmatch_t) * dat_datctl.oveccount);
+ if (pmatch == NULL)
+ {
+ fprintf(outfile, "** Failed to get memory for recording matching "
+ "information (size set = %du)\n", dat_datctl.oveccount);
+ return PR_OK;
+ }
+ }
+
if ((dat_datctl.options & PCRE2_NOTBOL) != 0) eflags |= REG_NOTBOL;
if ((dat_datctl.options & PCRE2_NOTEOL) != 0) eflags |= REG_NOTEOL;
if ((dat_datctl.options & PCRE2_NOTEMPTY) != 0) eflags |= REG_NOTEMPTY;
@@ -6305,6 +6313,14 @@ else
PCRE2_MATCH_DATA_CREATE(match_data, max_oveccount, NULL);
}
+if (CASTVAR(void *, match_data) == NULL)
+ {
+ fprintf(outfile, "** Failed to get memory for recording matching "
+ "information (size requested: %d)\n", dat_datctl.oveccount);
+ max_oveccount = 0;
+ return PR_OK;
+ }
+
/* Replacement processing is ignored for DFA matching. */
if (dat_datctl.replacement[0] != 0 && (dat_datctl.control & CTL_DFA) != 0)
diff --git a/testdata/testinput2 b/testdata/testinput2
index a700d5a..921d83c 100644
--- a/testdata/testinput2
+++ b/testdata/testinput2
@@ -4969,4 +4969,7 @@ a)"xI
/(?<a>a)(?<b>b)\g{b}\g{a}\g{a}\g{a}\g{a}(?<a>xx)(?<b>zz)/I,dupnames
+//
+ \=ovector=7777777777
+
# End of testinput2
diff --git a/testdata/testoutput2 b/testdata/testoutput2
index ce8c667..9862ea3 100644
--- a/testdata/testoutput2
+++ b/testdata/testoutput2
@@ -15479,6 +15479,10 @@ First code unit = 'a'
Last code unit = 'z'
Subject length lower bound = 11
+//
+ \=ovector=7777777777
+** Invalid value in 'ovector=7777777777'
+
# End of testinput2
Error -63: PCRE2_ERROR_BADDATA (unknown error number)
Error -62: bad serialized data
--
2.7.4

View File

@ -1,51 +0,0 @@
From 23f3fd65eb57bdaa03701177bbd2043a08a3299e Mon Sep 17 00:00:00 2001
From: ph10 <ph10@6239d852-aaf2-0410-a92c-79f79f948069>
Date: Tue, 21 Mar 2017 16:18:54 +0000
Subject: [PATCH] Close serialization file in pcre2test after any error.
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
git-svn-id: svn://vcs.exim.org/pcre2/code/trunk@692 6239d852-aaf2-0410-a92c-79f79f948069
Petr Písař: Ported to 10.32.
diff --git a/src/pcre2test.c b/src/pcre2test.c
index 39eedbe..b6d3ec9 100644
--- a/src/pcre2test.c
+++ b/src/pcre2test.c
@@ -4456,6 +4456,7 @@ switch(cmd)
if (rc < 0)
{
serial_error(rc, "Serialization");
+ fclose(f);
break;
}
@@ -4469,6 +4470,7 @@ switch(cmd)
if (fwrite(serial, 1, serial_size, f) != serial_size)
{
fprintf(outfile, "** Wrong return from fwrite()\n");
+ fclose(f);
return PR_ABEND;
}
@@ -4496,6 +4498,7 @@ switch(cmd)
{
fprintf(outfile, "** Failed to get memory (size %lu) for #load\n",
(unsigned long int)serial_size);
+ fclose(f);
return PR_ABEND;
}
@@ -4503,6 +4506,7 @@ switch(cmd)
{
fprintf(outfile, "** Wrong return from fread()\n");
free(serial);
+ fclose(f);
return PR_ABEND;
}
fclose(f);
--
2.7.4

View File

@ -1,55 +0,0 @@
From 8ac12aa2c80b1a5eec8fdafa66611c8c7cde5af7 Mon Sep 17 00:00:00 2001
From: ph10 <ph10@6239d852-aaf2-0410-a92c-79f79f948069>
Date: Fri, 14 Apr 2017 12:14:41 +0000
Subject: [PATCH] Correct an incorrect cast.
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
git-svn-id: svn://vcs.exim.org/pcre2/code/trunk@748 6239d852-aaf2-0410-a92c-79f79f948069
Petr Písař: Ported to 10.23.
---
src/pcre2_valid_utf.c | 8 ++++----
2 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/src/pcre2_valid_utf.c b/src/pcre2_valid_utf.c
index 3e18f12..96e8bff 100644
--- a/src/pcre2_valid_utf.c
+++ b/src/pcre2_valid_utf.c
@@ -7,7 +7,7 @@ and semantics are as close as possible to those of the Perl 5 language.
Written by Philip Hazel
Original API code Copyright (c) 1997-2012 University of Cambridge
- New API code Copyright (c) 2016 University of Cambridge
+ New API code Copyright (c) 2016-2017 University of Cambridge
-----------------------------------------------------------------------------
Redistribution and use in source and binary forms, with or without
@@ -142,20 +142,20 @@ for (p = string; length > 0; p++)
if (c < 0xc0) /* Isolated 10xx xxxx byte */
{
- *erroroffset = (int)(p - string);
+ *erroroffset = (PCRE2_SIZE)(p - string);
return PCRE2_ERROR_UTF8_ERR20;
}
if (c >= 0xfe) /* Invalid 0xfe or 0xff bytes */
{
- *erroroffset = (int)(p - string);
+ *erroroffset = (PCRE2_SIZE)(p - string);
return PCRE2_ERROR_UTF8_ERR21;
}
ab = PRIV(utf8_table4)[c & 0x3f]; /* Number of additional bytes (1-5) */
if (length < ab) /* Missing bytes */
{
- *erroroffset = (int)(p - string);
+ *erroroffset = (PCRE2_SIZE)(p - string);
switch(ab - length)
{
case 1: return PCRE2_ERROR_UTF8_ERR1;
--
2.7.4

View File

@ -1,122 +0,0 @@
From 85f8f579ac7aa268290ed7bd3aca90d927a9b7e9 Mon Sep 17 00:00:00 2001
From: ph10 <ph10@6239d852-aaf2-0410-a92c-79f79f948069>
Date: Tue, 21 Mar 2017 17:46:21 +0000
Subject: [PATCH 1/2] Fix 32-bit error buffer size bug in pcre2test (Bugzilla
2079).
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
git-svn-id: svn://vcs.exim.org/pcre2/code/trunk@696 6239d852-aaf2-0410-a92c-79f79f948069
Petr Písař: Ported to 10.23.
---
doc/pcre2api.3 | 10 +++++-----
src/pcre2_error.c | 2 +-
src/pcre2test.c | 7 ++++---
testdata/testinput2 | 2 ++
testdata/testoutput2 | 3 +++
diff --git a/doc/pcre2api.3 b/doc/pcre2api.3
index e0a434a..0a3d2ee 100644
--- a/doc/pcre2api.3
+++ b/doc/pcre2api.3
@@ -1,4 +1,4 @@
-.TH PCRE2API 3 "24 December 2016" "PCRE2 10.23"
+.TH PCRE2API 3 "21 March 2017" "PCRE2 10.30"
.SH NAME
PCRE2 - Perl-compatible regular expressions (revised API)
.sp
@@ -2633,8 +2633,8 @@ The internal recursion limit was reached.
A text message for an error code from any PCRE2 function (compile, match, or
auxiliary) can be obtained by calling \fBpcre2_get_error_message()\fP. The code
is passed as the first argument, with the remaining two arguments specifying a
-code unit buffer and its length, into which the text message is placed. Note
-that the message is returned in code units of the appropriate width for the
+code unit buffer and its length in code units, into which the text message is
+placed. The message is returned in code units of the appropriate width for the
library that is being used.
.P
The returned message is terminated with a trailing zero, and the function
@@ -3321,6 +3321,6 @@ Cambridge, England.
.rs
.sp
.nf
-Last updated: 23 December 2016
-Copyright (c) 1997-2016 University of Cambridge.
+Last updated: 21 March 2017
+Copyright (c) 1997-2017 University of Cambridge.
.fi
diff --git a/src/pcre2_error.c b/src/pcre2_error.c
index 9eab4fc..e25c7e6 100644
--- a/src/pcre2_error.c
+++ b/src/pcre2_error.c
@@ -271,7 +271,7 @@ distinct.
Arguments:
enumber error number
buffer where to put the message (zero terminated)
- size size of the buffer
+ size size of the buffer in code units
Returns: length of message if all is well
negative on error
diff --git a/src/pcre2test.c b/src/pcre2test.c
index b6d3ec9..9289656 100644
--- a/src/pcre2test.c
+++ b/src/pcre2test.c
@@ -2889,7 +2889,7 @@ if (pbuffer32_size < 4*len + 4)
{
if (pbuffer32 != NULL) free(pbuffer32);
pbuffer32_size = 4*len + 4;
- if (pbuffer32_size < 256) pbuffer32_size = 256;
+ if (pbuffer32_size < 512) pbuffer32_size = 512;
pbuffer32 = (uint32_t *)malloc(pbuffer32_size);
if (pbuffer32 == NULL)
{
@@ -7600,7 +7600,8 @@ if (arg_error != NULL)
int errcode;
char *endptr;
-/* Ensure the relevant non-8-bit buffer is available. */
+/* Ensure the relevant non-8-bit buffer is available. Ensure that it is at
+least 128 code units, because it is used for retrieving error messages. */
#ifdef SUPPORT_PCRE2_16
if (test_mode == PCRE16_MODE)
@@ -7620,7 +7621,7 @@ if (arg_error != NULL)
#ifdef SUPPORT_PCRE2_32
if (test_mode == PCRE32_MODE)
{
- pbuffer32_size = 256;
+ pbuffer32_size = 512;
pbuffer32 = (uint32_t *)malloc(pbuffer32_size);
if (pbuffer32 == NULL)
{
diff --git a/testdata/testinput2 b/testdata/testinput2
index 5a77e88..d62e975 100644
--- a/testdata/testinput2
+++ b/testdata/testinput2
@@ -5017,4 +5017,6 @@ a)"xI
/(?<!\1((?U)1((?U))))(*F)/never_backslash_c,alt_bsux,anchored,extended
+/\g{3/
+
# End of testinput2
diff --git a/testdata/testoutput2 b/testdata/testoutput2
index 3288424..ebf5fbd 100644
--- a/testdata/testoutput2
+++ b/testdata/testoutput2
@@ -15570,6 +15570,9 @@ No match
/(?<!\1((?U)1((?U))))(*F)/never_backslash_c,alt_bsux,anchored,extended
+/\g{3/
+Failed: error 157 at offset 2: \g is not followed by a braced, angle-bracketed, or quoted name/number or by a plain number
+
# End of testinput2
Error -63: PCRE2_ERROR_BADDATA (unknown error number)
Error -62: bad serialized data
--
2.7.4

View File

@ -1,123 +0,0 @@
From be14c2f3f01dc2b6b574b3a86536ee8194945f7f Mon Sep 17 00:00:00 2001
From: ph10 <ph10@6239d852-aaf2-0410-a92c-79f79f948069>
Date: Fri, 24 Feb 2017 18:25:32 +0000
Subject: [PATCH] Fix 32-bit non-UTF property test crash.
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
git-svn-id: svn://vcs.exim.org/pcre2/code/trunk@670 6239d852-aaf2-0410-a92c-79f79f948069
Petr Písař: Ported to 10.23.
diff --git a/src/pcre2_internal.h b/src/pcre2_internal.h
index 6a8774c..720bbc9 100644
--- a/src/pcre2_internal.h
+++ b/src/pcre2_internal.h
@@ -1774,10 +1774,17 @@ typedef struct {
/* UCD access macros */
#define UCD_BLOCK_SIZE 128
-#define GET_UCD(ch) (PRIV(ucd_records) + \
+#define REAL_GET_UCD(ch) (PRIV(ucd_records) + \
PRIV(ucd_stage2)[PRIV(ucd_stage1)[(int)(ch) / UCD_BLOCK_SIZE] * \
UCD_BLOCK_SIZE + (int)(ch) % UCD_BLOCK_SIZE])
+#if PCRE2_CODE_UNIT_WIDTH == 32
+#define GET_UCD(ch) ((ch > MAX_UTF_CODE_POINT)? \
+ PRIV(dummy_ucd_record) : REAL_GET_UCD(ch))
+#else
+#define GET_UCD(ch) REAL_GET_UCD(ch)
+#endif
+
#define UCD_CHARTYPE(ch) GET_UCD(ch)->chartype
#define UCD_SCRIPT(ch) GET_UCD(ch)->script
#define UCD_CATEGORY(ch) PRIV(ucp_gentype)[UCD_CHARTYPE(ch)]
@@ -1834,6 +1841,9 @@ extern const uint8_t PRIV(utf8_table4)[];
#define _pcre2_default_compile_context PCRE2_SUFFIX(_pcre2_default_compile_context_)
#define _pcre2_default_match_context PCRE2_SUFFIX(_pcre2_default_match_context_)
#define _pcre2_default_tables PCRE2_SUFFIX(_pcre2_default_tables_)
+#if PCRE2_CODE_UNIT_WIDTH == 32
+#define _pcre2_dummy_ucd_record PCRE2_SUFFIX(_pcre2_dummy_ucd_record_)
+#endif
#define _pcre2_hspace_list PCRE2_SUFFIX(_pcre2_hspace_list_)
#define _pcre2_vspace_list PCRE2_SUFFIX(_pcre2_vspace_list_)
#define _pcre2_ucd_caseless_sets PCRE2_SUFFIX(_pcre2_ucd_caseless_sets_)
@@ -1858,6 +1868,9 @@ extern const uint32_t PRIV(hspace_list)[];
extern const uint32_t PRIV(vspace_list)[];
extern const uint32_t PRIV(ucd_caseless_sets)[];
extern const ucd_record PRIV(ucd_records)[];
+#if PCRE2_CODE_UNIT_WIDTH == 32
+extern const ucd_record PRIV(dummy_ucd_record)[];
+#endif
extern const uint8_t PRIV(ucd_stage1)[];
extern const uint16_t PRIV(ucd_stage2)[];
extern const uint32_t PRIV(ucp_gbtable)[];
diff --git a/src/pcre2_ucd.c b/src/pcre2_ucd.c
index 116f537..56aa29d 100644
--- a/src/pcre2_ucd.c
+++ b/src/pcre2_ucd.c
@@ -41,6 +41,20 @@ const uint32_t PRIV(ucd_caseless_sets)[] = {0};
const char *PRIV(unicode_version) = "8.0.0";
+/* If the 32-bit library is run in non-32-bit mode, character values
+greater than 0x10ffff may be encountered. For these we set up a
+special record. */
+
+#if PCRE2_CODE_UNIT_WIDTH == 32
+const ucd_record PRIV(dummy_ucd_record)[] = {{
+ ucp_Common, /* script */
+ ucp_Cn, /* type unassigned */
+ ucp_gbOther, /* grapheme break property */
+ 0, /* case set */
+ 0, /* other case */
+ }};
+#endif
+
/* When recompiling tables with a new Unicode version, please check the
types in this structure definition from pcre2_internal.h (the actual
field names will be different):
diff --git a/testdata/testinput12 b/testdata/testinput12
index c3b2bfc..decfe82 100644
--- a/testdata/testinput12
+++ b/testdata/testinput12
@@ -360,4 +360,7 @@
/[\s[:^ascii:]]/B,ucp
+/\pP/ucp
+ \x{7fffffff}\=no_jit
+
# End of testinput12
diff --git a/testdata/testoutput12-16 b/testdata/testoutput12-16
index 3b5a0cd..41e0a48 100644
--- a/testdata/testoutput12-16
+++ b/testdata/testoutput12-16
@@ -1415,4 +1415,10 @@ No match
End
------------------------------------------------------------------
+/\pP/ucp
+ \x{7fffffff}\=no_jit
+** Character \x{7fffffff} is greater than 0xffff and UTF-16 mode is not enabled.
+** Truncation will probably give the wrong result.
+No match
+
# End of testinput12
diff --git a/testdata/testoutput12-32 b/testdata/testoutput12-32
index 1496159..e9130b9 100644
--- a/testdata/testoutput12-32
+++ b/testdata/testoutput12-32
@@ -1409,4 +1409,8 @@ No match
End
------------------------------------------------------------------
+/\pP/ucp
+ \x{7fffffff}\=no_jit
+No match
+
# End of testinput12
--
2.7.4

View File

@ -1,37 +0,0 @@
From d5790ad94d486405ecaac3d8f5796f642e57bf06 Mon Sep 17 00:00:00 2001
From: ph10 <ph10@6239d852-aaf2-0410-a92c-79f79f948069>
Date: Tue, 21 Mar 2017 16:31:54 +0000
Subject: [PATCH] Fix NULL deference if pcre2_callout_enumerate() is called
with a NULL pattern when Unicode support is available (Bugzilla 2076).
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
git-svn-id: svn://vcs.exim.org/pcre2/code/trunk@694 6239d852-aaf2-0410-a92c-79f79f948069
Petr Písař: Ported to 10.23.
diff --git a/src/pcre2_pattern_info.c b/src/pcre2_pattern_info.c
index 0392a0b..5dd8ac5 100644
--- a/src/pcre2_pattern_info.c
+++ b/src/pcre2_pattern_info.c
@@ -261,11 +261,15 @@ pcre2_real_code *re = (pcre2_real_code *)code;
pcre2_callout_enumerate_block cb;
PCRE2_SPTR cc;
#ifdef SUPPORT_UNICODE
-BOOL utf = (re->overall_options & PCRE2_UTF) != 0;
+BOOL utf;
#endif
if (re == NULL) return PCRE2_ERROR_NULL;
+#ifdef SUPPORT_UNICODE
+utf = (re->overall_options & PCRE2_UTF) != 0;
+#endif
+
/* Check that the first field in the block is the magic number. If it is not,
return with PCRE2_ERROR_BADMAGIC. */
--
2.7.4

View File

@ -1,79 +0,0 @@
From 51b522c0120d061f54317f8a1cede05328c97aca Mon Sep 17 00:00:00 2001
From: ph10 <ph10@6239d852-aaf2-0410-a92c-79f79f948069>
Date: Sat, 25 Mar 2017 15:19:49 +0000
Subject: [PATCH] Fix bug introduced at 10.21: use memory allocator from the
pattern if no context is supplied to pcre2_match().
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Ported to 10.23:
commit 1b7e16d584f0560dd84d2a3260cf08e1a86cccc1
Author: ph10 <ph10@6239d852-aaf2-0410-a92c-79f79f948069>
Date: Sat Mar 25 15:19:49 2017 +0000
Fix bug introduced at 10.21: use memory allocator from the pattern if no
context is supplied to pcre2_match().
git-svn-id: svn://vcs.exim.org/pcre2/code/trunk@707 6239d852-aaf2-0410-a92c-
79f79f948069
Signed-off-by: Petr Písař <ppisar@redhat.com>
---
src/pcre2_match.c | 18 ++++++++++--------
1 file changed, 10 insertions(+), 8 deletions(-)
diff --git a/src/pcre2_match.c b/src/pcre2_match.c
index 78a9bac..52bb843 100644
--- a/src/pcre2_match.c
+++ b/src/pcre2_match.c
@@ -6518,11 +6518,6 @@ options |= (re->flags & FF) / ((FF & (~FF+1)) / (OO & (~OO+1)));
#undef FF
#undef OO
-/* A NULL match context means "use a default context" */
-
-if (mcontext == NULL)
- mcontext = (pcre2_match_context *)(&PRIV(default_match_context));
-
/* These two settings are used in the code for checking a UTF string that
follows immediately afterwards. Other values in the mb block are used only
during interpretive pcre_match() processing, not when the JIT support is in
@@ -6590,7 +6585,7 @@ if (utf && (options & PCRE2_NO_UTF_CHECK) == 0)
/* It is an error to set an offset limit without setting the flag at compile
time. */
-if (mcontext->offset_limit != PCRE2_UNSET &&
+if (mcontext != NULL && mcontext->offset_limit != PCRE2_UNSET &&
(re->overall_options & PCRE2_USE_OFFSET_LIMIT) == 0)
return PCRE2_ERROR_BADOFFSETLIMIT;
@@ -6609,7 +6604,15 @@ if (re->executable_jit != NULL && (options & ~PUBLIC_JIT_MATCH_OPTIONS) == 0)
}
#endif
-/* Carry on with non-JIT matching. */
+/* Carry on with non-JIT matching. A NULL match context means "use a default
+context", but we take the memory control functions from the pattern. */
+
+if (mcontext == NULL)
+ {
+ mcontext = (pcre2_match_context *)(&PRIV(default_match_context));
+ mb->memctl = re->memctl;
+ }
+else mb->memctl = mcontext->memctl;
anchored = ((re->overall_options | options) & PCRE2_ANCHORED) != 0;
firstline = (re->overall_options & PCRE2_FIRSTLINE) != 0;
@@ -6621,7 +6624,6 @@ bumpalong_limit = (mcontext->offset_limit == PCRE2_UNSET)?
mb->callout = mcontext->callout;
mb->callout_data = mcontext->callout_data;
-mb->memctl = mcontext->memctl;
#ifdef HEAP_MATCH_RECURSE
mb->stack_memctl = mcontext->stack_memctl;
#endif
--
2.7.4

View File

@ -1,119 +0,0 @@
From 749c2eb6994ee26c1fcf1eb7b57faf5c84e9878b Mon Sep 17 00:00:00 2001
From: zherczeg <zherczeg@6239d852-aaf2-0410-a92c-79f79f948069>
Date: Fri, 31 Mar 2017 05:40:37 +0000
Subject: [PATCH] Fix character type detection when 32-bit and UCP are enabled
but UTF is not in JIT.
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
git-svn-id: svn://vcs.exim.org/pcre2/code/trunk@720 6239d852-aaf2-0410-a92c-79f79f948069
Signed-off-by: Petr Písař <ppisar@redhat.com>
---
src/pcre2_jit_compile.c | 31 +++++++++++++++++++++++++++++++
testdata/testinput12 | 2 +-
testdata/testoutput12-16 | 2 +-
testdata/testoutput12-32 | 2 +-
4 files changed, 34 insertions(+), 3 deletions(-)
diff --git a/src/pcre2_jit_compile.c b/src/pcre2_jit_compile.c
index 846510a..e93143d 100644
--- a/src/pcre2_jit_compile.c
+++ b/src/pcre2_jit_compile.c
@@ -588,6 +588,8 @@ the start pointers when the end of the capturing group has not yet reached. */
#define READ_CHAR_MAX 0x7fffffff
+#define INVALID_UTF_CHAR 888
+
static PCRE2_SPTR bracketend(PCRE2_SPTR cc)
{
SLJIT_ASSERT((*cc >= OP_ASSERT && *cc <= OP_ASSERTBACK_NOT) || (*cc >= OP_ONCE && *cc <= OP_SCOND));
@@ -3558,10 +3560,30 @@ static void do_getucd(compiler_common *common)
/* Search the UCD record for the character comes in TMP1.
Returns chartype in TMP1 and UCD offset in TMP2. */
DEFINE_COMPILER;
+#if PCRE2_CODE_UNIT_WIDTH == 32
+struct sljit_jump *jump;
+#endif
+
+#if defined SLJIT_DEBUG && SLJIT_DEBUG
+/* dummy_ucd_record */
+const ucd_record *record = GET_UCD(INVALID_UTF_CHAR);
+SLJIT_ASSERT(record->script == ucp_Common && record->chartype == ucp_Cn && record->gbprop == ucp_gbOther);
+SLJIT_ASSERT(record->caseset == 0 && record->other_case == 0);
+#endif
SLJIT_ASSERT(UCD_BLOCK_SIZE == 128 && sizeof(ucd_record) == 8);
sljit_emit_fast_enter(compiler, RETURN_ADDR, 0);
+
+#if PCRE2_CODE_UNIT_WIDTH == 32
+if (!common->utf)
+ {
+ jump = CMP(SLJIT_LESS, TMP1, 0, SLJIT_IMM, MAX_UTF_CODE_POINT + 1);
+ OP1(SLJIT_MOV, TMP1, 0, SLJIT_IMM, INVALID_UTF_CHAR);
+ JUMPHERE(jump);
+ }
+#endif
+
OP2(SLJIT_LSHR, TMP2, 0, TMP1, 0, SLJIT_IMM, UCD_BLOCK_SHIFT);
OP1(SLJIT_MOV_U8, TMP2, 0, SLJIT_MEM1(TMP2), (sljit_sw)PRIV(ucd_stage1));
OP2(SLJIT_AND, TMP1, 0, TMP1, 0, SLJIT_IMM, UCD_BLOCK_MASK);
@@ -5969,6 +5991,15 @@ if (needstype || needsscript)
if (needschar && !charsaved)
OP1(SLJIT_MOV, RETURN_ADDR, 0, TMP1, 0);
+#if PCRE2_CODE_UNIT_WIDTH == 32
+ if (!common->utf)
+ {
+ jump = CMP(SLJIT_LESS, TMP1, 0, SLJIT_IMM, MAX_UTF_CODE_POINT + 1);
+ OP1(SLJIT_MOV, TMP1, 0, SLJIT_IMM, INVALID_UTF_CHAR);
+ JUMPHERE(jump);
+ }
+#endif
+
OP2(SLJIT_LSHR, TMP2, 0, TMP1, 0, SLJIT_IMM, UCD_BLOCK_SHIFT);
OP1(SLJIT_MOV_U8, TMP2, 0, SLJIT_MEM1(TMP2), (sljit_sw)PRIV(ucd_stage1));
OP2(SLJIT_AND, TMP1, 0, TMP1, 0, SLJIT_IMM, UCD_BLOCK_MASK);
diff --git a/testdata/testinput12 b/testdata/testinput12
index decfe82..cca5dfa 100644
--- a/testdata/testinput12
+++ b/testdata/testinput12
@@ -361,6 +361,6 @@
/[\s[:^ascii:]]/B,ucp
/\pP/ucp
- \x{7fffffff}\=no_jit
+ \x{7fffffff}
# End of testinput12
diff --git a/testdata/testoutput12-16 b/testdata/testoutput12-16
index 41e0a48..33b8a33 100644
--- a/testdata/testoutput12-16
+++ b/testdata/testoutput12-16
@@ -1416,7 +1416,7 @@ No match
------------------------------------------------------------------
/\pP/ucp
- \x{7fffffff}\=no_jit
+ \x{7fffffff}
** Character \x{7fffffff} is greater than 0xffff and UTF-16 mode is not enabled.
** Truncation will probably give the wrong result.
No match
diff --git a/testdata/testoutput12-32 b/testdata/testoutput12-32
index e9130b9..1abeb59 100644
--- a/testdata/testoutput12-32
+++ b/testdata/testoutput12-32
@@ -1410,7 +1410,7 @@ No match
------------------------------------------------------------------
/\pP/ucp
- \x{7fffffff}\=no_jit
+ \x{7fffffff}
No match
# End of testinput12
--
2.7.4

View File

@ -1,187 +0,0 @@
From 9db78c678d82cc166f77b007e4834354ecf690bd Mon Sep 17 00:00:00 2001
From: ph10 <ph10@6239d852-aaf2-0410-a92c-79f79f948069>
Date: Thu, 16 Mar 2017 17:17:47 +0000
Subject: [PATCH] Fix crash for forward reference in lookbehind with
PCRE2_ANCHORED. Fixes oss-fuzz issue 865.
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Ported to 10.23:
commit a74ea02e5006bae4484b508b04a010e90c4dfdc2
Author: ph10 <ph10@6239d852-aaf2-0410-a92c-79f79f948069>
Date: Thu Mar 16 17:17:47 2017 +0000
Fix crash for forward reference in lookbehind with PCRE2_ANCHORED. Fixes
oss-fuzz issue 865.
git-svn-id: svn://vcs.exim.org/pcre2/code/trunk@681 6239d852-aaf2-0410-a92c-79f79f948069
Signed-off-by: Petr Písař <ppisar@redhat.com>
---
src/pcre2_compile.c | 52 +++++++++++++++++++++++++++++++++++-----------------
testdata/testinput2 | 2 ++
testdata/testoutput2 | 2 ++
3 files changed, 39 insertions(+), 17 deletions(-)
diff --git a/src/pcre2_compile.c b/src/pcre2_compile.c
index 6d98a68..26831d7 100644
--- a/src/pcre2_compile.c
+++ b/src/pcre2_compile.c
@@ -8049,6 +8049,10 @@ the end of the branch, it is called to skip over an internal lookaround, and it
is also called to skip to the end of a class, during which it will never
encounter nested groups (but there's no need to have special code for that).
+When called to find the end of a branch or group, pptr must point to the first
+meta code inside the branch, not the branch-starting code. In other cases it
+can point to the item that causes the function to be called.
+
Arguments:
pptr current pointer to skip from
skiptype PSKIP_CLASS when skipping to end of class
@@ -8065,10 +8069,10 @@ parsed_skip(uint32_t *pptr, uint32_t skiptype)
{
uint32_t nestlevel = 0;
-for (pptr += 1;; pptr++)
+for (;; pptr++)
{
uint32_t meta = META_CODE(*pptr);
-
+
switch(meta)
{
default: /* Just skip over most items */
@@ -8160,11 +8164,12 @@ return pptr;
/* This is called for nested groups within a branch of a lookbehind whose
length is being computed. If all the branches in the nested group have the same
length, that is OK. On entry, the pointer must be at the first element after
-the group initializing code. Caching is used to improve processing speed when
-the same capturing group occurs many times.
+the group initializing code. On exit it points to OP_KET. Caching is used to
+improve processing speed when the same capturing group occurs many times.
Arguments:
pptrptr pointer to pointer in the parsed pattern
+ isinline FALSE if a reference or recursion; TRUE for inline group
errcodeptr pointer to the errorcode
lcptr pointer to the loop counter
group number of captured group or -1 for a non-capturing group
@@ -8175,27 +8180,29 @@ Returns: the group length or a negative number
*/
static int
-get_grouplength(uint32_t **pptrptr, int *errcodeptr, int *lcptr,
+get_grouplength(uint32_t **pptrptr, BOOL isinline, int *errcodeptr, int *lcptr,
int group, parsed_recurse_check *recurses, compile_block *cb)
{
int branchlength;
int grouplength = -1;
/* The cache can be used only if there is no possibility of there being two
-groups with the same number. */
+groups with the same number. We do not need to set the end pointer for a group
+that is being processed as a back reference or recursion, but we must do so for
+an inline group. */
-if (group > 0)
+if (group > 0 && (cb->external_flags & PCRE2_DUPCAPUSED) == 0)
{
uint32_t groupinfo = cb->groupinfo[group];
- if ((cb->external_flags & PCRE2_DUPCAPUSED) == 0)
+ if ((groupinfo & GI_NOT_FIXED_LENGTH) != 0) return -1;
+ if ((groupinfo & GI_SET_FIXED_LENGTH) != 0)
{
- if ((groupinfo & GI_NOT_FIXED_LENGTH) != 0) return -1;
- if ((groupinfo & GI_SET_FIXED_LENGTH) != 0)
- return groupinfo & GI_FIXED_LENGTH_MASK;
+ if (isinline) *pptrptr = parsed_skip(*pptrptr, PSKIP_KET);
+ return groupinfo & GI_FIXED_LENGTH_MASK;
}
}
-/* Scan the group */
+/* Scan the group. In this case we find the end pointer of necessity. */
for(;;)
{
@@ -8353,11 +8360,12 @@ for (;; pptr++)
}
break;
- /* Lookaheads can be ignored. */
+ /* Lookaheads can be ignored, but we must start the skip inside the group
+ so that it isn't treated as a group within the branch. */
case META_LOOKAHEAD:
case META_LOOKAHEADNOT:
- pptr = parsed_skip(pptr, PSKIP_KET);
+ pptr = parsed_skip(pptr + 1, PSKIP_KET);
if (pptr == NULL) goto PARSED_SKIP_FAILED;
break;
@@ -8455,15 +8463,24 @@ for (;; pptr++)
else if (*gptr == (META_CAPTURE | group)) break;
}
- gptrend = parsed_skip(gptr, PSKIP_KET);
+ /* We must start the search for the end of the group at the first meta code
+ inside the group. Otherwise it will be treated as an enclosed group. */
+
+ gptrend = parsed_skip(gptr + 1, PSKIP_KET);
if (gptrend == NULL) goto PARSED_SKIP_FAILED;
if (pptr > gptr && pptr < gptrend) goto ISNOTFIXED; /* Local recursion */
for (r = recurses; r != NULL; r = r->prev) if (r->groupptr == gptr) break;
if (r != NULL) goto ISNOTFIXED; /* Mutual recursion */
this_recurse.prev = recurses;
this_recurse.groupptr = gptr;
+
+ /* We do not need to know the position of the end of the group, that is,
+ gptr is not used after the call to get_grouplength(). Setting the second
+ argument FALSE stops it scanning for the end when the length can be found
+ in the cache. */
+
gptr++;
- grouplength = get_grouplength(&gptr, errcodeptr, lcptr, group,
+ grouplength = get_grouplength(&gptr, FALSE, errcodeptr, lcptr, group,
&this_recurse, cb);
if (grouplength < 0)
{
@@ -8500,7 +8517,8 @@ for (;; pptr++)
case META_NOCAPTURE:
pptr++;
CHECK_GROUP:
- grouplength = get_grouplength(&pptr, errcodeptr, lcptr, group, recurses, cb);
+ grouplength = get_grouplength(&pptr, TRUE, errcodeptr, lcptr, group,
+ recurses, cb);
if (grouplength < 0) return -1;
itemlength = grouplength;
break;
diff --git a/testdata/testinput2 b/testdata/testinput2
index 921d83c..43692ea 100644
--- a/testdata/testinput2
+++ b/testdata/testinput2
@@ -4972,4 +4972,6 @@ a)"xI
//
\=ovector=7777777777
+/(?<!\1((?U)1((?U))))(*F)/never_backslash_c,alt_bsux,anchored,extended
+
# End of testinput2
diff --git a/testdata/testoutput2 b/testdata/testoutput2
index 9862ea3..cf9c8a3 100644
--- a/testdata/testoutput2
+++ b/testdata/testoutput2
@@ -15483,6 +15483,8 @@ Subject length lower bound = 11
\=ovector=7777777777
** Invalid value in 'ovector=7777777777'
+/(?<!\1((?U)1((?U))))(*F)/never_backslash_c,alt_bsux,anchored,extended
+
# End of testinput2
Error -63: PCRE2_ERROR_BADDATA (unknown error number)
Error -62: bad serialized data
--
2.7.4

View File

@ -1,255 +0,0 @@
From fcc05a01a8c1f87b3286a27dffc508dd5b0ced31 Mon Sep 17 00:00:00 2001
From: ph10 <ph10@6239d852-aaf2-0410-a92c-79f79f948069>
Date: Sat, 6 May 2017 16:56:07 +0000
Subject: [PATCH] Fix crash when more than one kind of "push" was set in
pcre2test.
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
git-svn-id: svn://vcs.exim.org/pcre2/code/trunk@767 6239d852-aaf2-0410-a92c-79f79f948069
Petr Písař: Ported to 10.23.
---
src/pcre2test.c | 15 +++++++++------
testdata/testinput20 | 44 ++++++++++++++++++++++++++------------------
testdata/testoutput20 | 47 +++++++++++++++++++++++++++++------------------
diff --git a/src/pcre2test.c b/src/pcre2test.c
index a7fe7c0..cab604f 100644
--- a/src/pcre2test.c
+++ b/src/pcre2test.c
@@ -721,12 +721,15 @@ the first control word. Note that CTL_POSIX_NOSUB is always accompanied by
CTL_POSIX, so it doesn't need its own entries. */
static uint32_t exclusive_pat_controls[] = {
- CTL_POSIX | CTL_HEXPAT,
- CTL_POSIX | CTL_PUSH,
- CTL_POSIX | CTL_PUSHCOPY,
- CTL_POSIX | CTL_PUSHTABLESCOPY,
- CTL_POSIX | CTL_USE_LENGTH,
- CTL_EXPAND | CTL_HEXPAT };
+ CTL_POSIX | CTL_HEXPAT,
+ CTL_POSIX | CTL_PUSH,
+ CTL_POSIX | CTL_PUSHCOPY,
+ CTL_POSIX | CTL_PUSHTABLESCOPY,
+ CTL_POSIX | CTL_USE_LENGTH,
+ CTL_PUSH | CTL_PUSHCOPY,
+ CTL_PUSH | CTL_PUSHTABLESCOPY,
+ CTL_PUSHCOPY | CTL_PUSHTABLESCOPY,
+ CTL_EXPAND | CTL_HEXPAT };
/* Data controls that are mutually exclusive. At present these are all in the
first control word. */
diff --git a/testdata/testinput20 b/testdata/testinput20
index c87a07e..71f39ae 100644
--- a/testdata/testinput20
+++ b/testdata/testinput20
@@ -31,20 +31,20 @@
#load testsaved2
#pop info
- foofoo
+ foofoo
barbar
-
+
#pop mark
C
-\= Expect no match
- D
-
+\= Expect no match
+ D
+
#pop
- AmanaplanacanalPanama
+ AmanaplanacanalPanama
#pop info
metcalfe 33
-
+
# Check for an error when different tables are used.
/abc/push,tables=1
@@ -59,30 +59,30 @@
#pop should give an error
pqr
-
+
/abcd/pushcopy
abcd
-
+
#pop
- abcd
+ abcd
#pop should give an error
/abcd/push
#popcopy
abcd
-
+
#pop
- abcd
-
+ abcd
+
/abcd/push
#save testsaved1
#pop should give an error
#load testsaved1
-#popcopy
+#popcopy
abcd
-
+
#pop
abcd
@@ -91,10 +91,18 @@
/abcd/pushtablescopy
abcd
-#popcopy
+#popcopy
abcd
-
+
#pop
- abcd
+ abcd
+
+# Must only specify one of these
+
+//push,pushcopy
+
+//push,pushtablescopy
+
+//pushcopy,pushtablescopy
# End of testinput20
diff --git a/testdata/testoutput20 b/testdata/testoutput20
index db99866..d6265fd 100644
--- a/testdata/testoutput20
+++ b/testdata/testoutput20
@@ -40,25 +40,25 @@ Named capturing subpatterns:
Options: dupnames
Starting code units: b f
Subject length lower bound = 6
- foofoo
+ foofoo
0: foofoo
1: foo
barbar
0: barbar
1: <unset>
2: bar
-
+
#pop mark
C
0: C
1: C
MK: A
-\= Expect no match
- D
+\= Expect no match
+ D
No match, mark = A
-
+
#pop
- AmanaplanacanalPanama
+ AmanaplanacanalPanama
0: AmanaplanacanalPanama
1: <unset>
2: <unset>
@@ -78,7 +78,7 @@ Subject length lower bound = 3
0: metcalfe 33
1: metcalfe
2: 33
-
+
# Check for an error when different tables are used.
/abc/push,tables=1
@@ -97,13 +97,13 @@ Serialization failed: error -30: patterns do not all use the same character tabl
#pop should give an error
** Can't pop off an empty stack
pqr
-
+
/abcd/pushcopy
abcd
0: abcd
-
+
#pop
- abcd
+ abcd
0: abcd
#pop should give an error
@@ -113,21 +113,21 @@ Serialization failed: error -30: patterns do not all use the same character tabl
#popcopy
abcd
0: abcd
-
+
#pop
- abcd
+ abcd
0: abcd
-
+
/abcd/push
#save testsaved1
#pop should give an error
** Can't pop off an empty stack
#load testsaved1
-#popcopy
+#popcopy
abcd
0: abcd
-
+
#pop
abcd
0: abcd
@@ -139,12 +139,23 @@ Serialization failed: error -30: patterns do not all use the same character tabl
abcd
0: abcd
-#popcopy
+#popcopy
abcd
0: abcd
-
+
#pop
- abcd
+ abcd
0: abcd
+# Must only specify one of these
+
+//push,pushcopy
+** Not allowed together: push pushcopy
+
+//push,pushtablescopy
+** Not allowed together: push pushtablescopy
+
+//pushcopy,pushtablescopy
+** Not allowed together: pushcopy pushtablescopy
+
# End of testinput20
--
2.9.3

View File

@ -1,40 +0,0 @@
From 0fece4355e2a5d494936d285eb200314112c9a8b Mon Sep 17 00:00:00 2001
From: ph10 <ph10@6239d852-aaf2-0410-a92c-79f79f948069>
Date: Tue, 21 Mar 2017 16:25:01 +0000
Subject: [PATCH] Fix memory leak when deserializing invalid data (Bugzilla
2075).
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
git-svn-id: svn://vcs.exim.org/pcre2/code/trunk@693 6239d852-aaf2-0410-a92c-79f79f948069
Petr Písař: Ported to 10.23.
diff --git a/src/pcre2_serialize.c b/src/pcre2_serialize.c
index 0af26d8..d2cc603 100644
--- a/src/pcre2_serialize.c
+++ b/src/pcre2_serialize.c
@@ -7,7 +7,7 @@ and semantics are as close as possible to those of the Perl 5 language.
Written by Philip Hazel
Original API code Copyright (c) 1997-2012 University of Cambridge
- New API code Copyright (c) 2016 University of Cambridge
+ New API code Copyright (c) 2016-2017 University of Cambridge
-----------------------------------------------------------------------------
Redistribution and use in source and binary forms, with or without
@@ -214,7 +214,10 @@ for (i = 0; i < number_of_codes; i++)
if (dst_re->magic_number != MAGIC_NUMBER ||
dst_re->name_entry_size > MAX_NAME_SIZE + IMM2_SIZE + 1 ||
dst_re->name_count > MAX_NAME_COUNT)
+ {
+ memctl->free(dst_re, memctl->memory_data);
return PCRE2_ERROR_BADSERIALIZEDDATA;
+ }
/* At the moment only one table is supported. */
--
2.7.4

View File

@ -1,101 +0,0 @@
From a96183f8281c6e8b0a42c5a05146a96f9540b673 Mon Sep 17 00:00:00 2001
From: ph10 <ph10@6239d852-aaf2-0410-a92c-79f79f948069>
Date: Wed, 22 Mar 2017 15:12:06 +0000
Subject: [PATCH] Fix misbehaving DFA match for possessively repeated character
class (Bugzilla 2086).
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Ported to 10.23:
commit 46399965f23c3efc1197823d1cd54084b27d9174
Author: ph10 <ph10@6239d852-aaf2-0410-a92c-79f79f948069>
Date: Wed Mar 22 15:12:06 2017 +0000
Fix misbehaving DFA match for possessively repeated character class (Bugzilla
2086).
git-svn-id: svn://vcs.exim.org/pcre2/code/trunk@698 6239d852-aaf2-0410-a92c-79f79f948069
Signed-off-by: Petr Písař <ppisar@redhat.com>
---
src/pcre2_dfa_match.c | 10 ++++++----
testdata/testinput6 | 3 +++
testdata/testoutput6 | 4 ++++
3 files changed, 13 insertions(+), 4 deletions(-)
diff --git a/src/pcre2_dfa_match.c b/src/pcre2_dfa_match.c
index c909d61..519a147 100644
--- a/src/pcre2_dfa_match.c
+++ b/src/pcre2_dfa_match.c
@@ -544,7 +544,7 @@ for (;;)
BOOL partial_newline = FALSE;
BOOL could_continue = reset_could_continue;
reset_could_continue = FALSE;
-
+
if (ptr > mb->last_used_ptr) mb->last_used_ptr = ptr;
/* Make the new state list into the active state list and empty the
@@ -597,7 +597,7 @@ for (;;)
int state_offset = current_state->offset;
int rrc;
int count;
-
+
/* A negative offset is a special case meaning "hold off going to this
(negated) state until the number of characters in the data field have
been skipped". If the could_continue flag was passed over from a previous
@@ -633,7 +633,7 @@ for (;;)
code = start_code + state_offset;
codevalue = *code;
-
+
/* If this opcode inspects a character, but we are at the end of the
subject, remember the fact for use when testing for a partial match. */
@@ -2539,11 +2539,13 @@ for (;;)
if (isinclass)
{
int max = (int)GET2(ecode, 1 + IMM2_SIZE);
- if (*ecode == OP_CRPOSRANGE)
+
+ if (*ecode == OP_CRPOSRANGE && count >= (int)GET2(ecode, 1))
{
active_count--; /* Remove non-match possibility */
next_active_state--;
}
+
if (++count >= max && max != 0) /* Max 0 => no limit */
{ ADD_NEW(next_state_offset + 1 + 2 * IMM2_SIZE, 0); }
else
diff --git a/testdata/testinput6 b/testdata/testinput6
index ee6cd1b..be9b767 100644
--- a/testdata/testinput6
+++ b/testdata/testinput6
@@ -4886,4 +4886,7 @@
\= Expect recursion limit exceeded
a[00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]
+/(02-)?[0-9]{3}-[0-9]{3}/
+ 02-123-123
+
# End of testinput6
diff --git a/testdata/testoutput6 b/testdata/testoutput6
index 62f2674..2930acc 100644
--- a/testdata/testoutput6
+++ b/testdata/testoutput6
@@ -7687,4 +7687,8 @@ No match
a[00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]
Failed: error -53: recursion limit exceeded
+/(02-)?[0-9]{3}-[0-9]{3}/
+ 02-123-123
+ 0: 02-123-123
+
# End of testinput6
--
2.7.4

View File

@ -1,183 +0,0 @@
From 37fdecdb938eae9aece6c3b552b26d9054212a43 Mon Sep 17 00:00:00 2001
From: ph10 <ph10@6239d852-aaf2-0410-a92c-79f79f948069>
Date: Sun, 19 Mar 2017 18:34:27 +0000
Subject: [PATCH] Fix pcre2test bug for global match with zero terminated
subject.
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Ported to 10.23:
commit 0f66bd9a67d59124c7f81b44ee28b6c1f26fd789
Author: ph10 <ph10@6239d852-aaf2-0410-a92c-79f79f948069>
Date: Sun Mar 19 18:34:27 2017 +0000
Fix pcre2test bug for global match with zero terminated subject.
git-svn-id: svn://vcs.exim.org/pcre2/code/trunk@687 6239d852-aaf2-0410-a92c-79f79f948069
Signed-off-by: Petr Písař <ppisar@redhat.com>
---
src/pcre2test.c | 38 ++++++++++++++++++++++----------------
testdata/testinput5 | 3 +++
testdata/testoutput5 | 4 ++++
3 files changed, 29 insertions(+), 16 deletions(-)
diff --git a/src/pcre2test.c b/src/pcre2test.c
index 01457e8..4220b46 100644
--- a/src/pcre2test.c
+++ b/src/pcre2test.c
@@ -5724,7 +5724,7 @@ Returns: PR_OK continue processing next line
static int
process_data(void)
{
-PCRE2_SIZE len, ulen;
+PCRE2_SIZE len, ulen, arg_ulen;
uint32_t gmatched;
uint32_t c, k;
uint32_t g_notempty = 0;
@@ -6087,6 +6087,7 @@ ENDSTRING:
SET(*q, 0);
len = CASTVAR(uint8_t *, q) - dbuffer; /* Length in bytes */
ulen = len/code_unit_size; /* Length in code units */
+arg_ulen = ulen; /* Value to use in match arg */
/* If the string was terminated by \= we must now interpret modifiers. */
@@ -6115,11 +6116,15 @@ if (pat_patctl.replacement[0] != 0 &&
}
/* We now have the subject in dbuffer, with len containing the byte length, and
-ulen containing the code unit length. Move the data to the end of the buffer so
-that a read over the end can be caught by valgrind or other means. If we have
-explicit valgrind support, mark the unused start of the buffer unaddressable.
-If we are using the POSIX interface, or testing zero-termination, we must
-include the terminating zero in the usable data. */
+ulen containing the code unit length, with a copy in arg_ulen for use in match
+function arguments (this gets changed to PCRE2_ZERO_TERMINATED when the
+zero_terminate modifier is present).
+
+Move the data to the end of the buffer so that a read over the end can be
+caught by valgrind or other means. If we have explicit valgrind support, mark
+the unused start of the buffer unaddressable. If we are using the POSIX
+interface, or testing zero-termination, we must include the terminating zero in
+the usable data. */
c = code_unit_size * (((pat_patctl.control & CTL_POSIX) +
(dat_datctl.control & CTL_ZERO_TERMINATE) != 0)? 1:0);
@@ -6250,7 +6255,7 @@ if ((dat_datctl.control & (CTL_ALLUSEDTEXT|CTL_DFA)) == CTL_ALLUSEDTEXT &&
/* Handle passing the subject as zero-terminated. */
if ((dat_datctl.control & CTL_ZERO_TERMINATE) != 0)
- ulen = PCRE2_ZERO_TERMINATED;
+ arg_ulen = PCRE2_ZERO_TERMINATED;
/* The nullcontext modifier is used to test calling pcre2_[jit_]match() with a
NULL context. */
@@ -6452,7 +6457,7 @@ if (dat_datctl.replacement[0] != 0)
rlen = PCRE2_ZERO_TERMINATED;
else
rlen = (CASTVAR(uint8_t *, r) - rbuffer)/code_unit_size;
- PCRE2_SUBSTITUTE(rc, compiled_code, pp, ulen, dat_datctl.offset,
+ PCRE2_SUBSTITUTE(rc, compiled_code, pp, arg_ulen, dat_datctl.offset,
dat_datctl.options|xoptions, match_data, dat_context,
rbuffer, rlen, nbuffer, &nsize);
@@ -6534,7 +6539,7 @@ else for (gmatched = 0;; gmatched++)
start_time = clock();
for (i = 0; i < timeitm; i++)
{
- PCRE2_DFA_MATCH(capcount, compiled_code, pp, ulen,
+ PCRE2_DFA_MATCH(capcount, compiled_code, pp, arg_ulen,
dat_datctl.offset, dat_datctl.options | g_notempty, match_data,
use_dat_context, dfa_workspace, DFA_WS_DIMENSION);
}
@@ -6545,7 +6550,7 @@ else for (gmatched = 0;; gmatched++)
start_time = clock();
for (i = 0; i < timeitm; i++)
{
- PCRE2_JIT_MATCH(capcount, compiled_code, pp, ulen,
+ PCRE2_JIT_MATCH(capcount, compiled_code, pp, arg_ulen,
dat_datctl.offset, dat_datctl.options | g_notempty, match_data,
use_dat_context);
}
@@ -6556,7 +6561,7 @@ else for (gmatched = 0;; gmatched++)
start_time = clock();
for (i = 0; i < timeitm; i++)
{
- PCRE2_MATCH(capcount, compiled_code, pp, ulen,
+ PCRE2_MATCH(capcount, compiled_code, pp, arg_ulen,
dat_datctl.offset, dat_datctl.options | g_notempty, match_data,
use_dat_context);
}
@@ -6572,9 +6577,9 @@ else for (gmatched = 0;; gmatched++)
if ((dat_datctl.control & CTL_FINDLIMITS) != 0)
{
- capcount = check_match_limit(pp, ulen, PCRE2_ERROR_MATCHLIMIT, "match");
+ capcount = check_match_limit(pp, arg_ulen, PCRE2_ERROR_MATCHLIMIT, "match");
if (FLD(compiled_code, executable_jit) == NULL)
- (void)check_match_limit(pp, ulen, PCRE2_ERROR_RECURSIONLIMIT,
+ (void)check_match_limit(pp, arg_ulen, PCRE2_ERROR_RECURSIONLIMIT,
"recursion");
}
@@ -6604,7 +6609,7 @@ else for (gmatched = 0;; gmatched++)
dfa_workspace = (int *)malloc(DFA_WS_DIMENSION*sizeof(int));
if (dfa_matched++ == 0)
dfa_workspace[0] = -1; /* To catch bad restart */
- PCRE2_DFA_MATCH(capcount, compiled_code, pp, ulen,
+ PCRE2_DFA_MATCH(capcount, compiled_code, pp, arg_ulen,
dat_datctl.offset, dat_datctl.options | g_notempty, match_data,
use_dat_context, dfa_workspace, DFA_WS_DIMENSION);
if (capcount == 0)
@@ -6616,10 +6621,10 @@ else for (gmatched = 0;; gmatched++)
else
{
if ((pat_patctl.control & CTL_JITFAST) != 0)
- PCRE2_JIT_MATCH(capcount, compiled_code, pp, ulen, dat_datctl.offset,
+ PCRE2_JIT_MATCH(capcount, compiled_code, pp, arg_ulen, dat_datctl.offset,
dat_datctl.options | g_notempty, match_data, use_dat_context);
else
- PCRE2_MATCH(capcount, compiled_code, pp, ulen, dat_datctl.offset,
+ PCRE2_MATCH(capcount, compiled_code, pp, arg_ulen, dat_datctl.offset,
dat_datctl.options | g_notempty, match_data, use_dat_context);
if (capcount == 0)
{
@@ -7032,6 +7037,7 @@ else for (gmatched = 0;; gmatched++)
pp += end_offset * code_unit_size;
len -= end_offset * code_unit_size;
ulen -= end_offset;
+ if (arg_ulen != PCRE2_ZERO_TERMINATED) arg_ulen -= end_offset;
}
}
} /* End of global loop */
diff --git a/testdata/testinput5 b/testdata/testinput5
index e5a43e5..a574872 100644
--- a/testdata/testinput5
+++ b/testdata/testinput5
@@ -1763,4 +1763,7 @@
/[^\HH]/Bi,utf
+//g,utf
+ \=zero_terminate
+
# End of testinput5
diff --git a/testdata/testoutput5 b/testdata/testoutput5
index 9651fd1..26f9569 100644
--- a/testdata/testoutput5
+++ b/testdata/testoutput5
@@ -4232,4 +4232,8 @@ Failed: error 125 at offset 2: lookbehind assertion is not fixed length
End
------------------------------------------------------------------
+//g,utf
+ \=zero_terminate
+ 0:
+
# End of testinput5
--
2.7.4

View File

@ -1,73 +0,0 @@
From 3091213a8f163aaad43390229380e22adb096787 Mon Sep 17 00:00:00 2001
From: ph10 <ph10@6239d852-aaf2-0410-a92c-79f79f948069>
Date: Tue, 21 Mar 2017 18:36:13 +0000
Subject: [PATCH 2/2] Previous patch was not quite complete.
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
git-svn-id: svn://vcs.exim.org/pcre2/code/trunk@697 6239d852-aaf2-0410-a92c-79f79f948069
Signed-off-by: Petr Písař <ppisar@redhat.com>
---
src/pcre2test.c | 15 +++++++++------
1 file changed, 9 insertions(+), 6 deletions(-)
diff --git a/src/pcre2test.c b/src/pcre2test.c
index 9289656..b979dd1 100644
--- a/src/pcre2test.c
+++ b/src/pcre2test.c
@@ -1017,9 +1017,9 @@ are supported. */
if (test_mode == PCRE8_MODE) \
r = pcre2_get_error_message_8(a,G(b,8),G(G(b,8),_size)); \
else if (test_mode == PCRE16_MODE) \
- r = pcre2_get_error_message_16(a,G(b,16),G(G(b,16),_size)); \
+ r = pcre2_get_error_message_16(a,G(b,16),G(G(b,16),_size/2)); \
else \
- r = pcre2_get_error_message_32(a,G(b,32),G(G(b,32),_size))
+ r = pcre2_get_error_message_32(a,G(b,32),G(G(b,32),_size/4))
#define PCRE2_GET_OVECTOR_COUNT(a,b) \
if (test_mode == PCRE8_MODE) \
@@ -1399,6 +1399,9 @@ the three different cases. */
/* ----- Common macros for two-mode cases ----- */
+#define BYTEONE (BITONE/8)
+#define BYTETWO (BITTWO/8)
+
#define CASTFLD(t,a,b) \
((test_mode == G(G(PCRE,BITONE),_MODE))? (t)(G(a,BITONE)->b) : \
(t)(G(a,BITTWO)->b))
@@ -1481,9 +1484,9 @@ the three different cases. */
#define PCRE2_GET_ERROR_MESSAGE(r,a,b) \
if (test_mode == G(G(PCRE,BITONE),_MODE)) \
- r = G(pcre2_get_error_message_,BITONE)(a,G(b,BITONE),G(G(b,BITONE),_size)); \
+ r = G(pcre2_get_error_message_,BITONE)(a,G(b,BITONE),G(G(b,BITONE),_size/BYTEONE)); \
else \
- r = G(pcre2_get_error_message_,BITTWO)(a,G(b,BITTWO),G(G(b,BITTWO),_size))
+ r = G(pcre2_get_error_message_,BITTWO)(a,G(b,BITTWO),G(G(b,BITTWO),_size/BYTETWO))
#define PCRE2_GET_OVECTOR_COUNT(a,b) \
if (test_mode == G(G(PCRE,BITONE),_MODE)) \
@@ -1904,7 +1907,7 @@ the three different cases. */
#define PCRE2_DFA_MATCH(a,b,c,d,e,f,g,h,i,j) \
a = pcre2_dfa_match_16(G(b,16),(PCRE2_SPTR16)c,d,e,f,G(g,16),h,i,j)
#define PCRE2_GET_ERROR_MESSAGE(r,a,b) \
- r = pcre2_get_error_message_16(a,G(b,16),G(G(b,16),_size))
+ r = pcre2_get_error_message_16(a,G(b,16),G(G(b,16),_size/2))
#define PCRE2_GET_OVECTOR_COUNT(a,b) a = pcre2_get_ovector_count_16(G(b,16))
#define PCRE2_GET_STARTCHAR(a,b) a = pcre2_get_startchar_16(G(b,16))
#define PCRE2_JIT_COMPILE(r,a,b) r = pcre2_jit_compile_16(G(a,16),b)
@@ -2000,7 +2003,7 @@ the three different cases. */
#define PCRE2_DFA_MATCH(a,b,c,d,e,f,g,h,i,j) \
a = pcre2_dfa_match_32(G(b,32),(PCRE2_SPTR32)c,d,e,f,G(g,32),h,i,j)
#define PCRE2_GET_ERROR_MESSAGE(r,a,b) \
- r = pcre2_get_error_message_32(a,G(b,32),G(G(b,32),_size))
+ r = pcre2_get_error_message_32(a,G(b,32),G(G(b,32),_size/4))
#define PCRE2_GET_OVECTOR_COUNT(a,b) a = pcre2_get_ovector_count_32(G(b,32))
#define PCRE2_GET_STARTCHAR(a,b) a = pcre2_get_startchar_32(G(b,32))
#define PCRE2_JIT_COMPILE(r,a,b) r = pcre2_jit_compile_32(G(a,32),b)
--
2.7.4

View File

@ -1 +1 @@
SHA512 (pcre2-10.23.tar.bz2) = 3e5910bd2405cc35934d91e4be760abe4f2e900202a20b6ba74adb7a3acb2b74b3bf9b0e97e8de10f8e8534133e0722e0bf0f5fb40d6c2c4520d1ed61749d456
SHA512 (pcre2-10.30.tar.bz2) = f247a9f917c75920793b9919a45bb1426d126246e7a5d04e39d9407e44b5781f894a90cd3d232b385436b2f22be391335ab782664dd3a28c79058a2fcc74dc3e