com php-src: Fix bug #71637: Multiple Heap Overflow due to integer overflows: ext/filter/sanitizing_filters.c ext/standard/s tring.c ext/xml/xml.c
| From: | Stanislav Malyshev | Date: | Wed, 02 Mar 2016 06:32:38 +0000 |
| Subject: | com php-src: Fix bug #71637: Multiple Heap Overflow due to integer overflows: ext/filter/sanitizing_filters.c ext/standard/s tring.c ext/xml/xml.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-91237@lists.php.net to get a copy of this message | ||
Commit: 9cabc99fcef0f12b472e40811beab4eb2ef17e1b
Author: Stanislav Malyshev <stas@php.net> Sun, 21 Feb 2016 23:14:29 -0800
Parents: bb80c00a0099dd12ddec0380250834b64c1f92f2
Branches: PHP-7.0 PHP-7.0.4 master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=9cabc99fcef0f12b472e40811beab4eb2ef17e1b
Log:
Fix bug #71637: Multiple Heap Overflow due to integer overflows
Bugs:
https://bugs.php.net/71637
Changed paths:
M ext/filter/sanitizing_filters.c
M ext/standard/string.c
M ext/xml/xml.c
Diff:
diff --git a/ext/filter/sanitizing_filters.c b/ext/filter/sanitizing_filters.c
index ff27bdb..0b11ecf 100644
--- a/ext/filter/sanitizing_filters.c
+++ b/ext/filter/sanitizing_filters.c
@@ -87,7 +87,7 @@ static void php_filter_encode_url(zval *value, const unsigned char* chars, const
memset(tmp, 1, 32);
}
*/
- str = zend_string_alloc(3 * Z_STRLEN_P(value), 0);
+ str = zend_string_safe_alloc(Z_STRLEN_P(value), 3, 0, 0);
p = (unsigned char *) ZSTR_VAL(str);
s = (unsigned char *) Z_STRVAL_P(value);
e = s + Z_STRLEN_P(value);
diff --git a/ext/standard/string.c b/ext/standard/string.c
index 489006b..7b6ad8e 100644
--- a/ext/standard/string.c
+++ b/ext/standard/string.c
@@ -5372,7 +5372,7 @@ PHP_FUNCTION(str_pad)
return;
}
- result = zend_string_alloc(ZSTR_LEN(input) + num_pad_chars, 0);
+ result = zend_string_safe_alloc(ZSTR_LEN(input), 1, num_pad_chars, 0);
ZSTR_LEN(result) = 0;
/* We need to figure out the left/right padding lengths.. */
diff --git a/ext/xml/xml.c b/ext/xml/xml.c
index d6eae46..bfa1b85 100644
--- a/ext/xml/xml.c
+++ b/ext/xml/xml.c
@@ -581,7 +581,7 @@ PHP_XML_API zend_string *xml_utf8_encode(const char *s, size_t len, const XML_Ch
}
/* This is the theoretical max (will never get beyond len * 2 as long
* as we are converting from single-byte characters, though) */
- str = zend_string_alloc(len * 4, 0);
+ str = zend_string_safe_alloc(len, 4, 0, 0);
ZSTR_LEN(str) = 0;
while (pos > 0) {
c = encoder ? encoder((unsigned char)(*s)) : (unsigned short)(*s);