10.30-RC1 bump
This commit is contained in:
parent
0099a92309
commit
054cc8376c
1
.gitignore
vendored
1
.gitignore
vendored
@ -7,3 +7,4 @@
|
||||
/pcre2-10.22.tar.bz2
|
||||
/pcre2-10.23-RC1.tar.bz2
|
||||
/pcre2-10.23.tar.bz2
|
||||
/pcre2-10.30-RC1.tar.bz2
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -1,155 +0,0 @@
|
||||
From 0dd869d72a472eca78ab323fd7318b3fae00593b Mon Sep 17 00:00:00 2001
|
||||
From: ph10 <ph10@6239d852-aaf2-0410-a92c-79f79f948069>
|
||||
Date: Sat, 27 May 2017 15:49:29 +0000
|
||||
Subject: [PATCH] Fix lookbehind with zero-length branch in DFA matching. Fixes
|
||||
oss-fuzz 1959.
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
Petr Písař: Ported to 10.23:
|
||||
|
||||
commit 25926aac413c2b67359bc03c2a11a86a7a0718da
|
||||
Author: ph10 <ph10@6239d852-aaf2-0410-a92c-79f79f948069>
|
||||
Date: Sat May 27 15:49:29 2017 +0000
|
||||
|
||||
Fix lookbehind with zero-length branch in DFA matching. Fixes oss-fuzz 1959.
|
||||
|
||||
git-svn-id: svn://vcs.exim.org/pcre2/code/trunk@807 6239d852-aaf2-0410-a92c-79f79f948069
|
||||
|
||||
Signed-off-by: Petr Písař <ppisar@redhat.com>
|
||||
---
|
||||
src/pcre2_dfa_match.c | 30 +++++++++++-------------------
|
||||
testdata/testinput6 | 6 ++++++
|
||||
testdata/testoutput6 | 10 ++++++++++
|
||||
3 files changed, 27 insertions(+), 19 deletions(-)
|
||||
|
||||
diff --git a/src/pcre2_dfa_match.c b/src/pcre2_dfa_match.c
|
||||
index 519a147..7f0f9bf 100644
|
||||
--- a/src/pcre2_dfa_match.c
|
||||
+++ b/src/pcre2_dfa_match.c
|
||||
@@ -375,14 +375,10 @@ internal_dfa_match(
|
||||
{
|
||||
stateblock *active_states, *new_states, *temp_states;
|
||||
stateblock *next_active_state, *next_new_state;
|
||||
-
|
||||
const uint8_t *ctypes, *lcc, *fcc;
|
||||
PCRE2_SPTR ptr;
|
||||
PCRE2_SPTR end_code;
|
||||
-PCRE2_SPTR first_op;
|
||||
-
|
||||
dfa_recursion_info new_recursive;
|
||||
-
|
||||
int active_count, new_count, match_count;
|
||||
|
||||
/* Some fields in the mb block are frequently referenced, so we load them into
|
||||
@@ -417,21 +413,15 @@ active_states = (stateblock *)(workspace + 2);
|
||||
next_new_state = new_states = active_states + wscount;
|
||||
new_count = 0;
|
||||
|
||||
-first_op = this_start_code + 1 + LINK_SIZE +
|
||||
- ((*this_start_code == OP_CBRA || *this_start_code == OP_SCBRA ||
|
||||
- *this_start_code == OP_CBRAPOS || *this_start_code == OP_SCBRAPOS)
|
||||
- ? IMM2_SIZE:0);
|
||||
-
|
||||
/* The first thing in any (sub) pattern is a bracket of some sort. Push all
|
||||
the alternative states onto the list, and find out where the end is. This
|
||||
makes is possible to use this function recursively, when we want to stop at a
|
||||
matching internal ket rather than at the end.
|
||||
|
||||
-If the first opcode in the first alternative is OP_REVERSE, we are dealing with
|
||||
-a backward assertion. In that case, we have to find out the maximum amount to
|
||||
-move back, and set up each alternative appropriately. */
|
||||
+If we are dealing with a backward assertion we have to find out the maximum
|
||||
+amount to move back, and set up each alternative appropriately. */
|
||||
|
||||
-if (*first_op == OP_REVERSE)
|
||||
+if (*this_start_code == OP_ASSERTBACK || *this_start_code == OP_ASSERTBACK_NOT)
|
||||
{
|
||||
size_t max_back = 0;
|
||||
size_t gone_back;
|
||||
@@ -476,15 +466,17 @@ if (*first_op == OP_REVERSE)
|
||||
if (current_subject < mb->start_used_ptr)
|
||||
mb->start_used_ptr = current_subject;
|
||||
|
||||
- /* Now we can process the individual branches. */
|
||||
+ /* Now we can process the individual branches. There will be an OP_REVERSE at
|
||||
+ the start of each branch, except when the length of the branch is zero. */
|
||||
|
||||
end_code = this_start_code;
|
||||
do
|
||||
{
|
||||
- size_t back = (size_t)GET(end_code, 2+LINK_SIZE);
|
||||
+ uint32_t revlen = (end_code[1+LINK_SIZE] == OP_REVERSE)? 1 + LINK_SIZE : 0;
|
||||
+ size_t back = (revlen == 0)? 0 : (size_t)GET(end_code, 2+LINK_SIZE);
|
||||
if (back <= gone_back)
|
||||
{
|
||||
- int bstate = (int)(end_code - start_code + 2 + 2*LINK_SIZE);
|
||||
+ int bstate = (int)(end_code - start_code + 1 + LINK_SIZE + revlen);
|
||||
ADD_NEW_DATA(-bstate, 0, (int)(gone_back - back));
|
||||
}
|
||||
end_code += GET(end_code, 1);
|
||||
@@ -544,7 +536,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 +589,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 +625,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. */
|
||||
|
||||
diff --git a/testdata/testinput6 b/testdata/testinput6
|
||||
index be9b767..9fb96d2 100644
|
||||
--- a/testdata/testinput6
|
||||
+++ b/testdata/testinput6
|
||||
@@ -4889,4 +4889,10 @@
|
||||
/(02-)?[0-9]{3}-[0-9]{3}/
|
||||
02-123-123
|
||||
|
||||
+/(?<=abc|)/
|
||||
+ abcde\=aftertext
|
||||
+
|
||||
+/(?<=|abc)/
|
||||
+ abcde\=aftertext
|
||||
+
|
||||
# End of testinput6
|
||||
diff --git a/testdata/testoutput6 b/testdata/testoutput6
|
||||
index 2930acc..f75e731 100644
|
||||
--- a/testdata/testoutput6
|
||||
+++ b/testdata/testoutput6
|
||||
@@ -7691,4 +7691,14 @@ Failed: error -53: recursion limit exceeded
|
||||
02-123-123
|
||||
0: 02-123-123
|
||||
|
||||
+/(?<=abc|)/
|
||||
+ abcde\=aftertext
|
||||
+ 0:
|
||||
+ 0+ abcde
|
||||
+
|
||||
+/(?<=|abc)/
|
||||
+ abcde\=aftertext
|
||||
+ 0:
|
||||
+ 0+ abcde
|
||||
+
|
||||
# End of testinput6
|
||||
--
|
||||
2.9.4
|
||||
|
@ -1,231 +0,0 @@
|
||||
From 398087c31c9eeb80eecdc74440ada9ebe8e2a6d7 Mon Sep 17 00:00:00 2001
|
||||
From: ph10 <ph10@6239d852-aaf2-0410-a92c-79f79f948069>
|
||||
Date: Sat, 3 Jun 2017 16:42:58 +0000
|
||||
Subject: [PATCH] Fix matching offsets from regexec() in the POSIX wrapper when
|
||||
called with REG_STARTEND and a starting offset greater than zero.
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
Petr Písař: Ported to 10.23:
|
||||
|
||||
commit 4ed24ba49fc4a584c58509177e5a3ad6d1a000e4
|
||||
Author: ph10 <ph10@6239d852-aaf2-0410-a92c-79f79f948069>
|
||||
Date: Sat Jun 3 16:42:58 2017 +0000
|
||||
|
||||
Fix matching offsets from regexec() in the POSIX wrapper when called with
|
||||
REG_STARTEND and a starting offset greater than zero.
|
||||
|
||||
git-svn-id: svn://vcs.exim.org/pcre2/code/trunk@818 6239d852-aaf2-0410-a92c-79f79f9480
|
||||
69
|
||||
|
||||
Signed-off-by: Petr Písař <ppisar@redhat.com>
|
||||
---
|
||||
doc/pcre2posix.3 | 30 ++++++++++++++++++------------
|
||||
doc/pcre2test.1 | 14 ++++++++++++++
|
||||
src/pcre2posix.c | 4 ++--
|
||||
src/pcre2test.c | 16 +++++++++++++++-
|
||||
testdata/testinput18 | 10 ++++++++++
|
||||
testdata/testoutput18 | 17 +++++++++++++++++
|
||||
6 files changed, 76 insertions(+), 15 deletions(-)
|
||||
|
||||
diff --git a/doc/pcre2posix.3 b/doc/pcre2posix.3
|
||||
index 70a86d8..b37046b 100644
|
||||
--- a/doc/pcre2posix.3
|
||||
+++ b/doc/pcre2posix.3
|
||||
@@ -1,4 +1,4 @@
|
||||
-.TH PCRE2POSIX 3 "31 January 2016" "PCRE2 10.22"
|
||||
+.TH PCRE2POSIX 3 "03 June 2017" "PCRE2 10.30"
|
||||
.SH NAME
|
||||
PCRE2 - Perl-compatible regular expressions (revised API)
|
||||
.SH "SYNOPSIS"
|
||||
@@ -204,15 +204,21 @@ function.
|
||||
.sp
|
||||
REG_STARTEND
|
||||
.sp
|
||||
-The string is considered to start at \fIstring\fP + \fIpmatch[0].rm_so\fP and
|
||||
-to have a terminating NUL located at \fIstring\fP + \fIpmatch[0].rm_eo\fP
|
||||
-(there need not actually be a NUL at that location), regardless of the value of
|
||||
-\fInmatch\fP. This is a BSD extension, compatible with but not specified by
|
||||
-IEEE Standard 1003.2 (POSIX.2), and should be used with caution in software
|
||||
-intended to be portable to other systems. Note that a non-zero \fIrm_so\fP does
|
||||
-not imply REG_NOTBOL; REG_STARTEND affects only the location of the string, not
|
||||
-how it is matched. Setting REG_STARTEND and passing \fIpmatch\fP as NULL are
|
||||
-mutually exclusive; the error REG_INVARG is returned.
|
||||
+When this option is set, the string is considered to start at \fIstring\fP +
|
||||
+\fIpmatch[0].rm_so\fP and to have a terminating NUL located at \fIstring\fP +
|
||||
+\fIpmatch[0].rm_eo\fP (there need not actually be a NUL at that location),
|
||||
+regardless of the value of \fInmatch\fP. However, the offsets of the matched
|
||||
+string and any captured substrings are still given relative to the start of
|
||||
+\fIstring\fP. (Before PCRE2 release 10.30 these were given relative to
|
||||
+\fIstring\fP + \fIpmatch[0].rm_so\fP, but this differs from other
|
||||
+implementations.)
|
||||
+.P
|
||||
+This is a BSD extension, compatible with but not specified by IEEE Standard
|
||||
+1003.2 (POSIX.2), and should be used with caution in software intended to be
|
||||
+portable to other systems. Note that a non-zero \fIrm_so\fP does not imply
|
||||
+REG_NOTBOL; REG_STARTEND affects only the location of the string, not how it is
|
||||
+matched. Setting REG_STARTEND and passing \fIpmatch\fP as NULL are mutually
|
||||
+exclusive; the error REG_INVARG is returned.
|
||||
.P
|
||||
If the pattern was compiled with the REG_NOSUB flag, no data about any matched
|
||||
strings is returned. The \fInmatch\fP and \fIpmatch\fP arguments of
|
||||
@@ -271,6 +277,6 @@ Cambridge, England.
|
||||
.rs
|
||||
.sp
|
||||
.nf
|
||||
-Last updated: 31 January 2016
|
||||
-Copyright (c) 1997-2016 University of Cambridge.
|
||||
+Last updated: 03 June 2017
|
||||
+Copyright (c) 1997-2017 University of Cambridge.
|
||||
.fi
|
||||
diff --git a/doc/pcre2test.1 b/doc/pcre2test.1
|
||||
index bd7383e..f8ce5bf 100644
|
||||
--- a/doc/pcre2test.1
|
||||
+++ b/doc/pcre2test.1
|
||||
@@ -1023,6 +1023,20 @@ wrapper API to be used, the only option-setting modifiers that have any effect
|
||||
are \fBnotbol\fP, \fBnotempty\fP, and \fBnoteol\fP, causing REG_NOTBOL,
|
||||
REG_NOTEMPTY, and REG_NOTEOL, respectively, to be passed to \fBregexec()\fP.
|
||||
The other modifiers are ignored, with a warning message.
|
||||
+.P
|
||||
+There is one additional modifier that can be used with the POSIX wrapper. It is
|
||||
+ignored (with a warning) if used for non-POSIX matching.
|
||||
+.sp
|
||||
+ posix_startend=<n>[:<m>]
|
||||
+.sp
|
||||
+This causes the subject string to be passed to \fBregexec()\fP using the
|
||||
+REG_STARTEND option, which uses offsets to restrict which part of the string is
|
||||
+searched. If only one number is given, the end offset is passed as the end of
|
||||
+the subject string. For more detail of REG_STARTEND, see the
|
||||
+.\" HREF
|
||||
+\fBpcre2posix\fP
|
||||
+.\"
|
||||
+documentation.
|
||||
.
|
||||
.
|
||||
.SS "Setting match controls"
|
||||
diff --git a/src/pcre2posix.c b/src/pcre2posix.c
|
||||
index 4ecc701..8be969a 100644
|
||||
--- a/src/pcre2posix.c
|
||||
+++ b/src/pcre2posix.c
|
||||
@@ -338,8 +338,8 @@ if (rc >= 0)
|
||||
if ((size_t)rc > nmatch) rc = (int)nmatch;
|
||||
for (i = 0; i < (size_t)rc; i++)
|
||||
{
|
||||
- pmatch[i].rm_so = ovector[i*2];
|
||||
- pmatch[i].rm_eo = ovector[i*2+1];
|
||||
+ pmatch[i].rm_so = ovector[i*2] + so;
|
||||
+ pmatch[i].rm_eo = ovector[i*2+1] + so;
|
||||
}
|
||||
for (; i < nmatch; i++) pmatch[i].rm_so = pmatch[i].rm_eo = -1;
|
||||
return 0;
|
||||
diff --git a/src/pcre2test.c b/src/pcre2test.c
|
||||
index af05b68..ecb6811 100644
|
||||
--- a/src/pcre2test.c
|
||||
+++ b/src/pcre2test.c
|
||||
@@ -182,7 +182,7 @@ void vms_setsymbol( char *, char *, int );
|
||||
#endif
|
||||
#endif
|
||||
|
||||
-#define CFORE_UNSET UINT32_MAX /* Unset value for cfail/cerror fields */
|
||||
+#define CFORE_UNSET UINT32_MAX /* Unset value for startend/cfail/cerror fields */
|
||||
#define DFA_WS_DIMENSION 1000 /* Size of DFA workspace */
|
||||
#define DEFAULT_OVECCOUNT 15 /* Default ovector count */
|
||||
#define JUNK_OFFSET 0xdeadbeef /* For initializing ovector */
|
||||
@@ -502,6 +502,7 @@ typedef struct datctl { /* Structure for data line modifiers. */
|
||||
uint32_t control; /* Must be in same position as patctl */
|
||||
uint32_t control2; /* Must be in same position as patctl */
|
||||
uint8_t replacement[REPLACE_MODSIZE]; /* So must this */
|
||||
+ uint32_t startend[2];
|
||||
uint32_t cerror[2];
|
||||
uint32_t cfail[2];
|
||||
int32_t callout_data;
|
||||
@@ -615,6 +616,7 @@ static modstruct modlist[] = {
|
||||
{ "ph", MOD_DAT, MOD_OPT, PCRE2_PARTIAL_HARD, DO(options) },
|
||||
{ "posix", MOD_PAT, MOD_CTL, CTL_POSIX, PO(control) },
|
||||
{ "posix_nosub", MOD_PAT, MOD_CTL, CTL_POSIX|CTL_POSIX_NOSUB, PO(control) },
|
||||
+ { "posix_startend", MOD_DAT, MOD_IN2, 0, DO(startend) },
|
||||
{ "ps", MOD_DAT, MOD_OPT, PCRE2_PARTIAL_SOFT, DO(options) },
|
||||
{ "push", MOD_PAT, MOD_CTL, CTL_PUSH, PO(control) },
|
||||
{ "pushcopy", MOD_PAT, MOD_CTL, CTL_PUSHCOPY, PO(control) },
|
||||
@@ -6193,6 +6195,14 @@ if ((pat_patctl.control & CTL_POSIX) != 0)
|
||||
}
|
||||
}
|
||||
|
||||
+ if (dat_datctl.startend[0] != CFORE_UNSET)
|
||||
+ {
|
||||
+ pmatch[0].rm_so = dat_datctl.startend[0];
|
||||
+ pmatch[0].rm_eo = (dat_datctl.startend[1] != 0)?
|
||||
+ dat_datctl.startend[1] : len;
|
||||
+ eflags |= REG_STARTEND;
|
||||
+ }
|
||||
+
|
||||
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;
|
||||
@@ -6252,6 +6262,9 @@ if ((dat_datctl.control & (CTL_DFA|CTL_FINDLIMITS)) == (CTL_DFA|CTL_FINDLIMITS))
|
||||
dat_datctl.control &= ~CTL_FINDLIMITS;
|
||||
}
|
||||
|
||||
+if (dat_datctl.startend[0] != CFORE_UNSET)
|
||||
+ fprintf(outfile, "** \\=posix_startend ignored for non-POSIX matching\n");
|
||||
+
|
||||
/* ALLUSEDTEXT is not supported with JIT, but JIT is not used with DFA
|
||||
matching, even if the JIT compiler was used. */
|
||||
|
||||
@@ -7407,6 +7420,7 @@ memset(&def_datctl, 0, sizeof(datctl));
|
||||
def_datctl.oveccount = DEFAULT_OVECCOUNT;
|
||||
def_datctl.copy_numbers[0] = -1;
|
||||
def_datctl.get_numbers[0] = -1;
|
||||
+def_datctl.startend[0] = def_datctl.startend[1] = CFORE_UNSET;
|
||||
def_datctl.cerror[0] = def_datctl.cerror[1] = CFORE_UNSET;
|
||||
def_datctl.cfail[0] = def_datctl.cfail[1] = CFORE_UNSET;
|
||||
|
||||
diff --git a/testdata/testinput18 b/testdata/testinput18
|
||||
index bd1c6ad..d8d8084 100644
|
||||
--- a/testdata/testinput18
|
||||
+++ b/testdata/testinput18
|
||||
@@ -109,4 +109,14 @@
|
||||
/(?=(a\K))/
|
||||
a
|
||||
|
||||
+/^d(e)$/posix
|
||||
+ acdef\=posix_startend=2:4
|
||||
+ acde\=posix_startend=2
|
||||
+\= Expect no match
|
||||
+ acdef
|
||||
+ acdef\=posix_startend=2
|
||||
+
|
||||
+/^a\x{00}b$/posix
|
||||
+ a\x{00}b\=posix_startend=0:3
|
||||
+
|
||||
# End of testdata/testinput18
|
||||
diff --git a/testdata/testoutput18 b/testdata/testoutput18
|
||||
index fd6fac3..0c13abc 100644
|
||||
--- a/testdata/testoutput18
|
||||
+++ b/testdata/testoutput18
|
||||
@@ -168,4 +168,21 @@ Start of matched string is beyond its end - displaying from end to start.
|
||||
0: a
|
||||
1: a
|
||||
|
||||
+/^d(e)$/posix
|
||||
+ acdef\=posix_startend=2:4
|
||||
+ 0: de
|
||||
+ 1: e
|
||||
+ acde\=posix_startend=2
|
||||
+ 0: de
|
||||
+ 1: e
|
||||
+\= Expect no match
|
||||
+ acdef
|
||||
+No match: POSIX code 17: match failed
|
||||
+ acdef\=posix_startend=2
|
||||
+No match: POSIX code 17: match failed
|
||||
+
|
||||
+/^a\x{00}b$/posix
|
||||
+ a\x{00}b\=posix_startend=0:3
|
||||
+ 0: a\x00b
|
||||
+
|
||||
# End of testdata/testinput18
|
||||
--
|
||||
2.9.4
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -0,0 +1,457 @@
|
||||
From 953920c6fac83750ac8a4528672f1bd2c41d1fc6 Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Petr=20P=C3=ADsa=C5=99?= <ppisar@redhat.com>
|
||||
Date: Thu, 20 Jul 2017 10:38:24 +0200
|
||||
Subject: [PATCH] Distribute forgotten sljitProtExecAllocator.c
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
Signed-off-by: Petr Písař <ppisar@redhat.com>
|
||||
---
|
||||
Makefile.am | 1 +
|
||||
src/sljit/sljitProtExecAllocator.c | 421 +++++++++++++++++++++++++++++++++++++
|
||||
2 files changed, 422 insertions(+)
|
||||
create mode 100644 src/sljit/sljitProtExecAllocator.c
|
||||
|
||||
diff --git a/Makefile.am b/Makefile.am
|
||||
index bbf23b8..7fa98c5 100644
|
||||
--- a/Makefile.am
|
||||
+++ b/Makefile.am
|
||||
@@ -442,6 +442,7 @@ EXTRA_DIST += \
|
||||
src/sljit/sljitNativeX86_32.c \
|
||||
src/sljit/sljitNativeX86_64.c \
|
||||
src/sljit/sljitNativeX86_common.c \
|
||||
+ src/sljit/sljitProtExecAllocator.c \
|
||||
src/sljit/sljitUtils.c
|
||||
|
||||
# Some of the JIT sources are also in separate files that are #included.
|
||||
diff --git a/src/sljit/sljitProtExecAllocator.c b/src/sljit/sljitProtExecAllocator.c
|
||||
new file mode 100644
|
||||
index 0000000..8a5b2b3
|
||||
--- /dev/null
|
||||
+++ b/src/sljit/sljitProtExecAllocator.c
|
||||
@@ -0,0 +1,421 @@
|
||||
+/*
|
||||
+ * Stack-less Just-In-Time compiler
|
||||
+ *
|
||||
+ * Copyright Zoltan Herczeg (hzmester@freemail.hu). All rights reserved.
|
||||
+ *
|
||||
+ * Redistribution and use in source and binary forms, with or without modification, are
|
||||
+ * permitted provided that the following conditions are met:
|
||||
+ *
|
||||
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
+ * conditions and the following disclaimer.
|
||||
+ *
|
||||
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
+ * of conditions and the following disclaimer in the documentation and/or other materials
|
||||
+ * provided with the distribution.
|
||||
+ *
|
||||
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) AND CONTRIBUTORS ``AS IS'' AND ANY
|
||||
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
|
||||
+ * SHALL THE COPYRIGHT HOLDER(S) OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
||||
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
|
||||
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
+ */
|
||||
+
|
||||
+/*
|
||||
+ This file contains a simple executable memory allocator
|
||||
+
|
||||
+ It is assumed, that executable code blocks are usually medium (or sometimes
|
||||
+ large) memory blocks, and the allocator is not too frequently called (less
|
||||
+ optimized than other allocators). Thus, using it as a generic allocator is
|
||||
+ not suggested.
|
||||
+
|
||||
+ How does it work:
|
||||
+ Memory is allocated in continuous memory areas called chunks by alloc_chunk()
|
||||
+ Chunk format:
|
||||
+ [ block ][ block ] ... [ block ][ block terminator ]
|
||||
+
|
||||
+ All blocks and the block terminator is started with block_header. The block
|
||||
+ header contains the size of the previous and the next block. These sizes
|
||||
+ can also contain special values.
|
||||
+ Block size:
|
||||
+ 0 - The block is a free_block, with a different size member.
|
||||
+ 1 - The block is a block terminator.
|
||||
+ n - The block is used at the moment, and the value contains its size.
|
||||
+ Previous block size:
|
||||
+ 0 - This is the first block of the memory chunk.
|
||||
+ n - The size of the previous block.
|
||||
+
|
||||
+ Using these size values we can go forward or backward on the block chain.
|
||||
+ The unused blocks are stored in a chain list pointed by free_blocks. This
|
||||
+ list is useful if we need to find a suitable memory area when the allocator
|
||||
+ is called.
|
||||
+
|
||||
+ When a block is freed, the new free block is connected to its adjacent free
|
||||
+ blocks if possible.
|
||||
+
|
||||
+ [ free block ][ used block ][ free block ]
|
||||
+ and "used block" is freed, the three blocks are connected together:
|
||||
+ [ one big free block ]
|
||||
+*/
|
||||
+
|
||||
+/* --------------------------------------------------------------------- */
|
||||
+/* System (OS) functions */
|
||||
+/* --------------------------------------------------------------------- */
|
||||
+
|
||||
+/* 64 KByte. */
|
||||
+#define CHUNK_SIZE 0x10000
|
||||
+
|
||||
+struct chunk_header {
|
||||
+ void *executable;
|
||||
+ int fd;
|
||||
+};
|
||||
+
|
||||
+/*
|
||||
+ alloc_chunk / free_chunk :
|
||||
+ * allocate executable system memory chunks
|
||||
+ * the size is always divisible by CHUNK_SIZE
|
||||
+ allocator_grab_lock / allocator_release_lock :
|
||||
+ * make the allocator thread safe
|
||||
+ * can be empty if the OS (or the application) does not support threading
|
||||
+ * only the allocator requires this lock, sljit is fully thread safe
|
||||
+ as it only uses local variables
|
||||
+*/
|
||||
+
|
||||
+#include <fcntl.h>
|
||||
+
|
||||
+#ifndef O_NOATIME
|
||||
+#define O_NOATIME 0
|
||||
+#endif
|
||||
+
|
||||
+#ifdef __O_TMPFILE
|
||||
+#ifndef O_TMPFILE
|
||||
+#define O_TMPFILE (__O_TMPFILE | O_DIRECTORY)
|
||||
+#endif
|
||||
+#endif
|
||||
+
|
||||
+int mkostemp(char *template, int flags);
|
||||
+char *secure_getenv(const char *name);
|
||||
+
|
||||
+static SLJIT_INLINE int create_tempfile(void)
|
||||
+{
|
||||
+ int fd;
|
||||
+
|
||||
+ char tmp_name[256];
|
||||
+ size_t tmp_name_len;
|
||||
+ char *dir;
|
||||
+ size_t len;
|
||||
+
|
||||
+#ifdef P_tmpdir
|
||||
+ len = (P_tmpdir != NULL) ? strlen(P_tmpdir) : 0;
|
||||
+
|
||||
+ if (len > 0 && len < sizeof(tmp_name)) {
|
||||
+ strcpy(tmp_name, P_tmpdir);
|
||||
+ tmp_name_len = len;
|
||||
+ }
|
||||
+ else {
|
||||
+ strcpy(tmp_name, "/tmp");
|
||||
+ tmp_name_len = 4;
|
||||
+ }
|
||||
+#else
|
||||
+ strcpy(tmp_name, "/tmp");
|
||||
+ tmp_name_len = 4;
|
||||
+#endif
|
||||
+
|
||||
+ dir = secure_getenv("TMPDIR");
|
||||
+ if (dir) {
|
||||
+ len = strlen(dir);
|
||||
+ if (len > 0 && len < sizeof(tmp_name)) {
|
||||
+ strcpy(tmp_name, dir);
|
||||
+ tmp_name_len = len;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ SLJIT_ASSERT(tmp_name_len > 0 && tmp_name_len < sizeof(tmp_name));
|
||||
+
|
||||
+ while (tmp_name_len > 0 && tmp_name[tmp_name_len - 1] == '/') {
|
||||
+ tmp_name_len--;
|
||||
+ tmp_name[tmp_name_len] = '\0';
|
||||
+ }
|
||||
+
|
||||
+#ifdef O_TMPFILE
|
||||
+ fd = open(tmp_name, O_TMPFILE | O_EXCL | O_RDWR | O_NOATIME | O_CLOEXEC, S_IRUSR | S_IWUSR);
|
||||
+ if (fd != -1)
|
||||
+ return fd;
|
||||
+#endif
|
||||
+
|
||||
+ if (tmp_name_len + 7 >= sizeof(tmp_name))
|
||||
+ {
|
||||
+ return -1;
|
||||
+ }
|
||||
+
|
||||
+ strcpy(tmp_name + tmp_name_len, "/XXXXXX");
|
||||
+ fd = mkostemp(tmp_name, O_CLOEXEC | O_NOATIME);
|
||||
+
|
||||
+ if (fd == -1)
|
||||
+ return fd;
|
||||
+
|
||||
+ if (unlink(tmp_name)) {
|
||||
+ close(fd);
|
||||
+ return -1;
|
||||
+ }
|
||||
+
|
||||
+ return fd;
|
||||
+}
|
||||
+
|
||||
+static SLJIT_INLINE struct chunk_header* alloc_chunk(sljit_uw size)
|
||||
+{
|
||||
+ struct chunk_header *retval;
|
||||
+ int fd;
|
||||
+
|
||||
+ fd = create_tempfile();
|
||||
+ if (fd == -1)
|
||||
+ return NULL;
|
||||
+
|
||||
+ if (ftruncate(fd, size)) {
|
||||
+ close(fd);
|
||||
+ return NULL;
|
||||
+ }
|
||||
+
|
||||
+ retval = (struct chunk_header *)mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
|
||||
+
|
||||
+ if (retval == MAP_FAILED) {
|
||||
+ close(fd);
|
||||
+ return NULL;
|
||||
+ }
|
||||
+
|
||||
+ retval->executable = mmap(NULL, size, PROT_READ | PROT_EXEC, MAP_SHARED, fd, 0);
|
||||
+
|
||||
+ if (retval->executable == MAP_FAILED) {
|
||||
+ munmap(retval, size);
|
||||
+ close(fd);
|
||||
+ return NULL;
|
||||
+ }
|
||||
+
|
||||
+ retval->fd = fd;
|
||||
+ return retval;
|
||||
+}
|
||||
+
|
||||
+static SLJIT_INLINE void free_chunk(void *chunk, sljit_uw size)
|
||||
+{
|
||||
+ struct chunk_header *header = ((struct chunk_header *)chunk) - 1;
|
||||
+
|
||||
+ int fd = header->fd;
|
||||
+ munmap(header->executable, size);
|
||||
+ munmap(header, size);
|
||||
+ close(fd);
|
||||
+}
|
||||
+
|
||||
+/* --------------------------------------------------------------------- */
|
||||
+/* Common functions */
|
||||
+/* --------------------------------------------------------------------- */
|
||||
+
|
||||
+#define CHUNK_MASK (~(CHUNK_SIZE - 1))
|
||||
+
|
||||
+struct block_header {
|
||||
+ sljit_uw size;
|
||||
+ sljit_uw prev_size;
|
||||
+ sljit_sw executable_offset;
|
||||
+};
|
||||
+
|
||||
+struct free_block {
|
||||
+ struct block_header header;
|
||||
+ struct free_block *next;
|
||||
+ struct free_block *prev;
|
||||
+ sljit_uw size;
|
||||
+};
|
||||
+
|
||||
+#define AS_BLOCK_HEADER(base, offset) \
|
||||
+ ((struct block_header*)(((sljit_u8*)base) + offset))
|
||||
+#define AS_FREE_BLOCK(base, offset) \
|
||||
+ ((struct free_block*)(((sljit_u8*)base) + offset))
|
||||
+#define MEM_START(base) ((void*)((base) + 1))
|
||||
+#define ALIGN_SIZE(size) (((size) + sizeof(struct block_header) + 7) & ~7)
|
||||
+
|
||||
+static struct free_block* free_blocks;
|
||||
+static sljit_uw allocated_size;
|
||||
+static sljit_uw total_size;
|
||||
+
|
||||
+static SLJIT_INLINE void sljit_insert_free_block(struct free_block *free_block, sljit_uw size)
|
||||
+{
|
||||
+ free_block->header.size = 0;
|
||||
+ free_block->size = size;
|
||||
+
|
||||
+ free_block->next = free_blocks;
|
||||
+ free_block->prev = NULL;
|
||||
+ if (free_blocks)
|
||||
+ free_blocks->prev = free_block;
|
||||
+ free_blocks = free_block;
|
||||
+}
|
||||
+
|
||||
+static SLJIT_INLINE void sljit_remove_free_block(struct free_block *free_block)
|
||||
+{
|
||||
+ if (free_block->next)
|
||||
+ free_block->next->prev = free_block->prev;
|
||||
+
|
||||
+ if (free_block->prev)
|
||||
+ free_block->prev->next = free_block->next;
|
||||
+ else {
|
||||
+ SLJIT_ASSERT(free_blocks == free_block);
|
||||
+ free_blocks = free_block->next;
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+SLJIT_API_FUNC_ATTRIBUTE void* sljit_malloc_exec(sljit_uw size)
|
||||
+{
|
||||
+ struct chunk_header *chunk_header;
|
||||
+ struct block_header *header;
|
||||
+ struct block_header *next_header;
|
||||
+ struct free_block *free_block;
|
||||
+ sljit_uw chunk_size;
|
||||
+ sljit_sw executable_offset;
|
||||
+
|
||||
+ allocator_grab_lock();
|
||||
+ if (size < (64 - sizeof(struct block_header)))
|
||||
+ size = (64 - sizeof(struct block_header));
|
||||
+ size = ALIGN_SIZE(size);
|
||||
+
|
||||
+ free_block = free_blocks;
|
||||
+ while (free_block) {
|
||||
+ if (free_block->size >= size) {
|
||||
+ chunk_size = free_block->size;
|
||||
+ if (chunk_size > size + 64) {
|
||||
+ /* We just cut a block from the end of the free block. */
|
||||
+ chunk_size -= size;
|
||||
+ free_block->size = chunk_size;
|
||||
+ header = AS_BLOCK_HEADER(free_block, chunk_size);
|
||||
+ header->prev_size = chunk_size;
|
||||
+ header->executable_offset = free_block->header.executable_offset;
|
||||
+ AS_BLOCK_HEADER(header, size)->prev_size = size;
|
||||
+ }
|
||||
+ else {
|
||||
+ sljit_remove_free_block(free_block);
|
||||
+ header = (struct block_header*)free_block;
|
||||
+ size = chunk_size;
|
||||
+ }
|
||||
+ allocated_size += size;
|
||||
+ header->size = size;
|
||||
+ allocator_release_lock();
|
||||
+ return MEM_START(header);
|
||||
+ }
|
||||
+ free_block = free_block->next;
|
||||
+ }
|
||||
+
|
||||
+ chunk_size = sizeof(struct chunk_header) + sizeof(struct block_header);
|
||||
+ chunk_size = (chunk_size + size + CHUNK_SIZE - 1) & CHUNK_MASK;
|
||||
+
|
||||
+ chunk_header = alloc_chunk(chunk_size);
|
||||
+ if (!chunk_header) {
|
||||
+ allocator_release_lock();
|
||||
+ return NULL;
|
||||
+ }
|
||||
+
|
||||
+ executable_offset = (sljit_sw)((sljit_u8*)chunk_header->executable - (sljit_u8*)chunk_header);
|
||||
+
|
||||
+ chunk_size -= sizeof(struct chunk_header) + sizeof(struct block_header);
|
||||
+ total_size += chunk_size;
|
||||
+
|
||||
+ header = (struct block_header *)(chunk_header + 1);
|
||||
+
|
||||
+ header->prev_size = 0;
|
||||
+ header->executable_offset = executable_offset;
|
||||
+ if (chunk_size > size + 64) {
|
||||
+ /* Cut the allocated space into a free and a used block. */
|
||||
+ allocated_size += size;
|
||||
+ header->size = size;
|
||||
+ chunk_size -= size;
|
||||
+
|
||||
+ free_block = AS_FREE_BLOCK(header, size);
|
||||
+ free_block->header.prev_size = size;
|
||||
+ free_block->header.executable_offset = executable_offset;
|
||||
+ sljit_insert_free_block(free_block, chunk_size);
|
||||
+ next_header = AS_BLOCK_HEADER(free_block, chunk_size);
|
||||
+ }
|
||||
+ else {
|
||||
+ /* All space belongs to this allocation. */
|
||||
+ allocated_size += chunk_size;
|
||||
+ header->size = chunk_size;
|
||||
+ next_header = AS_BLOCK_HEADER(header, chunk_size);
|
||||
+ }
|
||||
+ next_header->size = 1;
|
||||
+ next_header->prev_size = chunk_size;
|
||||
+ next_header->executable_offset = executable_offset;
|
||||
+ allocator_release_lock();
|
||||
+ return MEM_START(header);
|
||||
+}
|
||||
+
|
||||
+SLJIT_API_FUNC_ATTRIBUTE void sljit_free_exec(void* ptr)
|
||||
+{
|
||||
+ struct block_header *header;
|
||||
+ struct free_block* free_block;
|
||||
+
|
||||
+ allocator_grab_lock();
|
||||
+ header = AS_BLOCK_HEADER(ptr, -(sljit_sw)sizeof(struct block_header));
|
||||
+ header = AS_BLOCK_HEADER(header, -header->executable_offset);
|
||||
+ allocated_size -= header->size;
|
||||
+
|
||||
+ /* Connecting free blocks together if possible. */
|
||||
+
|
||||
+ /* If header->prev_size == 0, free_block will equal to header.
|
||||
+ In this case, free_block->header.size will be > 0. */
|
||||
+ free_block = AS_FREE_BLOCK(header, -(sljit_sw)header->prev_size);
|
||||
+ if (SLJIT_UNLIKELY(!free_block->header.size)) {
|
||||
+ free_block->size += header->size;
|
||||
+ header = AS_BLOCK_HEADER(free_block, free_block->size);
|
||||
+ header->prev_size = free_block->size;
|
||||
+ }
|
||||
+ else {
|
||||
+ free_block = (struct free_block*)header;
|
||||
+ sljit_insert_free_block(free_block, header->size);
|
||||
+ }
|
||||
+
|
||||
+ header = AS_BLOCK_HEADER(free_block, free_block->size);
|
||||
+ if (SLJIT_UNLIKELY(!header->size)) {
|
||||
+ free_block->size += ((struct free_block*)header)->size;
|
||||
+ sljit_remove_free_block((struct free_block*)header);
|
||||
+ header = AS_BLOCK_HEADER(free_block, free_block->size);
|
||||
+ header->prev_size = free_block->size;
|
||||
+ }
|
||||
+
|
||||
+ /* The whole chunk is free. */
|
||||
+ if (SLJIT_UNLIKELY(!free_block->header.prev_size && header->size == 1)) {
|
||||
+ /* If this block is freed, we still have (allocated_size / 2) free space. */
|
||||
+ if (total_size - free_block->size > (allocated_size * 3 / 2)) {
|
||||
+ total_size -= free_block->size;
|
||||
+ sljit_remove_free_block(free_block);
|
||||
+ free_chunk(free_block, free_block->size + sizeof(struct block_header));
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ allocator_release_lock();
|
||||
+}
|
||||
+
|
||||
+SLJIT_API_FUNC_ATTRIBUTE void sljit_free_unused_memory_exec(void)
|
||||
+{
|
||||
+ struct free_block* free_block;
|
||||
+ struct free_block* next_free_block;
|
||||
+
|
||||
+ allocator_grab_lock();
|
||||
+
|
||||
+ free_block = free_blocks;
|
||||
+ while (free_block) {
|
||||
+ next_free_block = free_block->next;
|
||||
+ if (!free_block->header.prev_size &&
|
||||
+ AS_BLOCK_HEADER(free_block, free_block->size)->size == 1) {
|
||||
+ total_size -= free_block->size;
|
||||
+ sljit_remove_free_block(free_block);
|
||||
+ free_chunk(free_block, free_block->size + sizeof(struct block_header));
|
||||
+ }
|
||||
+ free_block = next_free_block;
|
||||
+ }
|
||||
+
|
||||
+ SLJIT_ASSERT((total_size && free_blocks) || (!total_size && !free_blocks));
|
||||
+ allocator_release_lock();
|
||||
+}
|
||||
+
|
||||
+SLJIT_API_FUNC_ATTRIBUTE sljit_sw sljit_exec_offset(void* ptr)
|
||||
+{
|
||||
+ return ((struct block_header *)(ptr))[-1].executable_offset;
|
||||
+}
|
||||
--
|
||||
2.9.4
|
||||
|
31
pcre2-10.30-RC1-Fix-formatting-converted_length.patch
Normal file
31
pcre2-10.30-RC1-Fix-formatting-converted_length.patch
Normal file
@ -0,0 +1,31 @@
|
||||
From 0c0a69a8312a3fd9e20465940634a4caa6d84c07 Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Petr=20P=C3=ADsa=C5=99?= <ppisar@redhat.com>
|
||||
Date: Thu, 20 Jul 2017 13:14:19 +0200
|
||||
Subject: [PATCH] Fix formatting converted_length
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
size_t width varies among platforms.
|
||||
|
||||
Signed-off-by: Petr Písař <ppisar@redhat.com>
|
||||
---
|
||||
src/pcre2test.c | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/src/pcre2test.c b/src/pcre2test.c
|
||||
index 5d1cbdc..3775772 100644
|
||||
--- a/src/pcre2test.c
|
||||
+++ b/src/pcre2test.c
|
||||
@@ -5466,7 +5466,7 @@ if (pat_patctl.convert_type != CONVERT_UNSET)
|
||||
|
||||
if (rc != 0)
|
||||
{
|
||||
- fprintf(outfile, "** Pattern conversion error at offset %lu: ",
|
||||
+ fprintf(outfile, "** Pattern conversion error at offset %zu: ",
|
||||
converted_length);
|
||||
convert_return = print_error_message(rc, "", "\n")? PR_SKIP:PR_ABEND;
|
||||
}
|
||||
--
|
||||
2.9.4
|
||||
|
@ -0,0 +1,86 @@
|
||||
From e5a7fbea3d4478a57346135b8965c943a11da9c1 Mon Sep 17 00:00:00 2001
|
||||
From: ph10 <ph10@6239d852-aaf2-0410-a92c-79f79f948069>
|
||||
Date: Fri, 21 Jul 2017 08:53:02 +0000
|
||||
Subject: [PATCH] Put back pcre2_set_recursion_limit() as a real function,
|
||||
synonym for pcre2_set_depth_limit() in order to preserve the ABI.
|
||||
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@846 6239d852-aaf2-0410-a92c-79f79f948069
|
||||
|
||||
Petr Písař <ppisar@redhat.com>: Ported to 10.30-RC1
|
||||
---
|
||||
src/pcre2.h.generic | 4 +++-
|
||||
src/pcre2.h.in | 4 +++-
|
||||
src/pcre2_context.c | 8 +++++++-
|
||||
|
||||
diff --git a/src/pcre2.h.generic b/src/pcre2.h.generic
|
||||
index 7cafb4c..287b12a 100644
|
||||
--- a/src/pcre2.h.generic
|
||||
+++ b/src/pcre2.h.generic
|
||||
@@ -489,6 +489,8 @@ PCRE2_EXP_DECL int PCRE2_CALL_CONVENTION \
|
||||
PCRE2_EXP_DECL int PCRE2_CALL_CONVENTION \
|
||||
pcre2_set_offset_limit(pcre2_match_context *, PCRE2_SIZE); \
|
||||
PCRE2_EXP_DECL int PCRE2_CALL_CONVENTION \
|
||||
+ pcre2_set_recursion_limit(pcre2_match_context *, uint32_t); \
|
||||
+PCRE2_EXP_DECL int PCRE2_CALL_CONVENTION \
|
||||
pcre2_set_recursion_memory_management(pcre2_match_context *, \
|
||||
void *(*)(PCRE2_SIZE, void *), void (*)(void *, void *), void *);
|
||||
|
||||
@@ -760,7 +762,7 @@ pcre2_compile are called by application code. */
|
||||
#define pcre2_substring_number_from_name PCRE2_SUFFIX(pcre2_substring_number_from_name_)
|
||||
|
||||
/* Keep this old function name for backwards compatibility */
|
||||
-#define pcre2_set_recursion_limit pcre2_set_depth_limit
|
||||
+#define pcre2_set_recursion_limit PCRE2_SUFFIX(pcre2_set_recursion_limit_)
|
||||
|
||||
/* Keep this obsolete function for backwards compatibility: it is now a noop. */
|
||||
#define pcre2_set_recursion_memory_management PCRE2_SUFFIX(pcre2_set_recursion_memory_management_)
|
||||
diff --git a/src/pcre2.h.in b/src/pcre2.h.in
|
||||
index 399ddcd..4a8e126 100644
|
||||
--- a/src/pcre2.h.in
|
||||
+++ b/src/pcre2.h.in
|
||||
@@ -489,6 +489,8 @@ PCRE2_EXP_DECL int PCRE2_CALL_CONVENTION \
|
||||
PCRE2_EXP_DECL int PCRE2_CALL_CONVENTION \
|
||||
pcre2_set_offset_limit(pcre2_match_context *, PCRE2_SIZE); \
|
||||
PCRE2_EXP_DECL int PCRE2_CALL_CONVENTION \
|
||||
+ pcre2_set_recursion_limit(pcre2_match_context *, uint32_t); \
|
||||
+PCRE2_EXP_DECL int PCRE2_CALL_CONVENTION \
|
||||
pcre2_set_recursion_memory_management(pcre2_match_context *, \
|
||||
void *(*)(PCRE2_SIZE, void *), void (*)(void *, void *), void *);
|
||||
|
||||
@@ -760,7 +762,7 @@ pcre2_compile are called by application code. */
|
||||
#define pcre2_substring_number_from_name PCRE2_SUFFIX(pcre2_substring_number_from_name_)
|
||||
|
||||
/* Keep this old function name for backwards compatibility */
|
||||
-#define pcre2_set_recursion_limit pcre2_set_depth_limit
|
||||
+#define pcre2_set_recursion_limit PCRE2_SUFFIX(pcre2_set_recursion_limit_)
|
||||
|
||||
/* Keep this obsolete function for backwards compatibility: it is now a noop. */
|
||||
#define pcre2_set_recursion_memory_management PCRE2_SUFFIX(pcre2_set_recursion_memory_management_)
|
||||
diff --git a/src/pcre2_context.c b/src/pcre2_context.c
|
||||
index 9e557da..2c14df0 100644
|
||||
--- a/src/pcre2_context.c
|
||||
+++ b/src/pcre2_context.c
|
||||
@@ -431,10 +431,16 @@ mcontext->offset_limit = limit;
|
||||
return 0;
|
||||
}
|
||||
|
||||
-/* This function became obsolete at release 10.30. It is kept as a no-op for
|
||||
+/* This function became obsolete at release 10.30. It is kept as a synonym for
|
||||
backwards compatibility. */
|
||||
|
||||
PCRE2_EXP_DEFN int PCRE2_CALL_CONVENTION
|
||||
+pcre2_set_recursion_limit(pcre2_match_context *mcontext, uint32_t limit)
|
||||
+{
|
||||
+return pcre2_set_depth_limit(mcontext, limit);
|
||||
+}
|
||||
+
|
||||
+PCRE2_EXP_DEFN int PCRE2_CALL_CONVENTION
|
||||
pcre2_set_recursion_memory_management(pcre2_match_context *mcontext,
|
||||
void *(*mymalloc)(size_t, void *), void (*myfree)(void *, void *),
|
||||
void *mydata)
|
||||
--
|
||||
2.9.4
|
||||
|
104
pcre2.spec
104
pcre2.spec
@ -1,16 +1,18 @@
|
||||
# This is stable release:
|
||||
#%%global rcversion RC1
|
||||
%global rcversion RC1
|
||||
Name: pcre2
|
||||
Version: 10.23
|
||||
Release: %{?rcversion:0.}8%{?rcversion:.%rcversion}%{?dist}
|
||||
Version: 10.30
|
||||
Release: %{?rcversion:0.}1%{?rcversion:.%rcversion}%{?dist}
|
||||
%global myversion %{version}%{?rcversion:-%rcversion}
|
||||
Summary: Perl-compatible regular expression library
|
||||
Group: System Environment/Libraries
|
||||
# the library: BSD
|
||||
# the library: BSD with exceptions
|
||||
# pcre2test (linked to GNU readline): BSD (linked to GPLv3+)
|
||||
# COPYING: see LICENCE file
|
||||
# LICENSE: BSD text and declares Public Domain
|
||||
# LICENSE: BSD text with exceptions and
|
||||
# Public Domain declaration
|
||||
# for testdata
|
||||
#Bundled
|
||||
# src/sljit: BSD
|
||||
#Not distributed in binary package
|
||||
# aclocal.m4: FSFULLR and GPLv2+ with exception
|
||||
# ar-lib: GPLv2+ with exception
|
||||
@ -36,57 +38,15 @@ URL: http://www.pcre.org/
|
||||
Source: ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/%{?rcversion:Testing/}%{name}-%{myversion}.tar.bz2
|
||||
# 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
|
||||
# Fix DFA matching a lookbehind assertion that has a zero-length branch,
|
||||
# PCRE2 oss-fuzz issue 1859, in upstream after 10.23
|
||||
Patch15: pcre2-10.23-Fix-lookbehind-with-zero-length-branch-in-DFA-matchi.patch
|
||||
# Fix returned offsets from regexec() when REG_STARTEND is used with starting offset
|
||||
# greater than zero, upstream bug #2128, in upstream after 10.23
|
||||
Patch16: pcre2-10.23-Fix-matching-offsets-from-regexec-in-the-POSIX-wrapp.patch
|
||||
# Add forgotten sources for SELinux JIT allocator, in upstream after 10.23-RC1,
|
||||
# <https://lists.exim.org/lurker/message/20170720.103409.cb67b89d.en.html>
|
||||
Patch1: pcre2-10.30-RC1-Distribute-forgotten-sljitProtExecAllocator.c.patch
|
||||
# Preserve pcre2-10.23 ABI, in upstream after 10.23-RC1
|
||||
# <https://lists.exim.org/lurker/message/20170720.111013.7f8f78d3.en.html>
|
||||
Patch2: pcre2-10.30-RC1-Put-back-pcre2_set_recursion_limit-as-a-real-functio.patch
|
||||
# Correct formatting a size_t variable, in upstream after 10.23-RC1,
|
||||
# <https://lists.exim.org/lurker/message/20170720.112359.fa1910da.en.html>
|
||||
Patch3: pcre2-10.30-RC1-Fix-formatting-converted_length.patch
|
||||
BuildRequires: autoconf
|
||||
BuildRequires: automake
|
||||
BuildRequires: coreutils
|
||||
@ -94,6 +54,7 @@ BuildRequires: gcc
|
||||
BuildRequires: libtool
|
||||
BuildRequires: make
|
||||
BuildRequires: readline-devel
|
||||
Provides: bundled(sljit)
|
||||
|
||||
%description
|
||||
PCRE2 is a re-working of the original PCRE (Perl-compatible regular
|
||||
@ -115,7 +76,7 @@ restricted, and does not give full access to all of PCRE2's facilities.
|
||||
|
||||
%package utf16
|
||||
Summary: UTF-16 variant of PCRE2
|
||||
Group: Development/Libraries
|
||||
Provides: bundled(sljit)
|
||||
Conflicts: %{name}%{?_isa} < 10.21-4
|
||||
|
||||
%description utf16
|
||||
@ -123,7 +84,7 @@ This is PCRE2 library working on UTF-16 strings.
|
||||
|
||||
%package utf32
|
||||
Summary: UTF-32 variant of PCRE2
|
||||
Group: Development/Libraries
|
||||
Provides: bundled(sljit)
|
||||
Conflicts: %{name}%{?_isa} < 10.21-4
|
||||
|
||||
%description utf32
|
||||
@ -131,7 +92,6 @@ This is PCRE2 library working on UTF-32 strings.
|
||||
|
||||
%package devel
|
||||
Summary: Development files for %{name}
|
||||
Group: Development/Libraries
|
||||
Requires: %{name}%{?_isa} = %{version}-%{release}
|
||||
Requires: %{name}-utf16%{?_isa} = %{version}-%{release}
|
||||
Requires: %{name}-utf32%{?_isa} = %{version}-%{release}
|
||||
@ -144,8 +104,8 @@ pcre2posix.h.
|
||||
|
||||
%package static
|
||||
Summary: Static library for %{name}
|
||||
Group: Development/Libraries
|
||||
Requires: %{name}-devel%{_isa} = %{version}-%{release}
|
||||
Provides: bundled(sljit)
|
||||
|
||||
%description static
|
||||
Library for static linking for %{name}.
|
||||
@ -154,7 +114,6 @@ Library for static linking for %{name}.
|
||||
Summary: Auxiliary utilities for %{name}
|
||||
# pcre2test (linked to GNU readline): BSD (linked to GPLv3+)
|
||||
License: BSD and GPLv3+
|
||||
Group: Development/Tools
|
||||
Requires: %{name}%{_isa} = %{version}-%{release}
|
||||
|
||||
%description tools
|
||||
@ -166,19 +125,6 @@ Utilities demonstrating PCRE2 capabilities like pcre2grep or pcre2test.
|
||||
%patch1 -p1
|
||||
%patch2 -p1
|
||||
%patch3 -p1
|
||||
%patch4 -p1
|
||||
%patch5 -p1
|
||||
%patch6 -p1
|
||||
%patch7 -p1
|
||||
%patch8 -p1
|
||||
%patch9 -p1
|
||||
%patch10 -p1
|
||||
%patch11 -p1
|
||||
%patch12 -p1
|
||||
%patch13 -p1
|
||||
%patch14 -p1
|
||||
%patch15 -p1
|
||||
%patch16 -p1
|
||||
# Because of multilib patch
|
||||
libtoolize --copy --force
|
||||
autoreconf -vif
|
||||
@ -200,6 +146,7 @@ autoreconf -vif
|
||||
--disable-coverage \
|
||||
--disable-ebcdic \
|
||||
--disable-fuzz-support \
|
||||
--enable-jit-sealloc \
|
||||
--disable-never-backslash-C \
|
||||
--enable-newline-is-lf \
|
||||
--enable-pcre2-8 \
|
||||
@ -213,7 +160,7 @@ autoreconf -vif
|
||||
--enable-pcre2test-libreadline \
|
||||
--disable-rebuild-chartables \
|
||||
--enable-shared \
|
||||
--enable-stack-for-recursion \
|
||||
--disable-silent-rules \
|
||||
--enable-static \
|
||||
--enable-unicode \
|
||||
--disable-valgrind
|
||||
@ -277,6 +224,11 @@ make %{?_smp_mflags} check VERBOSE=yes
|
||||
%{_mandir}/man1/pcre2test.*
|
||||
|
||||
%changelog
|
||||
* Thu Jul 20 2017 Petr Pisar <ppisar@redhat.com> - 10.30-0.1.RC1
|
||||
- 10.30-RC1 bump
|
||||
- Heap-based matching implementation replaced stack-based one
|
||||
- SELinux-friendly JIT enabled
|
||||
|
||||
* Fri Jun 16 2017 Petr Pisar <ppisar@redhat.com> - 10.23-8
|
||||
- Fix DFA matching a lookbehind assertion that has a zero-length branch
|
||||
(PCRE2 oss-fuzz issue 1859)
|
||||
|
2
sources
2
sources
@ -1 +1 @@
|
||||
SHA512 (pcre2-10.23.tar.bz2) = 3e5910bd2405cc35934d91e4be760abe4f2e900202a20b6ba74adb7a3acb2b74b3bf9b0e97e8de10f8e8534133e0722e0bf0f5fb40d6c2c4520d1ed61749d456
|
||||
SHA512 (pcre2-10.30-RC1.tar.bz2) = f72722e12822cb9f2831980cbc786536b1394350cac542cf280e8c14cf9a10386bb0ee2cd73ceba7d9c521ff8f1e0e79a8d89aaf93638ceb0cd7f9eabbfa2d07
|
||||
|
Loading…
Reference in New Issue
Block a user