princepawn has asked for the wisdom of the Perl Monks concerning the following question:
The reason it is suspect is that I do not check if the read is defined and thus both undef and 0 return values will end the loop.while ($bytesread = read($raw_file,$buffer,1024)) { print O $buffer; }
#!/usr/bin/perl use HTTP::Headers::UserAgent; use File::Basename; $VERSION = '3.0'; package HTTP::File; sub platform { $__platform = HTTP::Headers::UserAgent::GetPlatform ($ENV{HTTP_USE +R_AGENT}); $__platform =~ /^Win/ && return 'MSWin32'; $__platform =~ /^MAC/ && return 'MacOS'; $__platform =~ /x$/ && return ''; } sub upload { ($raw_file, $path,)=@_; # warn " ** raw_file $raw_file\n"; $path = $path ? $path : '/tmp'; # warn " ** path $path\n"; $platform = platform; # warn " ** platform $platform\n"; File::Basename::fileparse_set_fstype(platform); ($basename,$junk,$junk) = File::Basename::fileparse $raw_file; # warn " ** basename $basename\n"; open O, ">$path/$basename" || die $!; while ($bytesread = read($raw_file,$buffer,1024)) { print O $buffer; } close O; return $basename; } 1;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Windows NT CGI File Upload Problem
by tye (Sage) on Sep 14, 2000 at 19:36 UTC | |
by tilly (Archbishop) on Sep 14, 2000 at 19:55 UTC | |
by tye (Sage) on Sep 14, 2000 at 20:08 UTC | |
by tilly (Archbishop) on Sep 14, 2000 at 20:36 UTC | |
|
(Ovid - Is this a security hole?)RE: Windows NT CGI File Upload Problem
by Ovid (Cardinal) on Sep 14, 2000 at 20:30 UTC | |
|
Re: Windows NT CGI File Upload Problem
by Ovid (Cardinal) on Sep 14, 2000 at 19:44 UTC | |
by tye (Sage) on Sep 14, 2000 at 19:50 UTC | |
by princepawn (Parson) on Sep 14, 2000 at 20:09 UTC |