#44720 [Bgs->Csd]: Encoding $_SESSION crashes with recusive arrays
ID: 44720
Updated by: scottmac@php.net
Reported By: antphill at uk dot ibm dot com
-Status: Bogus
+Status: Closed
Bug Type: Session related
Operating System: Linux
PHP Version: 5.2.6RC5
New Comment:
This bug has been fixed in CVS.
Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
Thank you for the report, and for helping us make PHP better.
Even though session_register has been removed in 6.0, I don't agree
with leaving a segfault. I've fixed this in 5.3 and I'll backport to 5.2
once I check with ilia.
Previous Comments:
------------------------------------------------------------------------
[2008-04-14 17:47:45] jani@php.net
session_register() is deprecated. DO NOT USE. Ever. RTFM about
$_SESSION.
------------------------------------------------------------------------
[2008-04-14 16:04:14] antphill at uk dot ibm dot com
Description:
------------
If I add create a global variable array which contains recursive
entries it causes PHP to crash when I register it by calling
session_register. This appears to be because the PS_ENCODE_LOOP macro
does not check for recursion.
Reproduce code:
---------------
<?php
$array = array();
$array["foo"] = NULL;
$array["bar"] = NULL;
$array["guff"] = NULL;
$array["blah"] = &$array;
var_dump(session_start());
var_dump(session_register($array));
echo "Done!\n";
?>
Expected result:
----------------
Perhaps we should check for recusion rather like the JSON extension
does (see json_encode_array() in JSON.c)?
Actual result:
--------------
bool(true)
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=44720&edit=1
Thread (3 messages)