com php-src: Fix bug #69248 - heap overflow vulnerability in regcomp.c: ext/ereg/regex/regcomp.c
| From: | JulienPauli | Date: | Wed, 18 Mar 2015 09:39:08 +0000 |
| Subject: | com php-src: Fix bug #69248 - heap overflow vulnerability in regcomp.c: ext/ereg/regex/regcomp.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-85609@lists.php.net to get a copy of this message | ||
Commit: 94e7638d9a04ebb82433147ef65e70a85d988074
Author: Stanislav Malyshev <stas@php.net> Tue, 17 Mar 2015 17:04:57 -0700
Committer: Julien Pauli <jpauli@php.net> Wed, 18 Mar 2015 10:39:08 +0100
Parents: 2256ee4fa7b79bf4626cbe4e10d49fdab695e3ac
Branches: PHP-5.5.23
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=94e7638d9a04ebb82433147ef65e70a85d988074
Log:
Fix bug #69248 - heap overflow vulnerability in regcomp.c
Merged from https://github.com/garyhouston/regex/commit/70bc2965604b6b8aaf260049e64c708dddf85334
Bugs:
https://bugs.php.net/69248
Changed paths:
M ext/ereg/regex/regcomp.c
Diff:
diff --git a/ext/ereg/regex/regcomp.c b/ext/ereg/regex/regcomp.c
index 156eee9..f4bfc1c 100644
--- a/ext/ereg/regex/regcomp.c
+++ b/ext/ereg/regex/regcomp.c
@@ -117,7 +117,15 @@ int cflags;
(NC-1)*sizeof(cat_t));
if (g == NULL)
return(REG_ESPACE);
- p->ssize = len/(size_t)2*(size_t)3 + (size_t)1; /* ugh */
+ {
+ /* Patched for CERT Vulnerability Note VU#695940, Feb 2015. */
+ size_t new_ssize = len/(size_t)2*(size_t)3 + (size_t)1; /* ugh */
+ if (new_ssize < len || new_ssize > LONG_MAX / sizeof(sop)) {
+ free((char *) g);
+ return REG_INVARG;
+ }
+ p->ssize = new_ssize;
+ }
p->strip = (sop *)malloc(p->ssize * sizeof(sop));
p->slen = 0;
if (p->strip == NULL) {