php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #22283 fopen causes core dump
Submitted: 2003-02-18 15:51 UTC Modified: 2003-02-18 18:50 UTC
From: pprocacci at datapipe dot com Assigned: iliaa
Status: Closed Package: Reproducible crash
PHP Version: 4.3.0 5.0-dev OS: FreeBSD4.7-Stable
Private report: No CVE-ID:
 [2003-02-18 15:51 UTC] pprocacci at datapipe dot com
PHP Version => 4.3.0

System => FreeBSD lucky 4.7-RELEASE-p4 FreeBSD 4.7-RELEASE-p4 #0: Mon  i386
Build Date => Feb 17 2003 01:29:45
Configure Command =>  './configure' '--with-apxs=/usr/local/sbin/apxs' '--with-config-file-path=/usr/local/etc' '--enable-versioning' '--with-regex=system' '--without-gd' '--without-mysql' '--with-gd=/usr/local' '--enable-gd-native-ttf' '--with-freetype-dir=/usr/local' '--with-jpeg-dir=/usr/local' '--with-png-dir=/usr/local' '--with-zlib' '--with-bz2=/usr' '--with
-mcrypt=/usr/local' '--with-mhash=/usr/local' '--with-pdflib=/usr/local' '--with-zlib-dir=/usr' '--with-jpeg-dir=/usr/local' '--with-png-dir=/usr/local' '--with-tiff-dir=/usr/local' '
--with-imap=/usr/local' '--with-mysql=/usr/local' '--with-pgsql=/usr/local' '--with-dbase' '--with-gdbm=/usr/local' '--with-ldap=/usr/local' '--with-openssl=/usr' '--with-snmp=/usr/lo
cal' '--enable-ucd-snmp-hack' '--with-openssl=/usr' '--with-expat-dir=/usr/local' '--with-xmlrpc' '--enable-xslt' '--with-xslt-sablot=/usr/local' '--enable-wddx' '--with-dom=/usr/loca
l' '--enable-ftp' '--with-curl=/usr/local' '--with-gettext=/usr/local' '--with-iconv=/usr/local' '--with-pspell=/usr/local' '--enable-mbregex' '--enable-mbstring' '--enable-yp' '--ena
ble-bcmath' '--with-hyperwave=yes' '--with-mcve=/usr/local' '--with-ming=/usr/local' '--with-mcal=/usr/local' '--enable-sockets' '--enable-sysvsem' '--enable-sysvshm' '--enable-trans-sid' '--with-yaz=/usr/local/bin' '--prefix=/usr/local' 'i386-portbld-freebsd4.7'
Server API => Command Line Interface
Virtual Directory Support => disabled
Configuration File (php.ini) Path => /usr/local/etc
PHP API => 20020918
PHP Extension => 20020429
Zend Extension => 20021010
Debug Build => no
Thread Safety => disabled
Registered PHP Streams => php, http, ftp, https, ftps, compress.bzip2, compress.zlib  


I know this sounds rediculous, but  the following dumps core:

#!/usr/local/bin/php
<?php

$fp = fopen("http://xanthus.net", "r");

if(!is_resource($fp))
        die("Couldn't open xanthus.net\n");


fclose($fp);

?>

#######################
while this one doesn't
#######################

#!/usr/local/bin/php
<?php

$fp = fopen("http://php.net", "r");

if(!is_resource($fp))
        die("Couldn't open php.net\n");


fclose($fp);

?>

############################
There seems to be a problem with the way php handles redirects.  That page "xanthus.net" gets redirected to elsewhere, while php.net doesn't (or at least I think this is the reason.)

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-02-18 16:03 UTC] pprocacci at datapipe dot com
My Knowledge of gdb is very limited, but I can get this far.  ;(

Program received signal SIGSEGV, Segmentation fault.
0x819f13d in php_stream_url_wrap_http ()
 [2003-02-18 16:03 UTC] magnus@php.net
Please try using this CVS snapshot:

  http://snaps.php.net/php4-STABLE-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php4-win32-STABLE-latest.zip

And if it still is crashing, please provide a backtrace.
 [2003-02-18 16:10 UTC] magnus@php.net

 [2003-02-18 17:38 UTC] pprocacci at datapipe dot com
Here's my gdb output ..... (Not sure how to use gdb...hopefully my 5 minutes in the man page is useful)


lucky# gdb php
GNU gdb 4.18 (FreeBSD)
Copyright 1998 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "i386-unknown-freebsd"...Deprecated bfd_read called at /usr/src/gnu/usr.bin/binutils/gdb/../../../../contrib/gdb/gdb/dbxread.c line 2627 in elfstab_build_psymtabs
Deprecated bfd_read called at /usr/src/gnu/usr.bin/binutils/gdb/../../../../contrib/gdb/gdb/dbxread.c line 933 in fill_symbuf

(gdb) set args ./l_checker.php
(gdb) r
Starting program: /usr/local/bin/php ./l_checker.php

Program received signal SIGSEGV, Segmentation fault.
0x81bd6bd in php_stream_url_wrap_http (wrapper=0x82d06c0, path=0x83adea4 "http://xanthus.net", mode=0x83bc0a4 "r", options=4, opened_path=0x0, context=0x0, 
    __php_stream_call_depth=1, __zend_filename=0x8278080 "/usr/ports/www/mod_php4/work/php-4.3.0/main/streams.c", __zend_lineno=2380, 
    __zend_orig_filename=0x8267840 "/usr/ports/www/mod_php4/work/php-4.3.0/ext/standard/file.c", __zend_orig_lineno=1096)
    at /usr/ports/www/mod_php4/work/php-4.3.0/ext/standard/http_fopen_wrapper.c:351
351     /usr/ports/www/mod_php4/work/php-4.3.0/ext/standard/http_fopen_wrapper.c: No such file or directory.
(gdb) backtrace
#0  0x81bd6bd in php_stream_url_wrap_http (wrapper=0x82d06c0, path=0x83adea4 "http://xanthus.net", mode=0x83bc0a4 "r", options=4, opened_path=0x0, context=0x0, 
    __php_stream_call_depth=1, __zend_filename=0x8278080 "/usr/ports/www/mod_php4/work/php-4.3.0/main/streams.c", __zend_lineno=2380, 
    __zend_orig_filename=0x8267840 "/usr/ports/www/mod_php4/work/php-4.3.0/ext/standard/file.c", __zend_orig_lineno=1096)
    at /usr/ports/www/mod_php4/work/php-4.3.0/ext/standard/http_fopen_wrapper.c:351
#1  0x81f7040 in _php_stream_open_wrapper_ex (path=0x83adea4 "http://xanthus.net", mode=0x83bc0a4 "r", options=12, opened_path=0x0, context=0x0, __php_stream_call_depth=0, 
    __zend_filename=0x8267840 "/usr/ports/www/mod_php4/work/php-4.3.0/ext/standard/file.c", __zend_lineno=1096, __zend_orig_filename=0x0, __zend_orig_lineno=0)
    at /usr/ports/www/mod_php4/work/php-4.3.0/main/streams.c:2378
#2  0x818142b in php_if_fopen (ht=2, return_value=0x83bc124, this_ptr=0x0, return_value_used=1) at /usr/ports/www/mod_php4/work/php-4.3.0/ext/standard/file.c:1094
#3  0x822b4c8 in execute (op_array=0x83b0824) at /usr/ports/www/mod_php4/work/php-4.3.0/Zend/zend_execute.c:1598
#4  0x8216ec8 in zend_execute_scripts (type=8, retval=0x0, file_count=3) at /usr/ports/www/mod_php4/work/php-4.3.0/Zend/zend.c:864
#5  0x81eae7a in php_execute_script (primary_file=0xbfbffb74) at /usr/ports/www/mod_php4/work/php-4.3.0/main/main.c:1573
#6  0x8233b8a in main (argc=2, argv=0xbfbffbdc) at /usr/ports/www/mod_php4/work/php-4.3.0/sapi/cli/php_cli.c:746
#7  0x8080c45 in _start ()
 [2003-02-18 18:50 UTC] iliaa@php.net
This bug has been fixed in CVS.

In case this was a PHP problem, snapshots of the sources are packaged
every three hours; this change will be in the next snapshot. You can
grab the snapshot at http://snaps.php.net/.
 
In case this was a documentation problem, the fix will show up soon at
http://www.php.net/manual/.

In case this was a PHP.net website problem, the change will show
up on the PHP.net site and on the mirror sites in short time.
 
Thank you for the report, and for helping us make PHP better.


 
PHP Copyright © 2001-2014 The PHP Group
All rights reserved.
Last updated: Sun Apr 20 01:02:05 2014 UTC