cvs: php-src(PHP_5_1) /ext/spl spl_array.c /ext/spl/tests array_018.phpt
| From: | Marcus Boerger | Date: | Mon, 03 Oct 2005 17:59:56 +0000 |
| Subject: | cvs: php-src(PHP_5_1) /ext/spl spl_array.c /ext/spl/tests array_018.phpt | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-34270@lists.php.net to get a copy of this message | ||
helly Mon Oct 3 13:59:56 2005 EDT
Added files: (Branch: PHP_5_1)
/php-src/ext/spl/tests array_018.phpt
Modified files:
/php-src/ext/spl spl_array.c
Log:
- MFH Throw an exception if an illegal string value is being used in
ArrayObject::offsetSet()
http://cvs.php.net/diff.php/php-src/ext/spl/spl_array.c?r1=1.71.2.3&r2=1.71.2.4&ty=u
Index: php-src/ext/spl/spl_array.c
diff -u php-src/ext/spl/spl_array.c:1.71.2.3 php-src/ext/spl/spl_array.c:1.71.2.4
--- php-src/ext/spl/spl_array.c:1.71.2.3 Mon Oct 3 05:14:30 2005
+++ php-src/ext/spl/spl_array.c Mon Oct 3 13:59:56 2005
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: spl_array.c,v 1.71.2.3 2005/10/03 09:14:30 helly Exp $ */
+/* $Id: spl_array.c,v 1.71.2.4 2005/10/03 17:59:56 helly Exp $ */
#ifdef HAVE_CONFIG_H
# include "config.h"
@@ -301,6 +301,10 @@
}
switch(Z_TYPE_P(offset)) {
case IS_STRING:
+ if (*Z_STRVAL_P(offset) == '\0') {
+ zend_throw_exception(spl_ce_InvalidArgumentException, "An offset must not begin with \\0 or
be empty", 0 TSRMLS_CC);
+ return;
+ }
value->refcount++;
zend_symtable_update(spl_array_get_hash_table(intern, 0 TSRMLS_CC), Z_STRVAL_P(offset),
Z_STRLEN_P(offset)+1, (void**)&value, sizeof(void*), NULL);
return;
http://cvs.php.net/co.php/php-src/ext/spl/tests/array_018.phpt?r=1.1&p=1
Index: php-src/ext/spl/tests/array_018.phpt
+++ php-src/ext/spl/tests/array_018.phpt
--TEST--
SPL: ArrayObject and \0
--SKIPIF--
<?php if (!extension_loaded("spl")) print "skip"; ?>
--FILE--
<?php
try
{
$foo = new ArrayObject();
$foo->offsetSet("\0", "Foo");
}
catch (Exception $e)
{
var_dump($e->getMessage());
}
var_dump($foo);
try
{
$foo = new ArrayObject();
$data = explode("=", "=Foo");
$foo->offsetSet($data[0], $data[1]);
}
catch (Exception $e)
{
var_dump($e->getMessage());
}
var_dump($foo);
?>
===DONE===
--EXPECTF--
string(44) "An offset must not begin with \0 or be empty"
object(ArrayObject)#%d (0) {
}
string(44) "An offset must not begin with \0 or be empty"
object(ArrayObject)#%d (0) {
}
===DONE===
--UEXPECTF--
unicode(44) "An offset must not begin with \0 or be empty"
object(ArrayObject)#%d (0) {
}
unicode(44) "An offset must not begin with \0 or be empty"
object(ArrayObject)#%d (0) {
}
===DONE===