diff options
author | Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> | 2015-02-28 14:14:24 +0100 |
---|---|---|
committer | Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> | 2015-03-06 13:43:12 +0000 |
commit | 14fdd946f6260b239ee4215910f87fc2908b8fee (patch) | |
tree | 30071c1d863c46c14159e6609bb4e79e40ec9efd /src/3rdparty/pcre/pcre_study.c | |
parent | a9a41961c6ef3627a8dd2bf69664c13d9cb20568 (diff) |
Upgrade PCRE to r1530
Include a couple of hard-to-backport fixes for stack/heap overflows
and regressions from previous PCRE versions (cf. the changelog [1])
[1] http://vcs.pcre.org/viewvc/code/trunk/ChangeLog?view=markup
Change-Id: I618c3633e9265ef1b9fd56b58e2c6c714335aae8
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Diffstat (limited to 'src/3rdparty/pcre/pcre_study.c')
-rw-r--r-- | src/3rdparty/pcre/pcre_study.c | 47 |
1 files changed, 32 insertions, 15 deletions
diff --git a/src/3rdparty/pcre/pcre_study.c b/src/3rdparty/pcre/pcre_study.c index feb74115c6..0239fb41a4 100644 --- a/src/3rdparty/pcre/pcre_study.c +++ b/src/3rdparty/pcre/pcre_study.c @@ -393,7 +393,7 @@ for (;;) ce = cs = (pcre_uchar *)PRIV(find_bracket)(startcode, utf, GET2(slot, 0)); if (cs == NULL) return -2; do ce += GET(ce, 1); while (*ce == OP_ALT); - if (cc > cs && cc < ce) + if ((cc > cs && cc < ce) || recurse_depth > 10) { d = 0; had_recurse = TRUE; @@ -401,7 +401,7 @@ for (;;) } else { - int dd = find_minlength(re, cs, startcode, options, recurse_depth); + int dd = find_minlength(re, cs, startcode, options, recurse_depth+1); if (dd < d) d = dd; } slot += re->name_entry_size; @@ -418,14 +418,14 @@ for (;;) ce = cs = (pcre_uchar *)PRIV(find_bracket)(startcode, utf, GET2(cc, 1)); if (cs == NULL) return -2; do ce += GET(ce, 1); while (*ce == OP_ALT); - if (cc > cs && cc < ce) + if ((cc > cs && cc < ce) || recurse_depth > 10) { d = 0; had_recurse = TRUE; } else { - d = find_minlength(re, cs, startcode, options, recurse_depth); + d = find_minlength(re, cs, startcode, options, recurse_depth + 1); } } else d = 0; @@ -863,7 +863,6 @@ do case OP_NOTUPTOI: case OP_NOT_HSPACE: case OP_NOT_VSPACE: - case OP_PROP: case OP_PRUNE: case OP_PRUNE_ARG: case OP_RECURSE: @@ -881,6 +880,31 @@ do case OP_THEN_ARG: return SSB_FAIL; + /* A "real" property test implies no starting bits, but the fake property + PT_CLIST identifies a list of characters. These lists are short, as they + are used for characters with more than one "other case", so there is no + point in recognizing them for OP_NOTPROP. */ + + case OP_PROP: + if (tcode[1] != PT_CLIST) return SSB_FAIL; + { + const pcre_uint32 *p = PRIV(ucd_caseless_sets) + tcode[2]; + while ((c = *p++) < NOTACHAR) + { +#if defined SUPPORT_UTF && defined COMPILE_PCRE8 + if (utf) + { + pcre_uchar buff[6]; + (void)PRIV(ord2utf)(c, buff); + c = buff[0]; + } +#endif + if (c > 0xff) SET_BIT(0xff); else SET_BIT(c); + } + } + try_next = FALSE; + break; + /* We can ignore word boundary tests. */ case OP_WORD_BOUNDARY: @@ -1106,24 +1130,17 @@ do try_next = FALSE; break; - /* The cbit_space table has vertical tab as whitespace; we have to - ensure it is set as not whitespace. Luckily, the code value is the same - (0x0b) in ASCII and EBCDIC, so we can just adjust the appropriate bit. */ + /* The cbit_space table has vertical tab as whitespace; we no longer + have to play fancy tricks because Perl added VT to its whitespace at + release 5.18. PCRE added it at release 8.34. */ case OP_NOT_WHITESPACE: set_nottype_bits(start_bits, cbit_space, table_limit, cd); - start_bits[1] |= 0x08; try_next = FALSE; break; - /* The cbit_space table has vertical tab as whitespace; we have to not - set it from the table. Luckily, the code value is the same (0x0b) in - ASCII and EBCDIC, so we can just adjust the appropriate bit. */ - case OP_WHITESPACE: - c = start_bits[1]; /* Save in case it was already set */ set_type_bits(start_bits, cbit_space, table_limit, cd); - start_bits[1] = (start_bits[1] & ~0x08) | c; try_next = FALSE; break; |