php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #21529 Segmentation fault in command line script execution
Submitted: 2003-01-08 15:44 UTC Modified: 2003-01-08 21:34 UTC
From: francesco dot laurita at fastweb dot it Assigned:
Status: Closed Package: Reproducible crash
PHP Version: 4.3.0 OS: Linux RedHat 7.3 2.4.18
Private report: No CVE-ID: None
 [2003-01-08 15:44 UTC] francesco dot laurita at fastweb dot it
Script that cause crash:
<?php
/*
This script load hosts from file and try to connect with them
*/
        $list = file('host.txt');

        for ($i = 0; $i<count($list);$i++){
                $data = explode(":",trim($list[$i]));
                echo "Try ".$data[0]." on port ".$data[1]."\n";
                $sock = fsockopen($data[0],$data[1],&$errno,&$errstr,10);

                if ($sock){
                        echo "Connected on ".trim($list[$i])."\n";
                        exec("echo ".trim($list[$i])." >> pro.log");
                        fclose($sock);

                }

        }
?>

Configure line:
 ./configure --enable-ftp --with-gd --with-zlib --enable-calendar --enable-trans-sid --enable-xslt=/usr/lib --with-apxs=/usr/local/apache/bin/apxs --enable-sigchild --with-xml --with-expat=/usr/lib --with-xslt-sablot=/usr/lib --with-mysql=/usr --enable-pcntl --without-pear

php.ini
Default setting excepted the include_path

gdb:
(gdb) bt
#0  0x08114a32 in php_sockop_close (stream=0x81f316c, close_handle=1) at /usr/src/redhat/SOURCES/php-4.3.0/main/network.c:996
#1  0x081111d1 in _php_stream_free (stream=0x81f316c, close_options=3) at /usr/src/redhat/SOURCES/php-4.3.0/main/streams.c:327
#2  0x080ad98b in zif_fclose (ht=1, return_value=0x81f30fc, this_ptr=0x0, return_value_used=0)
    at /usr/src/redhat/SOURCES/php-4.3.0/ext/standard/file.c:1120
#3  0x08141bd4 in execute (op_array=0x81f0a44) at /usr/src/redhat/SOURCES/php-4.3.0/Zend/zend_execute.c:1596
#4  0x0812f7e4 in zend_execute_scripts (type=8, retval=0x0, file_count=3) at /usr/src/redhat/SOURCES/php-4.3.0/Zend/zend.c:864
#5  0x081096ed in php_execute_script (primary_file=0xbffffa30) at /usr/src/redhat/SOURCES/php-4.3.0/main/main.c:1573
#6  0x0814b12c in main (argc=3, argv=0xbffffad4) at /usr/src/redhat/SOURCES/php-4.3.0/sapi/cli/php_cli.c:746
#7  0x42017589 in __libc_start_main () from /lib/i686/libc.so.6
(gdb) frame 3
#3  0x08141bd4 in execute (op_array=0x81f0a44) at /usr/src/redhat/SOURCES/php-4.3.0/Zend/zend_execute.c:1596
1596                                                            ((zend_internal_function *) EX(function_state).function)->handler(EX(opline)->extended_value, EX(Ts)[EX(opline)->result.u.var].var.ptr, EX(object).ptr, return_value_used TSRMLS_CC);
(gdb) 

Note:
This is a only command line script
I've try to recompile whith --enable-debug but in this case i have not crash.
The host in the host file are 541.
Output example:
[fra@ebmserver fra]# php -q script.php 
Try xxxx-xxxx.com.xx on port 80
Connected on xx.xx.xx-18.xxx.xx.xx:80
Try xxx.5xx.xx.2xx on port 80
Connected on 1xx.xx.xx.xx:80
Try xx.kxxi.xx on port 80
Connected on wxx.xxi.is:80
Try xximv.axxu.xxx on port 80

Warning: fsockopen() [http://www.php.net/function.fsockopen]: php_network_getaddresses: getaddrinfo failed: Name or service not known in /fra/script.php on line 7

Warning: fsockopen() [http://www.php.net/function.fsockopen]: unable to connect to xxx.xxxau.xx:80 in /fra/script.php on line 7
Try 13xx.2xx8.xx1.xx on port 8080

Warning: fsockopen() [http://www.php.net/function.fsockopen]: php_hostconnect: connect failed in /fra/script.php on line 7

Warning: fsockopen() [http://www.php.net/function.fsockopen]: unable to connect to 1xxx.x.xx.xxx:8080 in /fra/script.php on line 7
Try wesxxxu.xx.texxxa.xx on port 80
Connected on wexxxu.lxxk.telxxxra.net:80
Try sexxer.clarxxyota.xxx on port 80
Connected on sexxxver.xxxarkxxxxta.com:80
Try nxxx2.rxxxa.cxxa on port 80
Connected on xx2.rxxa.cx:80
Segmentation fault (core dumped)

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-01-08 21:33 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-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 16:01:28 2024 UTC