php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #51802 PHP temp files not deleted when also using a CGI script
Submitted: 2010-05-12 21:07 UTC Modified: 2013-02-18 00:34 UTC
Votes:2
Avg. Score:5.0 ± 0.0
Reproduced:2 of 2 (100.0%)
Same Version:2 (100.0%)
Same OS:2 (100.0%)
From: relayadmin at disney dot com Assigned:
Status: No Feedback Package: CGI/CLI related
PHP Version: 5.2.13 OS: Windows Server 2003
Private report: No CVE-ID: None
 [2010-05-12 21:07 UTC] relayadmin at disney dot com
Description:
------------
This bug is very specific to Windows.  When executing a generic file upload using PHP, if at anytime while the file is being uploaded Apache then runs a CGI script like PERL or a C program, and the upload ends while the CGI script is still running, the uploaded file(s) in the temp directory will remain behind forever.

In order to avoid this the “php_do_open_temporary_file” routine will have to not use the “VCWD_OPEN_MODE” routine to open the temp file.  A generic Windows “open” call allows child processes to inherit their handles.  The temp file would need to be opened with a “CreateFile” call to open the file and specify the pSecurityAttributes option with bInheritHandle set to FALSE so that a child process will not inherit the open file handle.  The rub is this call uses a non-compatible handle so everyone who uses this handle has to be modified as well.



Test script:
---------------
Write or use any simple PHP upload program.  Next use CGI program below -- it doesn't need to do anything except take time.  So start the PHP upload, then start the CGI program below from a webpage.  Make sure the PHP upload completes before the script ends.


#include <windows.h>

void main(){
  Sleep(2*60*1000);	// sleep 2 minutes
}

Expected result:
----------------
The file should be uploaded and the temp file in the temp directory should not be present when done.  It should be moved to the destination directory.

Actual result:
--------------
The temp file remains forever in the temp directory, though the file is copied correctly to the destination directory.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2011-11-15 15:43 UTC] felipe@php.net
-Status: Open +Status: Feedback
 [2011-11-15 15:43 UTC] felipe@php.net
Please try using this snapshot:

  http://snaps.php.net/php5.3-latest.tar.gz
 
For Windows:

  http://windows.php.net/snapshots/


 [2013-02-18 00:34 UTC] php-bugs at lists dot php dot 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: Sat Dec 21 13:01:31 2024 UTC