diff options
author | Jun-ichiro itojun Hagino <itojun@cvs.openbsd.org> | 2002-06-24 06:06:26 +0000 |
---|---|---|
committer | Jun-ichiro itojun Hagino <itojun@cvs.openbsd.org> | 2002-06-24 06:06:26 +0000 |
commit | 2b11b5cf243d9416a399706f163529ad2878a5df (patch) | |
tree | eff10e9502a16387689545c9bca960688a69c704 | |
parent | 91c15ddf69b19387a9debe23e3defdafb9a43c97 (diff) |
correct ftp relay functionality.
-rw-r--r-- | usr.sbin/faithd/ftp.c | 33 | ||||
-rw-r--r-- | usr.sbin/faithd/prefix.c | 8 |
2 files changed, 15 insertions, 26 deletions
diff --git a/usr.sbin/faithd/ftp.c b/usr.sbin/faithd/ftp.c index 5d1142af7aa..e22e03d5dda 100644 --- a/usr.sbin/faithd/ftp.c +++ b/usr.sbin/faithd/ftp.c @@ -1,5 +1,5 @@ -/* $OpenBSD: ftp.c,v 1.8 2002/06/07 00:18:05 itojun Exp $ */ -/* $KAME: ftp.c,v 1.14 2002/04/24 08:17:23 itojun Exp $ */ +/* $OpenBSD: ftp.c,v 1.9 2002/06/24 06:06:25 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 @@ ftp_relay(int ctl6, int ctl4) 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 @@ ftp_relay(int ctl6, int ctl4) */ 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 @@ ftp_relay(int ctl6, int ctl4) */ 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 @@ passivefail: 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; diff --git a/usr.sbin/faithd/prefix.c b/usr.sbin/faithd/prefix.c index a8689c5a34b..927011c1b4d 100644 --- a/usr.sbin/faithd/prefix.c +++ b/usr.sbin/faithd/prefix.c @@ -1,5 +1,5 @@ -/* $OpenBSD: prefix.c,v 1.4 2002/02/16 21:28:02 millert Exp $ */ -/* $KAME: prefix.c,v 1.9 2001/07/02 14:36:49 itojun Exp $ */ +/* $OpenBSD: prefix.c,v 1.5 2002/06/24 06:06:25 itojun Exp $ */ +/* $KAME: prefix.c,v 1.11 2001/11/13 12:38:45 jinmei Exp $ */ /* * Copyright (C) 2000 WIDE Project. @@ -55,11 +55,7 @@ static void config_show(void); #endif struct config *config_list = NULL; -#ifdef NI_WITHSCOPEID -const int niflags = NI_NUMERICHOST | NI_WITHSCOPEID; -#else const int niflags = NI_NUMERICHOST; -#endif static int prefix_set(s, prefix, slash) |