Bug in CGI.pm - uploaded file size
Jan Kasprzak
kas na informatics.muni.cz
Pondělí Červenec 28 17:47:56 MEST 2003
Hello,
I have discovered a bug in CGI.pm - it computes incorrectly
the size of the uploaded file. When the length of the uploaded file
is 4095 bytes, it transfers 4096 bytes leaving an extra \r at the end
of the file. The value 4095 depends probably of the $FILLUNIT constant.
The patch against the version of CGI.pm labeled
$CGI::revision = '$Id: CGI.pm,v 1.75 2002/10/16 17:48:37 lstein Exp $';
$CGI::VERSION='2.89';
is the following:
--- CGI.pm.orig 2003-07-28 17:39:36.000000000 +0200
+++ CGI.pm 2003-07-28 17:40:16.000000000 +0200
@@ -3392,8 +3392,10 @@
substr($self->{BUFFER},0,$bytesToReturn)='';
# If we hit the boundary, remove the CRLF from the end.
- return (($start > 0) && ($start <= $bytes))
- ? substr($returnval,0,-2) : $returnval;
+ # MIND THE GAP: compute the end offset from $start, not from
+ # length($returnval)! -Jan "Yenya" Kasprzak, 2003-07-28
+ return (($start > 0) && ($start - 2 < $bytes))
+ ? substr($returnval,0,$start-2) : $returnval;
}
END_OF_FUNC
Please let me know if you accept this patch. Thanks,
-Yenya
--
| Jan "Yenya" Kasprzak <kas at {fi.muni.cz - work | yenya.net - private}> |
| GPG: ID 1024/D3498839 Fingerprint 0D99A7FB206605D7 8B35FCDE05B18A5E |
| http://www.fi.muni.cz/~kas/ Czech Linux Homepage: http://www.linux.cz/ |
|__ If you want "aesthetics", go play with microkernels. -Linus Torvalds __|
Další informace o konferenci Perl