From: ttessier at swhistlesoft dot com
Operating system: solaris 10
PHP version: 5.2.10
PHP Bug Type: Filesystem function related
Bug description: when fopen is used without the second parameter, php
segfaults in apache 2.2
Description:
When fopen is used without the second parameter, php segfaults in apache
2.2. I had this happen two times, once when I was using bcompiler and once
when I was using xml_parser. I thought that the issue was the other modules
until I realized that I was missing the second parameter to fopen.
I was doing a test on the returned value to check for validity such as if
( $fh ) or if ( is_resource ( $fh ) ) and was unable to see any warnings.
Once I removed the test and any interior blocks to the filehandle test
from the code, I was able to see a warning. I fixed the issue and have been
working solid since.
Reproduce code:
---
$regionf = 'regions.xml' ;
$fregions = fopen ( $regionf ) ;
if ( $fregions ){
echo File Opened ;
$xmldoc = fread ( $fregions, filesize ( $regionf ) ) ;
$parser = xml_parser_create ( ) ;
if ( $parser ){
xml_parser_set_option($parser,XML_OPTION_TARGET_ENCODING, UTF-8);
xml_parser_set_option($parser,XML_OPTION_SKIP_WHITE,1);
xml_parse ( $parser, $doc ) ;
xml_parse_into_struct($parser, trim($xmldoc), $xml_values);
print_r ( $xml_values ) ;
xml_parser_free ( $parser ) ;
}
fclose ( $fregions ) ;
}
Expected result:
apache segfault - browser displays previous content ( cache )
--
Edit bug report at http://bugs.php.net/?id=49338edit=1
--
Try a snapshot (PHP 5.2):
http://bugs.php.net/fix.php?id=49338r=trysnapshot52
Try a snapshot (PHP 5.3):
http://bugs.php.net/fix.php?id=49338r=trysnapshot53
Try a snapshot (PHP 6.0):
http://bugs.php.net/fix.php?id=49338r=trysnapshot60
Fixed in SVN:
http://bugs.php.net/fix.php?id=49338r=fixed
Fixed in SVN and need be documented:
http://bugs.php.net/fix.php?id=49338r=needdocs
Fixed in release:
http://bugs.php.net/fix.php?id=49338r=alreadyfixed
Need backtrace:
http://bugs.php.net/fix.php?id=49338r=needtrace
Need Reproduce Script:
http://bugs.php.net/fix.php?id=49338r=needscript
Try newer version:
http://bugs.php.net/fix.php?id=49338r=oldversion
Not developer issue:
http://bugs.php.net/fix.php?id=49338r=support
Expected behavior:
http://bugs.php.net/fix.php?id=49338r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=49338r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=49338r=submittedtwice
register_globals:
http://bugs.php.net/fix.php?id=49338r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=49338r=php4
Daylight Savings:http://bugs.php.net/fix.php?id=49338r=dst
IIS Stability:
http://bugs.php.net/fix.php?id=49338r=isapi
Install GNU Sed:
http://bugs.php.net/fix.php?id=49338r=gnused
Floating point limitations:
http://bugs.php.net/fix.php?id=49338r=float
No Zend Extensions:
http://bugs.php.net/fix.php?id=49338r=nozend
MySQL Configuration Error:
http://bugs.php.net/fix.php?id=49338r=mysqlcfg