diff options
author | David Crosby <dave@dafyddcrosby.com> | 2015-07-22 04:49:33 +0000 |
---|---|---|
committer | Tatsuya Kinoshita <tats@debian.org> | 2015-08-11 12:59:27 +0000 |
commit | 73550486ffc0d7bae2b62ac49c879354aa977eff (patch) | |
tree | 704fa628e7f8f6bd3e6d523104219c75a8f0d1fe | |
parent | use int for c (diff) | |
download | w3m-73550486ffc0d7bae2b62ac49c879354aa977eff.tar.gz w3m-73550486ffc0d7bae2b62ac49c879354aa977eff.zip |
dup can give a negative value
Diffstat (limited to '')
-rw-r--r-- | ftp.c | 6 |
1 files changed, 5 insertions, 1 deletions
@@ -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; |