From 73550486ffc0d7bae2b62ac49c879354aa977eff Mon Sep 17 00:00:00 2001 From: David Crosby Date: Tue, 21 Jul 2015 22:49:33 -0600 Subject: dup can give a negative value --- ftp.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'ftp.c') diff --git a/ftp.c b/ftp.c index 0002abd..2ad829c 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) @@ -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; -- cgit v1.2.3 From 14798c25c4bd58fcd906eac7a2df4578b00056ef Mon Sep 17 00:00:00 2001 From: David Crosby Date: Sun, 26 Jul 2015 00:08:52 -0600 Subject: Move sockent for splint --- ftp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'ftp.c') diff --git a/ftp.c b/ftp.c index 2ad829c..2ca0247 100644 --- a/ftp.c +++ b/ftp.c @@ -140,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]; @@ -157,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))) -- cgit v1.2.3