[PHP-BUG] Bug #62737 [NEW]: Segfault invoking SplFileInfo->openFile

2012-08-03 Thread leight at gmail dot com
From: leight at gmail dot com
Operating system: Linux / OSX
PHP version:  master-Git-2012-08-03 (Git)
Package:  Reproducible crash
Bug Type: Bug
Bug description:Segfault invoking SplFileInfo->openFile

Description:

When SplFileObject is on the disable_classes list, and
SplFileInfo->openFile is 
called, PHP crashes because there is no check on whether the SplFileObject
object 
was actually created or not, before trying to use it.

The offending code is in ext/spl/spl_directory.c in 
spl_filesystem_object_create_type

Test script:
---
openFile('r');

Expected result:

A message stating SplFileObject is disabled.

Actual result:
--
Segmentation fault

-- 
Edit bug report at https://bugs.php.net/bug.php?id=62737&edit=1
-- 
Try a snapshot (PHP 5.4):
https://bugs.php.net/fix.php?id=62737&r=trysnapshot54
Try a snapshot (PHP 5.3):
https://bugs.php.net/fix.php?id=62737&r=trysnapshot53
Try a snapshot (trunk):  
https://bugs.php.net/fix.php?id=62737&r=trysnapshottrunk
Fixed in SVN:
https://bugs.php.net/fix.php?id=62737&r=fixed
Fixed in SVN and need be documented: 
https://bugs.php.net/fix.php?id=62737&r=needdocs
Fixed in release:
https://bugs.php.net/fix.php?id=62737&r=alreadyfixed
Need backtrace:  
https://bugs.php.net/fix.php?id=62737&r=needtrace
Need Reproduce Script:   
https://bugs.php.net/fix.php?id=62737&r=needscript
Try newer version:   
https://bugs.php.net/fix.php?id=62737&r=oldversion
Not developer issue: 
https://bugs.php.net/fix.php?id=62737&r=support
Expected behavior:   
https://bugs.php.net/fix.php?id=62737&r=notwrong
Not enough info: 
https://bugs.php.net/fix.php?id=62737&r=notenoughinfo
Submitted twice: 
https://bugs.php.net/fix.php?id=62737&r=submittedtwice
register_globals:
https://bugs.php.net/fix.php?id=62737&r=globals
PHP 4 support discontinued:  
https://bugs.php.net/fix.php?id=62737&r=php4
Daylight Savings:https://bugs.php.net/fix.php?id=62737&r=dst
IIS Stability:   
https://bugs.php.net/fix.php?id=62737&r=isapi
Install GNU Sed: 
https://bugs.php.net/fix.php?id=62737&r=gnused
Floating point limitations:  
https://bugs.php.net/fix.php?id=62737&r=float
No Zend Extensions:  
https://bugs.php.net/fix.php?id=62737&r=nozend
MySQL Configuration Error:   
https://bugs.php.net/fix.php?id=62737&r=mysqlcfg



Bug #62328 [Com]: implementing __toString and a cast to string fails

2012-08-10 Thread leight at gmail dot com
Edit report at https://bugs.php.net/bug.php?id=62328&edit=1

 ID: 62328
 Comment by: leight at gmail dot com
 Reported by:jordan dot raub at dataxltd dot com
 Summary:implementing __toString and a cast to string fails
 Status: Open
 Type:   Bug
 Package:SimpleXML related
 Operating System:   Linux
 PHP Version:5.4.4
 Block user comment: N
 Private report: N

 New Comment:

This is caused by a built-in classes cast_object function being called when it 
exists, before falling back to alternative methods of converting to a string.

I have added a pull request that fixes the issue.

https://github.com/php/php-src/pull/157


Previous Comments:

[2012-06-14 19:13:55] jordan dot raub at dataxltd dot com

Oops! Accidentally switched the expected and actual results...


[2012-06-14 19:11:31] jordan dot raub at dataxltd dot com

Description:

I would expect casting to a string to have the same result as calling the 
__toString() function on extending a SimpleXMLElement object. 
I've tested this against

PHP 5.3.3-7+squeeze13 with Suhosin-Patch (cli) (built: Jun 10 2012 07:31:32) 
Copyright (c) 1997-2009 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies
with XCache v1.3.0, Copyright (c) 2005-2009, by mOo
with Xdebug v2.1.2, Copyright (c) 2002-2011, by Derick Rethans
with Suhosin v0.9.32.1, Copyright (c) 2007-2010, by SektionEins GmbH

and 

PHP 5.4.4 (cli) (built: Jun 14 2012 11:50:02) 
Copyright (c) 1997-2012 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2012 Zend Technologies

and 


PHP 5.3.14 (cli) (built: Jun 14 2012 11:49:39) 
Copyright (c) 1997-2012 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2012 Zend Technologies


Test script:
---
');
$xml->tag = "you're it!";

echo "\nno cast\n";
echo $xml;
echo "\ncast\n";
echo (string) $xml;
echo "\nexplicit call\n";
echo $xml->__toString();
echo "\n";
var_dump((string) $xml);
var_dump($xml->__toString());


Expected result:

no cast
stringification
cast

explicit call
stringification
string(0) ""
string(15) "stringification"


Actual result:
--
no cast
stringification
cast
stringification
explicit call
stringification
string(15) "stringification"
string(15) "stringification"







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