You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by wr...@apache.org on 2007/12/12 19:51:01 UTC

svn commit: r603702 - /httpd/mod_ftp/trunk/modules/ftp/ftp_commands.c

Author: wrowe
Date: Wed Dec 12 10:51:00 2007
New Revision: 603702

URL: http://svn.apache.org/viewvc?rev=603702&view=rev
Log:
Clean up unused sockets in PORT/EPRT/passive socket failure

Modified:
    httpd/mod_ftp/trunk/modules/ftp/ftp_commands.c

Modified: httpd/mod_ftp/trunk/modules/ftp/ftp_commands.c
URL: http://svn.apache.org/viewvc/httpd/mod_ftp/trunk/modules/ftp/ftp_commands.c?rev=603702&r1=603701&r2=603702&view=diff
==============================================================================
--- httpd/mod_ftp/trunk/modules/ftp/ftp_commands.c (original)
+++ httpd/mod_ftp/trunk/modules/ftp/ftp_commands.c Wed Dec 12 10:51:00 2007
@@ -1479,8 +1479,6 @@
     const char *addr;
     int family = 0;
 
-    ftp_reset_dataconn(fc);
-
     if (strcasecmp(arg, "ALL") == 0) {
         /* A contract to never respond to other data connection methods */
         fc->all_epsv = 1;
@@ -1488,6 +1486,8 @@
         return FTP_REPLY_COMMAND_OK;
     }
 
+    ftp_reset_dataconn(fc);
+
     /* Why don't pasv_bindaddr/bindfamily appear below?
      * These directives provide an override which the client
      * is informed of, while EPSV only informs the client of
@@ -1607,7 +1607,6 @@
     if ( ( res = init_pasv_socket(r, family, addr) ) ) {
         return res;
     }
-
     s = fc->csock;
 
     apr_socket_addr_get(&sa, APR_LOCAL, s);
@@ -1767,6 +1766,7 @@
 #endif
             ap_log_error(APLOG_MARK, APLOG_ERR, rv, c->base_server,
                          "Couldn't bind to socket");
+        apr_socket_close(s);
         return FTP_REPLY_CANNOT_OPEN_DATACONN;
     }
 
@@ -1782,6 +1782,7 @@
 #endif
         fc->response_notes = apr_pstrdup(r->pool,
                      "Invalid EPRT command, unable to decode request");
+        apr_socket_close(s);
         return FTP_REPLY_SYNTAX_ERROR;
     }
 
@@ -1805,12 +1806,12 @@
                          test_ip, c->remote_ip);
             fc->response_notes = apr_pstrdup(r->pool,
                          "Invalid EPRT command, proxy EPRT is not permitted");
+            apr_socket_close(s);
             return FTP_REPLY_SYNTAX_ERROR;
         }
     }
     
     fc->response_notes = apr_psprintf(r->pool, FTP_MSG_SUCCESS, r->method);
-    fc->passive_created = -1; /* Redundant but just for clarity */
     fc->csock = s;
     return FTP_REPLY_COMMAND_OK;
 }
@@ -1916,6 +1917,7 @@
         ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r,
                       "Couldn't resolve local socket address"
                       " (apr or socket stack bug?)  Giving up");
+        apr_socket_close(s);
         return FTP_REPLY_CANNOT_OPEN_DATACONN;
     }
 
@@ -1931,6 +1933,7 @@
 #endif
             ap_log_error(APLOG_MARK, APLOG_ERR, rv, c->base_server,
                          "Couldn't bind to socket");
+        apr_socket_close(s);
         return FTP_REPLY_CANNOT_OPEN_DATACONN;
     }
 
@@ -1938,7 +1941,6 @@
                           port, 0, c->pool);
 
     fc->response_notes = apr_psprintf(r->pool, FTP_MSG_SUCCESS, r->method);
-    fc->passive_created = -1; /* Redundant but just for clarity */
     fc->csock = s;
     return FTP_REPLY_COMMAND_OK;
 }