php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #23683 ftp_close($connection) crashes
Submitted: 2003-05-18 14:42 UTC Modified: 2003-05-19 08:31 UTC
From: pekka at studio-on-the dot net Assigned: moriyoshi (profile)
Status: Closed Package: FTP related
PHP Version: 4.3.2RC3 OS: Windows XP Profesional SP1
Private report: No CVE-ID: None
 [2003-05-18 14:42 UTC] pekka at studio-on-the dot net
I have an ftp upload script (non public code), which ends in plain

ftp_close($connection);

Where $connection is opened handle. After installing RC3 (as module) I a crash:

Event viewer: "Faulting application Apache.exe, version 0.0.0.0, faulting module php4ts.dll, version 4.3.2.2, fault address 0x000b9fc4."

or 

"Faulting application Apache.exe, version 0.0.0.0, faulting module ntdll.dll, version 5.1.2600.1106, fault address 0x00002109."

FTP is disconneted by the function before crash (ftp logs show session was perfect and complete). I have tried it with local ftp server and remote ones. I tried also with 

ftp_close();

and got no crash (and of course no disconnect either)

If I used 

ftp_close($fdfdf);

where $fdfdf is NOT an opened ftp handle, Apache just hangs page load after output code before ftp_close BUT without a crash.

If I comment line

/*
ftp_close($connection);
*/

the whole script runs ok, except ftp remains open of course.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-05-18 14:43 UTC] pekka at studio-on-the dot net
Oh, and Apache is 1.3.27.
 [2003-05-18 15:00 UTC] iliaa@php.net
Not enough information was provided for us to be able
to handle this bug. Please re-read the instructions at
http://bugs.php.net/how-to-report.php

If you can provide more information, feel free to add it
to this bug and change the status back to "Open".

Thank you for your interest in PHP.


Could you provide the smallest possible php script that could be used to replicate the crash & the output of var_dump($ftp_handle) just before you do ftp_close() on it.
 [2003-05-18 16:30 UTC] pekka at studio-on-the dot net
It gives BEFORE and AFTER "ftp_close($connection);"
 
resource(2) of type (FTP Buffer) 

I used code:

$ftp_server = "127.0.0.1";
$ftp_user_name = "pekka";
$ftp_user_pass = "mypass";
$ftp_folder = "/gallery/D30_photos/small";
$file_to_upload = "CRW_7145_00001.jpg";
$temppath = "./" . $file_to_upload;

$ftp_server = gethostbyname($ftp_server);
$connection = ftp_connect($ftp_server); 
ftp_set_option($connection, FTP_TIMEOUT_SEC, 5);
ftp_login($connection, $ftp_user_name, $ftp_user_pass);
ftp_systype($connection);
ftp_pasv($connection,TRUE);
ftp_mkdir($connection,$ftp_folder);
ftp_chdir($connection, $ftp_folder);
ftp_pwd($connection);
ftp_size($connection,urldecode($file_to_upload));
ftp_mdtm($connection,urldecode($file_to_upload));
ftp_put($connection,$file_to_upload,$temppath,FTP_BINARY);
var_dump($connection);
ftp_close($connection);

FTP server "Serv-U" reports:

--------------------
[6] Mon 19May03 00:28:11 - (000039) 220 Serv-U FTP Server v4.0 for WinSock ready...
[2] Mon 19May03 00:28:11 - (000039) USER pekka
[6] Mon 19May03 00:28:11 - (000039) 331 User name okay, need password.
[2] Mon 19May03 00:28:11 - (000039) PASS xxxxx
[6] Mon 19May03 00:28:11 - (000039) 230 User logged in, proceed.
[2] Mon 19May03 00:28:11 - (000039) SYST
[6] Mon 19May03 00:28:11 - (000039) 215 UNIX Type: L8
[2] Mon 19May03 00:28:11 - (000039) PASV
[6] Mon 19May03 00:28:11 - (000039) 227 Entering Passive Mode (127,0,0,1,12,117)
[2] Mon 19May03 00:28:11 - (000039) MKD /gallery/D30_photos/small
[6] Mon 19May03 00:28:11 - (000039) 550 /gallery/D30_photos/small: failed to create.
[2] Mon 19May03 00:28:11 - (000039) CWD /gallery/D30_photos/small
[6] Mon 19May03 00:28:11 - (000039) 250 Directory changed to /gallery/D30_photos/small
[2] Mon 19May03 00:28:11 - (000039) PWD
[6] Mon 19May03 00:28:11 - (000039) 257 "/gallery/D30_photos/small" is current directory.
[2] Mon 19May03 00:28:11 - (000039) TYPE I
[6] Mon 19May03 00:28:11 - (000039) 200 Type set to I.
[2] Mon 19May03 00:28:11 - (000039) SIZE CRW_7145_00001.jpg
[6] Mon 19May03 00:28:11 - (000039) 213 45644
[2] Mon 19May03 00:28:11 - (000039) MDTM CRW_7145_00001.jpg
[6] Mon 19May03 00:28:11 - (000039) 213 20030519002750
[5] Mon 19May03 00:28:11 - (000039) IP-Name: LOCALHOST
[2] Mon 19May03 00:28:11 - (000039) STOR CRW_7145_00001.jpg
[4] Mon 19May03 00:28:11 - (000039) Receiving file f:\program files\apache group\apache\htdocs\photography-on-the.net\gallery\d30_photos\small\crw_7145_00001.jpg
[6] Mon 19May03 00:28:11 - (000039) 150 Opening BINARY mode data connection for CRW_7145_00001.jpg.
[4] Mon 19May03 00:28:11 - (000039) Received file f:\program files\apache group\apache\htdocs\photography-on-the.net\gallery\d30_photos\small\crw_7145_00001.jpg successfully (4953 Kb/sec - 45644 bytes)
[6] Mon 19May03 00:28:11 - (000039) 226 Transfer complete.
[2] Mon 19May03 00:28:11 - (000039) QUIT
[6] Mon 19May03 00:28:11 - (000039) 221 Goodbye!
--------------------

And the crash was now:

Faulting application Apache.exe, version 0.0.0.0, faulting module ntdll.dll, version 5.1.2600.1106, fault address 0x00001d24.
 [2003-05-19 08:16 UTC] moriyoshi@php.net
ftp_pwd() problem.

 [2003-05-19 08:31 UTC] moriyoshi@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: Mon May 06 06:01:31 2024 UTC