cvs: php-src(PHP_4_3) /ext/standard var.c /ext/standard/tests/array bug26458.phpt
| From: | Ilia Alshanetsky | Date: | Sat, 29 Nov 2003 04:43:12 +0000 |
| Subject: | cvs: php-src(PHP_4_3) /ext/standard var.c /ext/standard/tests/array bug26458.phpt | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-24720@lists.php.net to get a copy of this message | ||
iliaa Fri Nov 28 23:43:12 2003 EDT
Added files: (Branch: PHP_4_3)
/php-src/ext/standard/tests/array bug26458.phpt
Modified files:
/php-src/ext/standard var.c
Log:
MFH: Fixed bug #26458 (var_dump(), var_export(), debug_zval_dump() not
binary safe for array keys).
Index: php-src/ext/standard/var.c
diff -u php-src/ext/standard/var.c:1.150.2.12 php-src/ext/standard/var.c:1.150.2.13
--- php-src/ext/standard/var.c:1.150.2.12 Tue Oct 7 21:52:07 2003
+++ php-src/ext/standard/var.c Fri Nov 28 23:43:11 2003
@@ -51,7 +51,9 @@
if (hash_key->nKeyLength==0) { /* numeric key */
php_printf("%*c[%ld]=>\n", level + 1, ' ', hash_key->h);
} else { /* string key */
- php_printf("%*c[\"%s\"]=>\n", level + 1, ' ',
hash_key->arKey);
+ php_printf("%*c[\"", level + 1, ' ');
+ PHPWRITE(hash_key->arKey, hash_key->nKeyLength - 1);
+ php_printf("\"]=>\n");
}
php_var_dump(zv, level + 2 TSRMLS_CC);
return 0;
@@ -159,7 +161,9 @@
if (hash_key->nKeyLength==0) { /* numeric key */
php_printf("%*c[%ld]=>\n", level + 1, ' ', hash_key->h);
} else { /* string key */
- php_printf("%*c[\"%s\"]=>\n", level + 1, ' ',
hash_key->arKey);
+ php_printf("%*c[\"", level + 1, ' ');
+ PHPWRITE(hash_key->arKey, hash_key->nKeyLength - 1);
+ php_printf("\"]=>\n");
}
php_debug_zval_dump(zv, level + 2 TSRMLS_CC);
return 0;
@@ -259,7 +263,9 @@
char *key;
int key_len;
key = php_addcslashes(hash_key->arKey, hash_key->nKeyLength - 1, &key_len, 0,
"'\\", 2 TSRMLS_CC);
- php_printf("%*c'%s' => ", level + 1, ' ', key);
+ php_printf("%*c'", level + 1, ' ');
+ PHPWRITE(key, key_len);
+ php_printf("' => ");
efree(key);
}
php_var_export(zv, level + 2 TSRMLS_CC);
Index: php-src/ext/standard/tests/array/bug26458.phpt
+++ php-src/ext/standard/tests/array/bug26458.phpt
--TEST--
Bug #26458 (var_dump(), var_export() & debug_zval_dump() are not binary safe for array keys)
--FILE--
<?php
$test = array("A\x00B" => "Hello world");
var_dump($test);
var_export($test);
debug_zval_dump($test);
?>
--EXPECT--
array(1) {
["AB"]=>
string(11) "Hello world"
}
array (
'AB' => 'Hello world',
)array(1) refcount(2){
["AB"]=>
string(11) "Hello world" refcount(1)
}