php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #21847 php core dumps whilst retrieving images from url
Submitted: 2003-01-23 13:02 UTC Modified: 2003-02-07 23:47 UTC
From: steveh at brendata dot co dot uk Assigned:
Status: No Feedback Package: Reproducible crash
PHP Version: 4.3.0 OS: linux-2.4.20
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: steveh at brendata dot co dot uk
New email:
PHP Version: OS:

 

 [2003-01-23 13:02 UTC] steveh at brendata dot co dot uk
When running the following code php core dumps.

<?
// Read the draper txt file
$fp=fopen("draper.txt","r");
$good=fopen("draper_good.txt","w");
$bad=fopen("draper_bad.txt","w");
while(!feof($fp))
        {
        $fields=split(",",fgets($fp));
        $url="http://www.drapertools.com/draper/images/details/".trim($fields[1])."_".trim($fields[2]).".jpg";
        $outfile="draper_images/draper_".trim($fields[1])."_".trim($fields[2]).".jpg";
        print("opening $url\n");
        ob_flush();
        if($urlfp=fopen($url,"rb"))
                {
                print("Outputing to $outfile\n");
                if($imagefp=fopen($outfile,"wb"))
                        {
                        print($url." -> ".$outfile."\n");
                        ob_flush();
                        fputs($good,$url." -> ".$outfile."\n");
                        $size=0;
                        while(!feof($urlfp))
                                {
                                $block=fread($urlfp,4096);
                                fputs($imagefp,$block);
                                $size+=4096;
                                print($url." -> ".$outfile." : $size\n");
                                };
                        fclose($imagefp);
                        };
                fclose($urlfp);
                }
        else
                {
                fputs($bad,$url."\n");
                };
        };
fclose($fp);
fclose($good);
fclose($bad);
?>

The input file is a comma delimited list, we are interested in the filename which we then retrieve from the site (you can find the names by going to the site or by downloading the text file from the site).

Just recompiled with debug, here is the backtrace:
#0  0x08153650 in php_hostconnect (host=0x82ef62c "www.drapertools.com", port=80, socktype=1, timeout=0x0)
    at /usr/src/php-4.3.0/main/network.c:435
#1  0x08153900 in _php_stream_sock_open_host (host=0x82ef62c "www.drapertools.com", port=80, socktype=1, timeout=0x0, 
    persistent_id=0x0) at /usr/src/php-4.3.0/main/network.c:619
#2  0x0811a497 in php_stream_url_wrap_http (wrapper=0x82491f0, 
    path=0x82ed5c4 "http://www.drapertools.com/draper/images/details/002_770-SA.jpg", mode=0x82e97cc "rb", options=4, 
    opened_path=0x0, context=0x0) at /usr/src/php-4.3.0/ext/standard/http_fopen_wrapper.c:121
#3  0x08152d2c in _php_stream_open_wrapper_ex (path=0x82ed5c4 "http://www.drapertools.com/draper/images/details/002_770-SA.jpg", 
    mode=0x82e97cc "rb", options=12, opened_path=0x0, context=0x0) at /usr/src/php-4.3.0/main/streams.c:2378
#4  0x080e915a in php_if_fopen (ht=2, return_value=0x82ee5ac, this_ptr=0x0, return_value_used=1)
    at /usr/src/php-4.3.0/ext/standard/file.c:1094
#5  0x404f78f0 in zend_oe () from /usr/local/Zend/lib/ZendOptimizer.so
#6  0x404f43a0 in zend_oe () from /usr/local/Zend/lib/ZendOptimizer.so
#7  0x0816f14c in zend_execute_scripts (type=8, retval=0x0, file_count=3) at /usr/src/php-4.3.0/Zend/zend.c:864
#8  0x08148909 in php_execute_script (primary_file=0xbffffb40) at /usr/src/php-4.3.0/main/main.c:1573
#9  0x08190f48 in main (argc=2, argv=0xbffffbe4) at /usr/src/php-4.3.0/sapi/cli/php_cli.c:746
#10 0x40342657 in __libc_start_main (main=0x81905c8 <main>, argc=2, ubp_av=0xbffffbe4, init=0x806fe60 <_init>, 
    fini=0x8196790 <_fini>, rtld_fini=0x4000dcd4 <_dl_fini>, stack_end=0xbffffbdc) at ../sysdeps/generic/libc-start.c:129

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-01-23 19:18 UTC] iliaa@php.net
Could you please provide the draper.txt so that the bug can be replicated. As is I cannot replicate the crash, merely get an error opening the specified image URL.
Also, does the crash occur if you disable ZendOptimizer?
 [2003-01-24 02:28 UTC] steveh at brendata dot co dot uk
This is the URL for the file, I will try switching off the optimiser and run again.

http://www.draper.co.uk/files/United%20Kingdom2002.txt
 [2003-01-24 03:16 UTC] steveh at brendata dot co dot uk
Still crashes with optmiser disabled but no core dump now, last string printed is corrupt.
 [2003-01-24 10:07 UTC] iliaa@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

Cannot replicate the crash with latest CVS.
 [2003-02-07 23:47 UTC] sniper@php.net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Open". Thank you.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 19:01:28 2024 UTC