1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-12-03 09:00:21 +00:00

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
This commit is contained in:
Andrey A. Chernov 1996-11-14 05:05:26 +00:00
parent 1e7c9b04ad
commit b92fd90719
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=19727

View File

@ -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;