com php-src: Fix bug #72838 - Integer overflow lead to heap corruption in sql_regcase: ext/ereg/ereg. c
| From: | Ferenc Kovacs | Date: | Thu, 18 Aug 2016 10:53:18 +0000 |
| Subject: | com php-src: Fix bug #72838 - Integer overflow lead to heap corruption in sql_regcase: ext/ereg/ereg. c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-93949@lists.php.net to get a copy of this message | ||
Commit: 6ba48cff6c31094bc1a6233e023c3a2fcd91ab7a
Author: Stanislav Malyshev <stas@php.net> Mon, 15 Aug 2016 23:43:59 -0700
Committer: Ferenc Kovacs <tyra3l@gmail.com> Thu, 18 Aug 2016 12:53:18 +0200
Parents: 69236ea9793b76b778c6cd64748cfee817521118
Branches: PHP-5.6.25
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=6ba48cff6c31094bc1a6233e023c3a2fcd91ab7a
Log:
Fix bug #72838 - Integer overflow lead to heap corruption in sql_regcase
Bugs:
https://bugs.php.net/72838
Changed paths:
M ext/ereg/ereg.c
Diff:
diff --git a/ext/ereg/ereg.c b/ext/ereg/ereg.c
index 5d38d04..8eb833a 100644
--- a/ext/ereg/ereg.c
+++ b/ext/ereg/ereg.c
@@ -743,6 +743,11 @@ PHP_EREG_API PHP_FUNCTION(sql_regcase)
for (i = j = 0; i < string_len; i++) {
c = (unsigned char) string[i];
+ if ( j >= INT_MAX - 1 || (isalpha(c) && j >= INT_MAX - 4)) {
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "String too long, max length is %d",
INT_MAX);
+ efree(tmp);
+ RETURN_FALSE;
+ }
if (isalpha(c)) {
tmp[j++] = '[';
tmp[j++] = toupper(c);