com php-src: Prevented modification of interned string: ext/standard/string.c
| From: | Dmitry Stogov | Date: | Wed, 16 Apr 2014 16:59:02 +0000 |
| Subject: | com php-src: Prevented modification of interned string: ext/standard/string.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-77366@lists.php.net to get a copy of this message | ||
Commit: a9aa5224e7a02a1a15097e5d310a1bc79f1fa560
Author: Dmitry Stogov <dmitry@zend.com> Wed, 16 Apr 2014 20:59:02 +0400
Parents: e59c8661fdb894429f25bc6af0ee919ce0f7d0f1
Branches: phpng
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=a9aa5224e7a02a1a15097e5d310a1bc79f1fa560
Log:
Prevented modification of interned string
Changed paths:
M ext/standard/string.c
Diff:
diff --git a/ext/standard/string.c b/ext/standard/string.c
index 290fa21..764f821 100644
--- a/ext/standard/string.c
+++ b/ext/standard/string.c
@@ -4283,12 +4283,23 @@ PHP_FUNCTION(strip_tags)
/* To maintain a certain BC, we allow anything for the second parameter and return original string
*/
if (allow != NULL) {
convert_to_string_ex(allow);
- allowed_tags = Z_STRVAL_P(allow);
- allowed_tags_len = Z_STRLEN_P(allow);
+// TODO: reimplement to avoid reallocation ???
+ if (IS_INTERNED(Z_STR_P(allow))) {
+ allowed_tags = estrndup(Z_STRVAL_P(allow), Z_STRLEN_P(allow));
+ allowed_tags_len = Z_STRLEN_P(allow);
+ } else {
+ allowed_tags = Z_STRVAL_P(allow);
+ allowed_tags_len = Z_STRLEN_P(allow);
+ }
}
buf = STR_INIT(str, str_len, 0);
buf->len = php_strip_tags_ex(buf->val, str_len, NULL, allowed_tags, allowed_tags_len, 0);
+
+// TODO: reimplement to avoid reallocation ???
+ if (allow && IS_INTERNED(Z_STR_P(allow))) {
+ efree(allowed_tags);
+ }
RETURN_STR(buf);
}
/* }}} */