]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Bug 3428: Active FTP data channel accepted twice
authorMichael Weiser <michael@weiser.dinsnail.net>
Fri, 2 Dec 2011 12:54:55 +0000 (05:54 -0700)
committerAmos Jeffries <squid3@treenet.co.nz>
Fri, 2 Dec 2011 12:54:55 +0000 (05:54 -0700)
src/ftp.cc

index 59b71832e4c698386ca7ac981fc900f9697d011f..9b4c5cdca7c04449a52f77fe38721e3529b6c0a5 100644 (file)
@@ -2552,6 +2552,7 @@ ftpReadEPSV(FtpStateData* ftpState)
 
     ftpState->data.port = port;
 
+    safe_free(ftpState->data.host);
     ftpState->data.host = xstrdup(fd_table[ftpState->ctrl.fd].ipaddr);
 
     safe_free(ftpState->ctrl.last_command);
@@ -2823,6 +2824,7 @@ ftpReadPasv(FtpStateData * ftpState)
 
     ftpState->data.port = port;
 
+    safe_free(ftpState->data.host);
     if (Config.Ftp.sanitycheck)
         ftpState->data.host = xstrdup(fd_table[ftpState->ctrl.fd].ipaddr);
     else
@@ -2871,6 +2873,7 @@ ftpOpenListenSocket(FtpStateData * ftpState, int fallback)
 
     /// Close old data channel, if any. We may open a new one below.
     ftpState->data.close();
+    safe_free(ftpState->data.host);
 
     /*
      * Set up a listen socket on the same local address as the
@@ -3117,7 +3120,10 @@ void FtpStateData::ftpAcceptDataConnection(const CommAcceptCbParams &io)
     data.close();
     data.opened(io.nfd, dataCloser());
     data.port = io.details.peer.GetPort();
-    io.details.peer.NtoA(data.host,SQUIDHOSTNAMELEN);
+
+    static char ntoapeer[MAX_IPSTRLEN];
+    io.details.peer.NtoA(ntoapeer,sizeof(ntoapeer));
+    data.host = xstrdup(ntoapeer);
 
     debugs(9, 3, "ftpAcceptDataConnection: Connected data socket on " <<
            "FD " << io.nfd << " to " << io.details.peer << " FD table says: " <<