]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Fix FTP EPSV negotiation parser.
authorAmos Jeffries <squid3@treenet.co.nz>
Sun, 26 Jul 2009 10:26:37 +0000 (22:26 +1200)
committerAmos Jeffries <squid3@treenet.co.nz>
Sun, 26 Jul 2009 10:26:37 +0000 (22:26 +1200)
No longer ignores single-value hints returned ie (1)

src/ftp.cc

index d0e1945f83608a818f86a72a2de989aaf5e7c65f..b50d299a6e05ace4b39aa6c26d81fbeca58589e1 100644 (file)
@@ -2447,9 +2447,13 @@ ftpReadEPSV(FtpStateData* ftpState)
         /* server response with list of supported methods   */
         /*   522 Network protocol not supported, use (1)    */
         /*   522 Network protocol not supported, use (1,2)  */
+        /* TODO: handle the (1,2) case. We might get it back after EPSV ALL 
+         * which means close data + control without self-destructing and re-open from scratch. */
         debugs(9, 5, HERE << "scanning: " << ftpState->ctrl.last_reply);
+        buf = ftpState->ctrl.last_reply;
+        while (buf != NULL && *buf != '\0' && *buf != '\n' && *buf != '(') ++buf;
+        if (buf != NULL && *buf == '\n') ++buf;
 
-        buf = ftpState->ctrl.last_reply + strcspn(ftpState->ctrl.last_reply, "(1,2)");
         if (buf == NULL || *buf == '\0') {
             /* handle broken server (RFC 2428 says MUST specify supported protocols in 522) */
             debugs(9, DBG_IMPORTANT, "Broken FTP Server at " << fd_table[ftpState->ctrl.fd].ipaddr << ". 522 error missing protocol negotiation hints");
@@ -2473,6 +2477,11 @@ ftpReadEPSV(FtpStateData* ftpState)
             ftpSendPassive(ftpState);
 #endif
         }
+        else {
+            /* handle broken server (RFC 2428 says MUST specify supported protocols in 522) */
+            debugs(9, DBG_IMPORTANT, "WARNING: Server at " << fd_table[ftpState->ctrl.fd].ipaddr << " sent unknown protocol negotiation hint: " << buf);
+            ftpSendPassive(ftpState);
+        }
         return;
     }