aboutsummaryrefslogtreecommitdiffstats
path: root/ftp.c
diff options
context:
space:
mode:
authorTatsuya Kinoshita <tats@debian.org>2021-01-02 00:20:37 +0000
committerTatsuya Kinoshita <tats@debian.org>2021-01-02 00:20:37 +0000
commit1d0ba25a660483da1272a31dd077ed94441e3d9f (patch)
tree1d8dee52cd1e3d340fe178a8193dc96c4496db84 /ftp.c
parentMerge branch 'cvstrunk' into upstream (diff)
downloadw3m-1d0ba25a660483da1272a31dd077ed94441e3d9f.tar.gz
w3m-1d0ba25a660483da1272a31dd077ed94441e3d9f.zip
New upstream version 0.5.3+git20210102upstream/0.5.3+git20210102upstream
Diffstat (limited to 'ftp.c')
-rw-r--r--ftp.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/ftp.c b/ftp.c
index 0002abd..2ca0247 100644
--- a/ftp.c
+++ b/ftp.c
@@ -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;