Sec Bug->Bug #73390 [Opn->Fbk]: Segmentation fault on clone sample code spread across multiple current versions

[email protected] Thu, 27 Oct 2016 01:08:50 GMT
Newsgroups php.standards
Message-ID <[email protected]>
Edit report at https://bugs.php.net/bug.php?id=73390&edit=1

 ID:                 73390
 Updated by:         [email protected]
 Reported by:        kenterfie at googlemail dot com
 Summary:            Segmentation fault on clone sample code spread
                     across multiple current versions
-Status:             Open
+Status:             Feedback
-Type:               Security
+Type:               Bug
 Package:            PHP Language Specification
 Operating System:   Linux
 PHP Version:        5.x 7.x
 Block user comment: N
 Private report:     Y

 New Comment:

Where on php.net do you have this sample? It's certainly not a correct code, it leads to stack exhaustion via infinite recursion.


Previous Comments:
------------------------------------------------------------------------
[2016-10-26 10:29:56] kenterfie at googlemail dot com

Added more meaningful version information

------------------------------------------------------------------------
[2016-10-26 10:28:40] kenterfie at googlemail dot com

Description:
------------
The following code sample is a 1:1 copy of one of your samples on php.net. It produce an segmentation fault. I was writing on a very similar subject, which also produce an segmentation fault, after some testing i found the page on php.net and also this sample fail. I set the bug type to security because it is spread accross the most current php versions. I have tested 5.6.27 locally, but all other version also affected. Simple test is to use http://phptester.net/ which end in an internal server error.


Test script:
---------------
<?php

class Foo
{
    var $that;

    function __clone()
    {
        $this->that = clone $this->that;
    }

}

$a = new Foo;
$b = new Foo;
$a->that = $b;
$b->that = $a;

$c = clone $a;
echo 'What happened?';
var_dump($c);

Expected result:
----------------
The normally expected result should be a successful created copy of an object.

Actual result:
--------------
Segmentation fault


------------------------------------------------------------------------



--
Edit this bug report at https://bugs.php.net/bug.php?id=73390&edit=1