com php-src: Fix #75457: heap-use-after-free in php7.0.25: ext/pcre/pcrelib/pcre_compile.c ext/pcre/tests/bug75 457.phpt

From: Date: Mon, 26 Aug 2019 02:19:50 +0000
Subject: com php-src: Fix #75457: heap-use-after-free in php7.0.25: ext/pcre/pcrelib/pcre_compile.c ext/pcre/tests/bug75 457.phpt
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-108043@lists.php.net to get a copy of this message
Commit: 7bf1f9d561826c4a3ed748e55bb756375cdf28b9 Author: Christoph M. Becker <cmbecker69@gmx.de> Fri, 16 Aug 2019 14:29:19 +0200 Committer: Stanislav Malyshev <stas@php.net> Sun, 25 Aug 2019 19:19:50 -0700 Parents: 1258303e66d8dede4f02347334b9f6576e98a21b Branches: PHP-7.1 PHP-7.2 PHP-7.3 PHP-7.4 master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=7bf1f9d561826c4a3ed748e55bb756375cdf28b9 Log: Fix #75457: heap-use-after-free in php7.0.25 Backport <https://vcs.pcre.org/pcre?view=revision&revision=1638>. Bugs: https://bugs.php.net/75457 Changed paths: M ext/pcre/pcrelib/pcre_compile.c A ext/pcre/tests/bug75457.phpt Diff: diff --git a/ext/pcre/pcrelib/pcre_compile.c b/ext/pcre/pcrelib/pcre_compile.c index c782774..402c428 100644 --- a/ext/pcre/pcrelib/pcre_compile.c +++ b/ext/pcre/pcrelib/pcre_compile.c @@ -483,7 +483,7 @@ static const char error_texts[] = "lookbehind assertion is not fixed length\0" "malformed number or name after (?(\0" "conditional group contains more than two branches\0" - "assertion expected after (?(\0" + "assertion expected after (?( or (?(?C)\0" "(?R or (?[+-]digits must be followed by )\0" /* 30 */ "unknown POSIX class name\0" @@ -6732,6 +6732,15 @@ for (;; ptr++) for (i = 3;; i++) if (!IS_DIGIT(ptr[i])) break; if (ptr[i] == CHAR_RIGHT_PARENTHESIS) tempptr += i + 1; + + /* tempptr should now be pointing to the opening parenthesis of the + assertion condition. */ + + if (*tempptr != CHAR_LEFT_PARENTHESIS) + { + *errorcodeptr = ERR28; + goto FAILED; + } } /* For conditions that are assertions, check the syntax, and then exit diff --git a/ext/pcre/tests/bug75457.phpt b/ext/pcre/tests/bug75457.phpt new file mode 100644 index 0000000..c7ce9ed --- /dev/null +++ b/ext/pcre/tests/bug75457.phpt @@ -0,0 +1,10 @@ +--TEST-- +Bug #75457 (heap-use-after-free in php7.0.25) +--FILE-- +<?php +$pattern = "/(((?(?C)0?=))(?!()0|.(?0)0)())/"; +var_dump(preg_match($pattern, "hello")); +?> +--EXPECTF-- +Warning: preg_match(): Compilation failed: assertion expected after (?( or (?(?C) at offset 4 in %sbug75457.php on line %d +bool(false)

« previous php.cvs (#108043) next »