com php-src: Fixed bug #70667 (strtr() causes invalid writes and a crashes): NEWS ext/standard/string.c ext/standard/tests/strings/bug70667.phpt

From: Date: Thu, 08 Oct 2015 11:30:43 +0000
Subject: com php-src: Fixed bug #70667 (strtr() causes invalid writes and a crashes): NEWS ext/standard/string.c ext/standard/tests/strings/bug70667.phpt
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-89343@lists.php.net to get a copy of this message
Commit: 9af07e7119a150acd5911c97da5d91fe9e424570 Author: Dmitry Stogov <dmitry@zend.com> Thu, 8 Oct 2015 14:30:43 +0300 Parents: cc3c425af8c6a56a1b295ab335d0758f48dad284 Branches: PHP-7.0 master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=9af07e7119a150acd5911c97da5d91fe9e424570 Log: Fixed bug #70667 (strtr() causes invalid writes and a crashes) Bugs: https://bugs.php.net/70667 Changed paths: M NEWS M ext/standard/string.c A ext/standard/tests/strings/bug70667.phpt Diff: diff --git a/NEWS b/NEWS index fcc1552..6e0b58f 100644 --- a/NEWS +++ b/NEWS @@ -16,6 +16,9 @@ PHP NEWS - Reflection: . Fixed bug #70650 (Wrong docblock assignment). (Marcio) +- Standard: + . Fixed bug #70667 (strtr() causes invalid writes and a crashes). (Dmitry) + 01 Oct 2015, PHP 7.0.0 RC 4 - Core: diff --git a/ext/standard/string.c b/ext/standard/string.c index 2200762..3d5b76c 100644 --- a/ext/standard/string.c +++ b/ext/standard/string.c @@ -3004,7 +3004,7 @@ static void php_strtr_array(zval *return_value, zend_string *input, HashTable *p zend_ulong *num_bitset; /* we will collect all possible key lengths */ - num_bitset = ecalloc((slen + (sizeof(zend_ulong)-1)) / sizeof(zend_ulong), sizeof(zend_ulong)); + num_bitset = ecalloc((slen + sizeof(zend_ulong)) / sizeof(zend_ulong), sizeof(zend_ulong)); memset(bitset, 0, sizeof(bitset)); /* check if original array has numeric keys */ diff --git a/ext/standard/tests/strings/bug70667.phpt b/ext/standard/tests/strings/bug70667.phpt new file mode 100644 index 0000000..fd3dead --- /dev/null +++ b/ext/standard/tests/strings/bug70667.phpt @@ -0,0 +1,9 @@ +--TEST-- +Bug #70667 (strtr() causes invalid writes and a crashes) +--FILE-- +<?php +$a = array("{{language_id}}"=>"255", "{{partner_name}}"=>"test1"); +var_dump(strtr("Sign in to test1", $a)); +?> +--EXPECT-- +string(16) "Sign in to test1"

« previous php.cvs (#89343) next »