php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Return to Bug #65591
Patch bug65591.phpt revision 2013-08-30 09:53 UTC by arjen at react dot com

Patch bug65591.phpt for Reproducible crash Bug #65591

Patch version 2013-08-30 09:53 UTC

Return to Bug #65591 | Download this patch
Patch Revisions:

Developer: arjen@react.com

--TEST--
Segfault when calling parent::serialize in serialize().
--FILE--
<?php
class Permission implements \Serializable {
    protected $id = 3;
    public function serialize()
    {
        return serialize(array($this->id));
    }
    public function unserialize($serialized)
    {
        list($this->id) = unserialize($serialized);
    }
 
}
 
class UserPermission implements \Serializable {
    public $permission;
    public $webshop;
 
    public function serialize()
    {
        return serialize(array($this->webshop, $this->permission));
    }
    public function unserialize($serialized)
    {
        list($this->webshop, $this->permission) = unserialize($serialized);
    }
}
 
class Webshop  implements \Serializable {
    protected $id = 13;
    public function serialize()
    {
        return serialize(array($this->id));
    }
    public function unserialize($serialized)
    {
        list($this->id) = unserialize($serialized);
    }
 
}
 
class AbstractToken  implements \Serializable {
    public $roles;
 
    public function serialize()
    {
        return serialize(array($this->roles));
    }
    public function unserialize($serialized)
    {
        list($this->roles) = unserialize($serialized);
    }
 
}
class UsernamePasswordToken extends AbstractToken {
    private $credentials = null;
    private $providerKey = null;
 
    public function serialize()
    {
        return serialize(array($this->credentials, $this->providerKey, parent::serialize()));
    }
 
    public function unserialize($str)
    {
        list($this->credentials, $this->providerKey, $parentStr) = unserialize($str);
        parent::unserialize($parentStr);
    }
}
 
$token = new UsernamePasswordToken();
$webshop = new Webshop;
$permission = new Permission;
$roles = array();
for ($i = 0; $i < 2; $i++) {
    $roles[$i] = new UserPermission();
    $roles[$i]->webshop = $webshop;
    $roles[$i]->permission = $permission;
}
$token->roles = $roles;
unserialize(serialize($token));
echo 'done';
--EXPECT--
done
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Nov 22 01:01:30 2024 UTC