aboutsummaryrefslogtreecommitdiff
path: root/toys/pending/ftpget.c
diff options
context:
space:
mode:
authorAshwini Sharma <ak.ashwini1981@gmail.com>2014-08-12 07:09:01 -0500
committerAshwini Sharma <ak.ashwini1981@gmail.com>2014-08-12 07:09:01 -0500
commit7eb3e4364c2bcebd2fdfef52c07f5101aa03e5bb (patch)
tree3a71927fe5198488d24af53b030d71797b67de35 /toys/pending/ftpget.c
parent6a77734d1b1ac1938abbc33014b60cfb49828824 (diff)
downloadtoybox-7eb3e4364c2bcebd2fdfef52c07f5101aa03e5bb.tar.gz
Patches to commands for issues reported from static analysis tool.
portability.h.patch - it is for O_CLOEXEC, as compiler complained of it. Makefile.patch - for cleaning generated/*.o files and libopts.dat file [Fixup to uniq.c from Rob.]
Diffstat (limited to 'toys/pending/ftpget.c')
-rw-r--r--toys/pending/ftpget.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/toys/pending/ftpget.c b/toys/pending/ftpget.c
index a68ceeb6..2a81a34a 100644
--- a/toys/pending/ftpget.c
+++ b/toys/pending/ftpget.c
@@ -153,21 +153,29 @@ static void verify_pasv_mode(char *r_filename)
unsigned portnum;
//vsftpd reply like:- "227 Entering Passive Mode (125,19,39,117,43,39)".
- if (get_ftp_response("PASV", NULL) != PASSIVE_MODE) close_stream("PASV");
+ if (get_ftp_response("PASV", NULL) != PASSIVE_MODE) goto close_stream;
//Response is "NNN <some text> (N1,N2,N3,N4,P1,P2) garbage.
//Server's IP is N1.N2.N3.N4
//Server's port for data connection is P1*256+P2.
- if ((pch = strrchr(toybuf, ')'))) *pch = '\0';
- if ((pch = strrchr(toybuf, ','))) *pch = '\0';
+ if (!(pch = strrchr(toybuf, ')'))) goto close_stream;
+ *pch = '\0';
+ if (!(pch = strrchr(toybuf, ','))) goto close_stream;
+ *pch = '\0';
+
portnum = atolx_range(pch + 1, 0, 255);
- if ((pch = strrchr(toybuf, ','))) *pch = '\0';
+ if (!(pch = strrchr(toybuf, ','))) goto close_stream;
+ *pch = '\0';
portnum = portnum + (atolx_range(pch + 1, 0, 255) * 256);
setport(htons(portnum));
if (TT.isget && get_ftp_response("SIZE", r_filename) != FTPFILE_STATUS)
TT.c = 0;
+ return;
+
+close_stream:
+ close_stream("PASV");
}
/*