php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #27646 Cannot serialize/unserialize non-finite numeric values
Submitted: 2004-03-18 21:29 UTC Modified: 2004-03-26 20:46 UTC
From: matthew_kay at ml1 dot net Assigned:
Status: Closed Package: Scripting Engine problem
PHP Version: 4.3.5, 5.0.0RC1 OS: *
Private report: No CVE-ID: None
 [2004-03-18 21:29 UTC] matthew_kay at ml1 dot net
Description:
------------
It appears that unserialize() does not unserialize 
numerics that are "non-finite", such as NAN and INF. 
Instead, it simply fails and returns (bool)false. 
 
If a NAN value is encountered anywhere during an 
unserialize() (for example, in an array or an object), the 
entire operation fails and unserialize will return false. 

Reproduce code:
---------------
$testNan = (float)NAN;
var_dump($testNan); //outputs float(NAN)
$testNan2 = unserialize(serialize($testNan));
var_dump($testNan2); //outputs bool(false)

$testInf = (float)INF;
var_dump($testInf); //outputs float(INF)
$testInf2 = unserialize(serialize($testInf));
var_dump($testInf2); //outputs bool(false)

Expected result:
----------------
float(NAN) 
float(NAN) 
float(INF) 
float(INF) 

Actual result:
--------------
float(NAN) 
bool(false) 
float(INF) 
bool(false) 

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-03-23 16:01 UTC] helly@php.net
Please try using this CVS snapshot:

  http://snaps.php.net/php5-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php5-win32-latest.zip
 [2004-03-23 16:01 UTC] helly@php.net
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.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 15:01:29 2024 UTC