com php-src: Fix bug #71750: use zend_string_safe_alloc for calculated allocations: NEWS ext/standard/url .c
| From: | Stanislav Malyshev | Date: | Mon, 21 Mar 2016 05:39:17 +0000 |
| Subject: | com php-src: Fix bug #71750: use zend_string_safe_alloc for calculated allocations: NEWS ext/standard/url .c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-91434@lists.php.net to get a copy of this message | ||
Commit: c4517b2a5e3141393c1c4f6fca51e1c325e91251
Author: Stanislav Malyshev <stas@php.net> Sun, 20 Mar 2016 22:39:17 -0700
Parents: 28a6ed9f9a36b9c517e4a8a429baf4dd382fc5d5
Branches: PHP-7.0 master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=c4517b2a5e3141393c1c4f6fca51e1c325e91251
Log:
Fix bug #71750: use zend_string_safe_alloc for calculated allocations
Bugs:
https://bugs.php.net/71750
Changed paths:
M NEWS
M ext/standard/url.c
Diff:
diff --git a/NEWS b/NEWS
index fc6a40b..e8684bb 100644
--- a/NEWS
+++ b/NEWS
@@ -8,6 +8,8 @@ PHP NEWS
. Fixed Bug #71859 (zend_objects_store_call_destructors operates on realloced
memory, crashing). (Laruence)
. Fixed bug #71841 (EG(error_zval) is not handled well). (Laruence)
+ . Fixed bug #71750 (Multiple Heap Overflows in php_raw_url_encode/
+ php_url_encode). (Stas)
. Fixed bug #71731 (Null coalescing operator and ArrayAccess). (Nikita)
. Fixed bug #69659 (ArrayAccess, isset() and the offsetExists method).
(Nikita)
diff --git a/ext/standard/url.c b/ext/standard/url.c
index 0138e42..9963ce6 100644
--- a/ext/standard/url.c
+++ b/ext/standard/url.c
@@ -493,7 +493,7 @@ PHPAPI zend_string *php_url_encode(char const *s, size_t len)
from = (unsigned char *)s;
end = (unsigned char *)s + len;
- start = zend_string_alloc(3 * len, 0);
+ start = zend_string_safe_alloc(3, len, 0, 0);
to = (unsigned char*)ZSTR_VAL(start);
while (from < end) {
@@ -611,7 +611,7 @@ PHPAPI zend_string *php_raw_url_encode(char const *s, size_t len)
register int x, y;
zend_string *str;
- str = zend_string_alloc(3 * len, 0);
+ str = zend_string_safe_alloc(3, len, 0, 0);
for (x = 0, y = 0; len--; x++, y++) {
ZSTR_VAL(str)[y] = (unsigned char) s[x];
#ifndef CHARSET_EBCDIC