Source-Changes-HG archive

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

[src/trunk]: src/usr.sbin/faithd correct ftp relay functionality.



details:   https://anonhg.NetBSD.org/src/rev/4f1b81db3d09
branches:  trunk
changeset: 533195:4f1b81db3d09
user:      itojun <itojun%NetBSD.org@localhost>
date:      Mon Jun 24 06:03:13 2002 +0000

description:
correct ftp relay functionality.

diffstat:

 usr.sbin/faithd/ftp.c |  33 +++++++++++++--------------------
 1 files changed, 13 insertions(+), 20 deletions(-)

diffs (91 lines):

diff -r ab48ff03f866 -r 4f1b81db3d09 usr.sbin/faithd/ftp.c
--- a/usr.sbin/faithd/ftp.c     Mon Jun 24 05:52:29 2002 +0000
+++ b/usr.sbin/faithd/ftp.c     Mon Jun 24 06:03:13 2002 +0000
@@ -1,5 +1,5 @@
-/*     $NetBSD: ftp.c,v 1.9 2002/06/07 00:20:45 itojun Exp $   */
-/*     $KAME: ftp.c,v 1.15 2002/06/07 00:16:37 itojun Exp $    */
+/*     $NetBSD: ftp.c,v 1.10 2002/06/24 06:03:13 itojun Exp $  */
+/*     $KAME: ftp.c,v 1.18 2002/06/23 14:41:47 itojun Exp $    */
 
 /*
  * Copyright (C) 1997 and 1998 WIDE Project.
@@ -84,27 +84,25 @@
 
                FD_ZERO(&readfds);
                FD_SET(ctl4, &readfds);
+               maxfd = ctl4;
                FD_SET(ctl6, &readfds);
+               maxfd = (ctl6 > maxfd) ? ctl6 : maxfd;
                if (0 <= port4) {
                        FD_SET(port4, &readfds);
-                       if (port4 > maxfd)
-                               maxfd = port4;
+                       maxfd = (port4 > maxfd) ? port4 : maxfd;
                }
                if (0 <= port6) {
                        FD_SET(port6, &readfds);
-                       if (port6 > maxfd)
-                               maxfd = port6;
+                       maxfd = (port6 > maxfd) ? port6 : maxfd;
                }
 #if 0
                if (0 <= wport4) {
                        FD_SET(wport4, &readfds);
-                       if (wport4 > maxfd)
-                               maxfd = wport4;
+                       maxfd = (wport4 > maxfd) ? wport4 : maxfd;
                }
                if (0 <= wport6) {
                        FD_SET(wport6, &readfds);
-                       if (wport6 > maxfd)
-                               maxfd = wport6;
+                       maxfd = (wport6 > maxfd) ? wport6 : maxfd;
                }
 #endif
                tv.tv_sec = FAITH_TIMEOUT;
@@ -129,16 +127,13 @@
                         */
                        error = ftp_copycommand(ctl6, ctl4, &state);
 
-                       switch (error) {
-                       case -1:
+                       if (error < 0)
                                goto bad;
-                       case 0:
+                       else if (error == 0) {
                                close(ctl4);
                                close(ctl6);
                                exit_success("terminating ftp control connection");
                                /*NOTREACHED*/
-                       default:
-                               break;
                        }
                }
                if (FD_ISSET(ctl4, &readfds)) {
@@ -148,16 +143,13 @@
                         */
                        error = ftp_copyresult(ctl4, ctl6, state);
 
-                       switch (error) {
-                       case -1:
+                       if (error < 0)
                                goto bad;
-                       case 0:
+                       else if (error == 0) {
                                close(ctl4);
                                close(ctl6);
                                exit_success("terminating ftp control connection");
                                /*NOTREACHED*/
-                       default:
-                               break;
                        }
                }
                if (0 <= port4 && 0 <= port6 && FD_ISSET(port4, &readfds)) {
@@ -494,6 +486,7 @@
                        n = snprintf(sbuf, sizeof(sbuf),
                                "500 could not translate from PASV\r\n");
                        if (n < 0 || n >= sizeof(sbuf))
+                               n = 0;
                        if (n)
                                write(src, sbuf, n);
                        return n;



Home | Main Index | Thread Index | Old Index