Bug #75713 [NEW]: Serialization bug: wrong variable name length
| From: | axtux at hotmail dot com | Date: | Wed, 20 Dec 2017 16:27:43 +0000 |
| Subject: | Bug #75713 [NEW]: Serialization bug: wrong variable name length | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-213182@lists.php.net to get a copy of this message | ||
From: axtux at hotmail dot com
Operating system: Linux/Ubuntu
PHP version: 7.0Git-2017-12-20 (Git)
Package: *Data Exchange functions
Bug Type: Bug
Bug description:Serialization bug: wrong variable name length
Description:
------------
Versions tested and affected :
PHP 7.0.28-dev (cli) (built: Dec 20 2017 16:38:38) ( NTS )
PHP 7.0.22-0ubuntu0.16.04.1 (cli) ( NTS )
PHP serialization is buggy when using private class variables. Steps to
reproduce :
1. create Test class with at least one private variable
2. create an instance of this class and serialize it
This leads to notice/warning/error when unserializing serialized string.
See test snippet of code https://pastebin.com/D9yM4G58
Test script:
---------------
error_reporting(E_ALL);
class Test
{
public $v1;
private $v2;
}
$t = new Test();
$s = serialize($t);
echo $s;
// copy value or notice is not shown
$s = 'O:4:"Test":2:{s:2:"v1";N;s:8:"Testv2";N;}';
$u = unserialize($s);
Expected result:
----------------
good variable name length
Actual result:
--------------
variable name length is 2 more than expected
--
Edit bug report at https://bugs.php.net/bug.php?id=75713&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=75713&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=75713&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=75713&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=75713&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=75713&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=75713&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=75713&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=75713&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=75713&r=support
Expected behavior: https://bugs.php.net/fix.php?id=75713&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=75713&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=75713&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=75713&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=75713&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=75713&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=75713&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=75713&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=75713&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=75713&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=75713&r=mysqlcfg