com php-src: Fix bug #72838 - Integer overflow lead to heap corruption in sql_regcase: ext/ereg/ereg. c

From: Date: Wed, 17 Aug 2016 05:55:42 +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-93824@lists.php.net to get a copy of this message
Commit: 5f91f692c354e45b9b46ba672f4182ff478bd1a3 Author: Stanislav Malyshev <stas@php.net> Mon, 15 Aug 2016 23:43:59 -0700 Parents: cfdeedd98558a7f946ed79f7100812dc2a43abfe Branches: PHP-5.6 Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=5f91f692c354e45b9b46ba672f4182ff478bd1a3 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);

« previous php.cvs (#93824) next »