# Unserialize bug in PHP 4.3.2RC4?

- Thread: https://externals.io/message/1891
- Original archive: https://news-web.php.net/php.internals/1891
- Started by Iacopo Spalletti on 2003-05-22T14:30:49+00:00
- Messages: 2
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #1891 — Iacopo Spalletti — 2003-05-22T14:30:49+00:00

URL: https://externals.io/message/1891#1891

I'm testing PHP 4.3.2RC4 and i think i found a bug in unserialize function
If you run this script:
<?php
error_reporting (E_ALL);
$a      = array(4);
$str    = serialize($a);
print('Serialized array: '.$str."\n");
$b      = unserialize($str);
print('Unserialized array: ');
var_dump($b);
print("\n");
$str    = serialize(array(4.5));
print('Serialized array: '.$str."\n");
$b      = unserialize($str);
print('Unserialized array: ')   ;
var_dump($b);
print("\n");
?>
You should expect the second variable to contain an array with a single 
floating value.
On my systems (Linux SuSE x86) i got this notice:
Notice: `unserialize()`: Error at offset 15 of 16 bytes in script-name.php on 
line 12
Result for `unserialize()` is "false"
Needless to say that on PHP 4.3.0 all run fine
Serializing/deserializing float var it's ok



Iacopo Spalletti
i dot spalletti at iast dot it

PGP key block: http://www.iast.it/pgp

---

## #1892 — Stanislav Malyshev — 2003-05-22T14:38:53+00:00

URL: https://externals.io/message/1891#1892 · In reply to: #1891

Strange thing - I saw this effect myself, but as soon as I have rebuilt 
var_unserializer.c from var_unserializer.re, it works OK again... Maybe 
just unclean CVS build or something?

IS>> I'm testing PHP 4.3.2RC4 and i think i found a bug in unserialize function
IS>> If you run this script:
IS>> <?php
IS>> error_reporting (E_ALL);
IS>> $a      = array(4);
IS>> $str    = serialize($a);
IS>> print('Serialized array: '.$str."\n");
IS>> $b      = unserialize($str);
IS>> print('Unserialized array: ');
IS>> var_dump($b);
IS>> print("\n");
IS>> $str    = serialize(array(4.5));
IS>> print('Serialized array: '.$str."\n");
IS>> $b      = unserialize($str);
IS>> print('Unserialized array: ')   ;
IS>> var_dump($b);
IS>> print("\n");
IS>> ?>
IS>> You should expect the second variable to contain an array with a single 
IS>> floating value.
IS>> On my systems (Linux SuSE x86) i got this notice:
IS>> Notice: `unserialize()`: Error at offset 15 of 16 bytes in script-name.php on 
IS>> line 12
IS>> Result for `unserialize()` is "false"
IS>> Needless to say that on PHP 4.3.0 all run fine
IS>> Serializing/deserializing float var it's ok
IS>> 
IS>> 
IS>> 
IS>> Iacopo Spalletti
IS>> i dot spalletti at iast dot it
IS>> 
IS>> PGP key block: http://www.iast.it/pgp  
IS>> 
IS>> 
IS>> 

-- 
Stanislav Malyshev, Zend Products Engineer   
stas@zend.com  http://www.zend.com/ +972-3-6139665 ext.109
