dup can give a negative value

This commit is contained in:
David Crosby
2015-07-21 22:49:33 -06:00
committed by Tatsuya Kinoshita
parent a00c90930b
commit 73550486ff

6
ftp.c
View File

@@ -123,6 +123,7 @@ static int
ftp_login(FTP ftp)
{
int sock, status;
int sock_wf;
sock = openSocket(ftp->host, "ftp", 21);
if (sock < 0)
@@ -169,7 +170,10 @@ ftp_login(FTP ftp)
}
}
ftp->rf = newInputStream(sock);
ftp->wf = fdopen(dup(sock), "wb");
if ((sock_wf = dup(sock)) >= 0 )
ftp->wf = fdopen(sock_wf, "wb");
else
goto open_err;
if (!ftp->rf || !ftp->wf)
goto open_err;
IStype(ftp->rf) |= IST_UNCLOSE;