Menu

#1 ftpd package does not handle binary files correctly

closed-fixed
ftpd (23)
8
2000-11-22
2000-11-17
No

Software:
---------
I am using TCL 3.3.2 and installed the latest tcllib0.8.
Contained in this library is a new package "ftpd" whose current version
is 1.1.

Problem:
--------
I wrote the following 2 line test script in order to test an FTP server:

package require ftpd
::ftp::server

However when I used this server to down-load binary files they were
either
corrupted or incomplete.
The FTP protocol between client and server correctly specifed binary
transfer mode.

Bug:
----
The default file system procedure "::ftpd::fsFile::fs" returns a file
handle
representing the local file for the following sub-commands :
append,retr,store
However the logic does not check what the current transfer mode when
opening the
file for reading/writing.

Correction:
-----------
One solution is to correct the following procedures:

1)
::ftpd::command::APPE
::ftpd::command::RETR
::ftpd::command::STOR
::ftpd::command::STOU

When calling the procedure "::ftpd::FS" add an additional parameter
$data(mode) indicating the current transfer mode.
This can be done easily because the procedure has a variable number
of arguments.

if {![catch {::ftpd::Fs retr $path $data(mode)} f]} {

2)
::ftpd::fsFile::fs

The extra parameter is passed from "::ftpd::FS" and can be tested
in the logic handling the sub-commands append,retr and store.

If the mode is binary then configure the file handle for binary
operation.

set fhandle [open $path r]
if {[lindex $args 0] == "binary"} {
fconfigure $fhandle -translation binary
}
return $fhandle

Discussion

  • Eric Melski

    Eric Melski - 2000-11-22
    • priority: 5 --> 8
    • assigned_to: nobody --> ericm
    • labels: 100100 --> ftpd
    • status: open --> closed-fixed
     
  • Eric Melski

    Eric Melski - 2000-11-22

    Nice job finding and fixing this bug, Mark. Thanks for the patch. Your fix is integrated into the CVS source tree, and will be included in the next release of the library.

    Eric Melski
    The Other Tcl Guy
    ericm at interwoven.com

     
MongoDB Logo MongoDB