diff options
author | Tatsuya Kinoshita <tats@debian.org> | 2015-08-11 13:05:46 +0000 |
---|---|---|
committer | Tatsuya Kinoshita <tats@debian.org> | 2015-08-11 13:05:46 +0000 |
commit | af52480aabcb700c9bf68989a5e6c648d22f9945 (patch) | |
tree | 17ee2ecab281cfb16d0a622d7adf6ae4ce385cfa /ftp.c | |
parent | Update ChangeLog (diff) | |
parent | Check for presence of prevl before using (diff) | |
download | w3m-af52480aabcb700c9bf68989a5e6c648d22f9945.tar.gz w3m-af52480aabcb700c9bf68989a5e6c648d22f9945.zip |
Merge branch 'bug/sw3m'
Diffstat (limited to 'ftp.c')
-rw-r--r-- | ftp.c | 8 |
1 files changed, 6 insertions, 2 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) @@ -139,7 +140,6 @@ ftp_login(FTP ftp) socklen_t socknamelen = sizeof(sockname); if (!getsockname(sock, (struct sockaddr *)&sockname, &socknamelen)) { - struct hostent *sockent; Str tmp = Strnew_charp(ftp->pass); #ifdef INET6 char hostbuf[NI_MAXHOST]; @@ -156,6 +156,7 @@ ftp_login(FTP ftp) Strcat_charp(tmp, "unknown"); #else + struct hostent *sockent; if ((sockent = gethostbyaddr((char *)&sockname.sin_addr, sizeof(sockname.sin_addr), sockname.sin_family))) @@ -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; |