diff options
author | ache <ache@FreeBSD.org> | 1996-11-14 05:05:26 +0000 |
---|---|---|
committer | ache <ache@FreeBSD.org> | 1996-11-14 05:05:26 +0000 |
commit | 29f75dec4a8b66e99954aa640d38b14d4013e4b3 (patch) | |
tree | 943606069ff025761cee03ad8894b4a23f7f7719 /lib/libftpio | |
parent | 76176371e0be8ba2aa9a0d55063bdabc84fcbf46 (diff) | |
download | FreeBSD-src-29f75dec4a8b66e99954aa640d38b14d4013e4b3.zip FreeBSD-src-29f75dec4a8b66e99954aa640d38b14d4013e4b3.tar.gz |
1) Don't allow endless recursion in ftp_close when it attempts to
send QUIT to closed connection.
2) Preserve login failure code, don't overwrite it with ftp_close
code
Should go to 2.2
Diffstat (limited to 'lib/libftpio')
-rw-r--r-- | lib/libftpio/ftpio.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/lib/libftpio/ftpio.c b/lib/libftpio/ftpio.c index 578d5b7..1fe8537 100644 --- a/lib/libftpio/ftpio.c +++ b/lib/libftpio/ftpio.c @@ -14,7 +14,7 @@ * Turned inside out. Now returns xfers as new file ids, not as a special * `state' of FTP_t * - * $Id: ftpio.c,v 1.14 1996/09/19 17:28:26 peter Exp $ + * $Id: ftpio.c,v 1.15 1996/10/10 08:34:27 jkh Exp $ * */ @@ -540,17 +540,21 @@ static int ftp_close(FTP_t ftp) { int i; + static int recursive = 0; - if (ftp->con_state == isopen) { + if (!recursive && ftp->con_state == isopen) { /* Debug("ftp_pkg: in ftp_close(), sending QUIT"); */ + recursive = 1; i = cmd(ftp, "QUIT"); close(ftp->fd_ctrl); ftp->fd_ctrl = -1; ftp->con_state = init; if (check_code(ftp, i, FTP_QUIT_HAPPY)) { + recursive = 0; ftp->errno = i; return FAILURE; } + recursive = 0; /* Debug("ftp_pkg: ftp_close() - proper shutdown"); */ return SUCCESS; } @@ -647,6 +651,8 @@ ftp_login_session(FTP_t ftp, char *host, char *user, char *passwd, int port, int i = cmd(ftp, "PASS %s", passwd); if (i >= 299 || i < 0) { ftp_close(ftp); + if (i > 0) + ftp->errno = i; return FAILURE; } return SUCCESS; |