9.0.x DevSnapshot: Bugfixes in IdTCPConnection and IDFTPServer

Giganews Newsgroups
Subject: 9.0.x DevSnapshot: Bugfixes in IdTCPConnection and IDFTPServer
Posted by:  Ulf_Jaenicke-Rößler
Date: Thu, 05 Oct 2006

Hi,

while working with FTPClient and FTPServer I found two bugs in IdTCPConnection and IDFTPServer,
respectively.

The first bug occurs, for instance, as soon as a FTP client calls List: IdFTP1->List(...) simply hangs.
I was able to fix it by checking the size of read data, which is necessary, because the while loop
doesn't break anymore if the connection has been close gracefully.

Here is a patch file:

--- c:/Programme/Borland/CBuilder6/Komponenten/Indy/Source/IdTCPConnection.pas.bak    Tue May 23 21:09:42 2006
+++ c:/Programme/Borland/CBuilder6/Komponenten/Indy/Source/IdTCPConnection.pas    Thu Oct 05 11:33:30 2006
@@ -745,6 +745,9 @@
            // than actually requested, so don't extract too
            // many bytes here...
            i := Min(i, InputBuffer.Size);
+            if i=0 then begin
+              break;
+            end;
            Move(InputBuffer.Memory^, LBuf[0], i);
            InputBuffer.Remove(i);
            if not (E is EIdConnClosedGracefully) or not AReadUntilDisconnect then begin

The second bug occurs, if a FTP client tries to rename a file on a FTP server. The connection seems to hang.
The reason is, that TIdFTPServer.CommandRNTO only sets a numeric return code, but no reply.

The fix is as follows:
--- c:/Programme/Borland/CBuilder6/Komponenten/Indy/Source/IdFTPServer.pas.bak    Fri Mar 31 20:45:16 2006
+++ c:/Programme/Borland/CBuilder6/Komponenten/Indy/Source/IdFTPServer.pas    Thu Oct 05 12:06:11 2006
@@ -1281,9 +1281,9 @@
      begin
        try
          FOnRenameFile(TIdFTPServerThread(ASender.Thread), FRNFR, s);
-          ASender.Reply.NumericCode := 250;
+          ASender.Reply.SetReply(250, RSFTPFileActionCompleted);
        except
-          ASender.Reply.NumericCode := 550;
+          ASender.Reply.SetReply(550, RSFTPFileActionNotTaken);
          raise;
        end;
      end

It would be great, if these fixes could go into the stable version, so that I don't need to have my own repository.

Best regards

Replies