diff options
author | Denis Vlasenko <vda.linux@googlemail.com> | 2006-12-22 00:21:07 +0000 |
---|---|---|
committer | Denis Vlasenko <vda.linux@googlemail.com> | 2006-12-22 00:21:07 +0000 |
commit | 714701c890b5f03253c5ecdb7367c4258ce78715 (patch) | |
tree | 7ddaf73cf2deda0f357b21802dab4d42798dd778 /networking/ftpgetput.c | |
parent | 0a8a7741795880201bcf78231d1eab0e2538bb0b (diff) | |
download | busybox-w32-714701c890b5f03253c5ecdb7367c4258ce78715.tar.gz busybox-w32-714701c890b5f03253c5ecdb7367c4258ce78715.tar.bz2 busybox-w32-714701c890b5f03253c5ecdb7367c4258ce78715.zip |
tar et al: die if bb_copyfd_size copies less than asked for.
(we have bb_copyfd_exact_size now for that kind of usage)
Diffstat (limited to 'networking/ftpgetput.c')
-rw-r--r-- | networking/ftpgetput.c | 29 |
1 files changed, 14 insertions, 15 deletions
diff --git a/networking/ftpgetput.c b/networking/ftpgetput.c index dff894468..9d054428f 100644 --- a/networking/ftpgetput.c +++ b/networking/ftpgetput.c | |||
@@ -22,8 +22,8 @@ typedef struct ftp_host_info_s { | |||
22 | struct sockaddr_in *s_in; | 22 | struct sockaddr_in *s_in; |
23 | } ftp_host_info_t; | 23 | } ftp_host_info_t; |
24 | 24 | ||
25 | static char verbose_flag = 0; | 25 | static char verbose_flag; |
26 | static char do_continue = 0; | 26 | static char do_continue; |
27 | 27 | ||
28 | static int ftpcmd(const char *s1, const char *s2, FILE *stream, char *buf) | 28 | static int ftpcmd(const char *s1, const char *s2, FILE *stream, char *buf) |
29 | { | 29 | { |
@@ -112,7 +112,9 @@ int ftp_receive(ftp_host_info_t *server, FILE *control_stream, | |||
112 | const char *local_path, char *server_path) | 112 | const char *local_path, char *server_path) |
113 | { | 113 | { |
114 | char buf[512]; | 114 | char buf[512]; |
115 | off_t filesize = 0; | 115 | /* I think 'filesize' usage here is bogus. Let's see... */ |
116 | //off_t filesize = -1; | ||
117 | #define filesize ((off_t)-1) | ||
116 | int fd_data; | 118 | int fd_data; |
117 | int fd_local = -1; | 119 | int fd_local = -1; |
118 | off_t beg_range = 0; | 120 | off_t beg_range = 0; |
@@ -124,11 +126,10 @@ int ftp_receive(ftp_host_info_t *server, FILE *control_stream, | |||
124 | fd_data = xconnect_ftpdata(server, buf); | 126 | fd_data = xconnect_ftpdata(server, buf); |
125 | 127 | ||
126 | if (ftpcmd("SIZE ", server_path, control_stream, buf) == 213) { | 128 | if (ftpcmd("SIZE ", server_path, control_stream, buf) == 213) { |
127 | filesize = BB_STRTOOFF(buf + 4, NULL, 10); | 129 | //filesize = BB_STRTOOFF(buf + 4, NULL, 10); |
128 | if (errno || filesize < 0) | 130 | //if (errno || filesize < 0) |
129 | bb_error_msg_and_die("SIZE error: %s", buf + 4); | 131 | // bb_error_msg_and_die("SIZE error: %s", buf + 4); |
130 | } else { | 132 | } else { |
131 | filesize = -1; | ||
132 | do_continue = 0; | 133 | do_continue = 0; |
133 | } | 134 | } |
134 | 135 | ||
@@ -154,7 +155,8 @@ int ftp_receive(ftp_host_info_t *server, FILE *control_stream, | |||
154 | if (ftpcmd(buf, NULL, control_stream, buf) != 350) { | 155 | if (ftpcmd(buf, NULL, control_stream, buf) != 350) { |
155 | do_continue = 0; | 156 | do_continue = 0; |
156 | } else { | 157 | } else { |
157 | filesize -= beg_range; | 158 | //if (filesize != -1) |
159 | // filesize -= beg_range; | ||
158 | } | 160 | } |
159 | } | 161 | } |
160 | 162 | ||
@@ -173,11 +175,11 @@ int ftp_receive(ftp_host_info_t *server, FILE *control_stream, | |||
173 | 175 | ||
174 | /* Copy the file */ | 176 | /* Copy the file */ |
175 | if (filesize != -1) { | 177 | if (filesize != -1) { |
176 | if (-1 == bb_copyfd_size(fd_data, fd_local, filesize)) | 178 | if (bb_copyfd_size(fd_data, fd_local, filesize) == -1) |
177 | exit(EXIT_FAILURE); | 179 | return EXIT_FAILURE; |
178 | } else { | 180 | } else { |
179 | if (-1 == bb_copyfd_eof(fd_data, fd_local)) | 181 | if (bb_copyfd_eof(fd_data, fd_local) == -1) |
180 | exit(EXIT_FAILURE); | 182 | return EXIT_FAILURE; |
181 | } | 183 | } |
182 | 184 | ||
183 | /* close it all down */ | 185 | /* close it all down */ |
@@ -277,14 +279,11 @@ int ftpgetput_main(int argc, char **argv) | |||
277 | /* content-length of the file */ | 279 | /* content-length of the file */ |
278 | unsigned opt; | 280 | unsigned opt; |
279 | char *port = "ftp"; | 281 | char *port = "ftp"; |
280 | |||
281 | /* socket to ftp server */ | 282 | /* socket to ftp server */ |
282 | FILE *control_stream; | 283 | FILE *control_stream; |
283 | struct sockaddr_in s_in; | 284 | struct sockaddr_in s_in; |
284 | |||
285 | /* continue a prev transfer (-c) */ | 285 | /* continue a prev transfer (-c) */ |
286 | ftp_host_info_t *server; | 286 | ftp_host_info_t *server; |
287 | |||
288 | int (*ftp_action)(ftp_host_info_t *, FILE *, const char *, char *) = NULL; | 287 | int (*ftp_action)(ftp_host_info_t *, FILE *, const char *, char *) = NULL; |
289 | 288 | ||
290 | /* Check to see if the command is ftpget or ftput */ | 289 | /* Check to see if the command is ftpget or ftput */ |