commit-inetutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[SCM] GNU Inetutils branch, master, updated. inetutils-1_9-5-gdd43de5


From: Mats Erik Andersson
Subject: [SCM] GNU Inetutils branch, master, updated. inetutils-1_9-5-gdd43de5
Date: Wed, 04 Jan 2012 17:52:25 +0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU Inetutils ".

The branch, master has been updated
       via  dd43de5f41d00394cdff2fedabbf8e97e059d79b (commit)
      from  a6e53e7914367ae9263416e0cd1b8deef7a2d93b (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://git.savannah.gnu.org/cgit/inetutils.git/commit/?id=dd43de5f41d00394cdff2fedabbf8e97e059d79b


commit dd43de5f41d00394cdff2fedabbf8e97e059d79b
Author: Mats Erik Andersson <address@hidden>
Date:   Wed Jan 4 18:33:06 2012 +0100

    ftpd: Regression with active connections.
    
    In using an active connection, the port was not cleared properly,
    leading to a missed port allocation in bind().  A minor portability
    issue lead to change of hints for getaddrinfo() in resolving `host_port'.

diff --git a/ChangeLog b/ChangeLog
index 774ce14..06cc08f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2012-01-04  Mats Erik Andersson <address@hidden>
+
+       Regression: Erase port for active data transmission.
+
+       * ftpd/ftpcmd.y (host_port): Use AI_NUMERICHOST and AI_NUMERICSERV
+       in `HINTS.ai_flags'.  Do not use AI_ADDRCONFIG.
+       * ftpd/ftpd.c (getdatasock): Erase port number stored in DATA_SOURCE.
+       * tests/ftp-localhost.sh: Detect transfered data and duplicate tests
+       also for an active connection, not only a passive attempt.
+
 2012-01-03  Alfred M. Szmidt  <address@hidden>
 
        * bootstrap.conf (gnulib_modules): Removed git-merge-changelog.
diff --git a/ftpd/ftpcmd.y b/ftpd/ftpcmd.y
index 62bbcbc..49a4355 100644
--- a/ftpd/ftpcmd.y
+++ b/ftpd/ftpcmd.y
@@ -620,9 +620,8 @@ host_port
                        memset (&hints, 0, sizeof (hints));
                        hints.ai_family = AF_INET;
                        hints.ai_socktype = SOCK_STREAM;
-#ifdef AI_ADDRCONFIG
-                       hints.ai_flags = AI_ADDRCONFIG;
-#endif
+                       hints.ai_flags = AI_NUMERICHOST | AI_NUMERICSERV;
+
                        err = getaddrinfo (a, p, &hints, &res);
                        if (err)
                          reply (550, "Address failure: %s,%s", a, p);
diff --git a/ftpd/ftpd.c b/ftpd/ftpd.c
index dfba2fe..29e9eed 100644
--- a/ftpd/ftpd.c
+++ b/ftpd/ftpd.c
@@ -1037,10 +1037,23 @@ getdatasock (const char *mode)
       goto bad;
   }
 
-  /* anchor socket to avoid multi-homing problems */
+  /* Anchor socket to avoid multi-homing problems.  */
   memcpy (&data_source, &ctrl_addr, sizeof (data_source));
   data_source_len = ctrl_addrlen;
 
+  /* Erase port number, suggesting bind() to allocate a new port.  */
+  switch (data_source.ss_family)
+    {
+    case AF_INET6:
+      ((struct sockaddr_in6 *) &data_source)->sin6_port = 0;
+      break;
+    case AF_INET:
+      ((struct sockaddr_in *) &data_source)->sin_port = 0;
+      break;
+    default:
+      break;   /* Do nothing; should not happen!  */
+    }
+
   for (tries = 1;; tries++)
     {
       if (bind (s, (struct sockaddr *) &data_source, data_source_len) >= 0)
diff --git a/tests/ftp-localhost.sh b/tests/ftp-localhost.sh
index 2eec944..556a717 100755
--- a/tests/ftp-localhost.sh
+++ b/tests/ftp-localhost.sh
@@ -74,6 +74,8 @@ $INETD --pidfile=$TMPDIR/inetd.pid $TMPDIR/inetd.conf
 # Wait for inetd to write pid and open socket
 sleep 2
 
+# Test a passive connection.
+#
 cat <<STOP |
 rstatus
 dir
@@ -93,8 +95,48 @@ if [ $errno != 0 ]; then
     exit 77
 fi
 
+# Standing control connection?
+if ! grep 'FTP server status' $TMPDIR/ftp.stdout; then
+    echo cannot find expected output for passive ftp client?
+    exit 1
+fi
+
+# Was data transfer successful?
+if ! grep '226 Transfer complete.' $TMPDIR/ftp.stdout; then
+    echo cannot find transfer result for passive ftp client?
+    exit 1
+fi
+
+# Test an active connection.
+#
+cat <<STOP |
+rstatus
+dir
+STOP
+HOME=$TMPDIR $FTP $TARGET 4711 -4 -v -t >$TMPDIR/ftp.stdout
+
+errno=$?
+cat $TMPDIR/ftp.stdout
+
+if [ $errno != 0 ]; then
+    echo running ftp failed? errno $errno
+    exit 77
+fi
+
+if [ $errno != 0 ]; then
+    echo running ftp failed? errno $errno
+    exit 77
+fi
+
+# Standing control connection?
 if ! grep 'FTP server status' $TMPDIR/ftp.stdout; then
-    echo cannot find expected output from ftp client?
+    echo cannot find expected output for active ftp client?
+    exit 1
+fi
+
+# Was data transfer successful?
+if ! grep '226 Transfer complete.' $TMPDIR/ftp.stdout; then
+    echo cannot find transfer result for active ftp client?
     exit 1
 fi
 

-----------------------------------------------------------------------

Summary of changes:
 ChangeLog              |   10 ++++++++++
 ftpd/ftpcmd.y          |    5 ++---
 ftpd/ftpd.c            |   15 ++++++++++++++-
 tests/ftp-localhost.sh |   44 +++++++++++++++++++++++++++++++++++++++++++-
 4 files changed, 69 insertions(+), 5 deletions(-)


hooks/post-receive
-- 
GNU Inetutils 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]