Skip Menu |
 

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

This queue is for tickets about the CGI CPAN distribution.

Report information
The Basics
Id: 12694
Status: resolved
Priority: 0/
Queue: CGI

People
Owner: LDS [...] cpan.org
Requestors: swalker [...] theiqgroup.com
Cc:
AdminCc:

Bug Information
Severity: Critical
Broken in: (no value)
Fixed in: (no value)

Attachments


Subject: Upload randomly fails to return a filehandle
Download (untitled) / with headers
text/plain 535b
I'm using perl 5.8.5 along with CGI 3.05 under a Apache 2 / mod_perl 1.99 environment. The problem is that CGI->upload sometimes fails return the filehandle when uploading files, while CGI->param($param_name) always gives me the filehandle correctly. I have traced this down to the upload routine itself. I believe the issue is the array vs. scalar context tricks that upload is pulling off to make developers happy when using the function. For now I will be overriding the upload function and using CGI->param($param_name) instead.
From: swalker [...] theiqgroup.com
Download (untitled) / with headers
text/plain 195b
[guest - Thu May 5 16:39:27 2005]: I will also note that I checked to make sure that this was not a race condition where the filehandle was having DESTROY called on it before upload was called.
From: Mike Hudack
Download (untitled) / with headers
text/plain 789b
[guest - Thu May 5 16:39:27 2005]: Show quoted text
> I'm using perl 5.8.5 along with CGI 3.05 under a Apache 2 / mod_perl > 1.99 environment. > > The problem is that CGI->upload sometimes fails return the filehandle > when uploading files, while CGI->param($param_name) always gives me > the filehandle correctly. I have traced this down to the upload > routine itself.
I find that this fails "randomly", except that it doesn't seem to be random. I've managed to find a client which consistently causes CGI to fail to return a filehandle. I haven't had time to isolate it further, but I will try to and submit more detailed information here. I've found that uploads performed with the Java HTTPClient 0.3-3 (http://www.innovation.ch/java/HTTPClient/) fail more consistently than others.
From: eric [...] petta-tech.com
Download (untitled) / with headers
text/plain 737b
On Thu May 05 16:39:27 2005, guest wrote: Show quoted text
> I'm using perl 5.8.5 along with CGI 3.05 under a Apache 2 / mod_perl > 1.99 environment. > > The problem is that CGI->upload sometimes fails return the filehandle > when uploading files, while CGI->param($param_name) always gives me > the filehandle correctly. I have traced this down to the upload > routine itself.
I believe I've found the bug and have a fix for it, The following line in upload() of CGI.pm is incorrect: my @param = grep(ref && fileno($_), $self->param($param_name)); It should be: my @param = grep(ref && defined(fileno($_)), $self->param($param_name)); because fileno($_) can be 0, since stdin (the usual taker of fileno 0) is closed by Apache.
From: eric [...] petta-tech.com
Here's a patch, as well
--- CGI.pm-orig 2006-08-16 14:06:42.000000000 -0700 +++ CGI.pm 2006-08-16 14:06:56.000000000 -0700 @@ -3411,7 +3411,7 @@ 'upload' =><<'END_OF_FUNC', sub upload { my($self,$param_name) = self_or_default(@_); - my @param = grep(ref && fileno($_), $self->param($param_name)); + my @param = grep(ref && defined(fileno($_)), $self->param($param_name)); return unless @param; return wantarray ? @param : $param[0]; }
Thanks! Will be fixed in 3.22 when it is released.


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.