#39488 [NEW]: unserialize does not convert array keys to proper type
| From: | michaelw at darkhorse dot com | Date: | Mon, 13 Nov 2006 07:08:02 +0000 |
| Subject: | #39488 [NEW]: unserialize does not convert array keys to proper type | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-104875@lists.php.net to get a copy of this message | ||
From: michaelw at darkhorse dot com
Operating system: os x
PHP version: 5.2.0
PHP Bug Type: *General Issues
Bug description: unserialize does not convert array keys to proper type
Description:
------------
When dealing with an incorrectly formatted serialized array (such as from
a source other than PHP like a javascript, or hand-coded), unserialize()
does not check and convert array keys that are stored as strings but
should be integers.
This makes it impossible to recover the value through any sort of
type-casting.
Reproduce code:
---------------
$badly_serialized_array = 'a:1:{s:1:"0";s:1:"a";}';
$back_to_an_array = unserialize($badly_serialized_array);
echo $back_to_an_array[0];
echo $back_to_an_array['0'];
$v = (string)'0';
echo $back_to_an_array[$v];
Expected result:
----------------
a
a
a
Actual result:
--------------
nothing
nothing
nothing
--
Edit bug report at http://bugs.php.net/?id=39488&edit=1
--
Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=39488&r=trysnapshot44
Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=39488&r=trysnapshot52
Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=39488&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=39488&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=39488&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=39488&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=39488&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=39488&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=39488&r=support
Expected behavior: http://bugs.php.net/fix.php?id=39488&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=39488&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=39488&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=39488&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=39488&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=39488&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=39488&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=39488&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=39488&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=39488&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=39488&r=mysqlcfg