]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Bug 3428: Active FTP data channel accepted twice
authorMichael Weiser <michael@weiser.dinsnail.net>
Mon, 28 Nov 2011 02:22:22 +0000 (19:22 -0700)
committerAmos Jeffries <squid3@treenet.co.nz>
Mon, 28 Nov 2011 02:22:22 +0000 (19:22 -0700)
src/ftp.cc

index 7fdc67bba6694aa44edd97a3eae494b3ac7cb29d..ae73d6eb9a66dc1ca9e307b2dd0b42fa2c15aa7b 100644 (file)
@@ -2467,6 +2467,7 @@ ftpReadEPSV(FtpStateData* ftpState)
 
     ftpState->data.port = port;
 
+    safe_free(ftpState->data.host);
     ftpState->data.host = xstrdup(fd_table[ftpState->ctrl.conn->fd].ipaddr);
 
     safe_free(ftpState->ctrl.last_command);
@@ -2712,6 +2713,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.conn->fd].ipaddr);
     else
@@ -2770,7 +2772,7 @@ ftpOpenListenSocket(FtpStateData * ftpState, int fallback)
         ftpState->data.clear();
     else
         ftpState->data.close();
-    ftpState->data.host = NULL;
+    safe_free(ftpState->data.host);
 
     /*
      * Set up a listen socket on the same local address as the
@@ -2980,7 +2982,9 @@ FtpStateData::ftpAcceptDataConnection(const CommAcceptCbParams &io)
     /** On COMM_OK start using the accepted data socket and discard the temporary listen socket. */
     data.close();
     data.opened(io.conn, dataCloser());
-    io.conn->remote.NtoA(data.host,SQUIDHOSTNAMELEN);
+    static char ntoapeer[MAX_IPSTRLEN];
+    io.conn->remote.NtoA(ntoapeer,sizeof(ntoapeer));
+    data.host = xstrdup(ntoapeer);
 
     debugs(9, 3, HERE << "Connected data socket on " <<
            io.conn << ". FD table says: " <<