#49338 [Opn->Fbk]: when fopen is used without the second parameter, php segfaults in apache 2.2
| From: | scottmac@php.net | Date: | Sun, 23 Aug 2009 16:23:02 +0000 |
| Subject: | #49338 [Opn->Fbk]: when fopen is used without the second parameter, php segfaults in apache 2.2 | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-141406@lists.php.net to get a copy of this message | ||
ID: 49338
Updated by: scottmac@php.net
Reported By: ttessier at swhistlesoft dot com
-Status: Open
+Status: Feedback
Bug Type: Filesystem function related
Operating System: solaris 10
PHP Version: 5.2.10
New Comment:
Thank you for this bug report. To properly diagnose the problem, we
need a backtrace to see what is happening behind the scenes. To
find out how to generate a backtrace, please read
http://bugs.php.net/bugs-generating-backtrace.php
for *NIX and
http://bugs.php.net/bugs-generating-backtrace-win32.php
for Win32
Once you have generated a backtrace, please submit it to this bug
report and change the status back to "Open". Thank you for helping
us make PHP better.
Previous Comments:
------------------------------------------------------------------------
[2009-08-23 16:17:17] ttessier at swhistlesoft dot com
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 this bug report at http://bugs.php.net/?id=49338&edit=1