aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--networking/ftpd.c26
1 files changed, 15 insertions, 11 deletions
diff --git a/networking/ftpd.c b/networking/ftpd.c
index 9a1ea65cc..583d7b387 100644
--- a/networking/ftpd.c
+++ b/networking/ftpd.c
@@ -87,9 +87,8 @@ struct globals {
87 int pasv_listen_fd; 87 int pasv_listen_fd;
88 int proc_self_fd; 88 int proc_self_fd;
89 int local_file_fd; 89 int local_file_fd;
90 int start_time; 90 unsigned end_time;
91 int abs_timeout; 91 unsigned timeout;
92 int timeout;
93 off_t local_file_pos; 92 off_t local_file_pos;
94 off_t restart_pos; 93 off_t restart_pos;
95 len_and_sockaddr *local_addr; 94 len_and_sockaddr *local_addr;
@@ -105,8 +104,9 @@ struct globals {
105}; 104};
106#define G (*(struct globals*)&bb_common_bufsiz1) 105#define G (*(struct globals*)&bb_common_bufsiz1)
107#define INIT_G() do { \ 106#define INIT_G() do { \
108 strcpy(G.msg_ok + 4, MSG_OK ); \ 107 /* Moved to main */ \
109 strcpy(G.msg_err + 4, MSG_ERR); \ 108 /*strcpy(G.msg_ok + 4, MSG_OK );*/ \
109 /*strcpy(G.msg_err + 4, MSG_ERR);*/ \
110} while (0) 110} while (0)
111 111
112 112
@@ -206,7 +206,7 @@ timeout_handler(int sig UNUSED_PARAM)
206 off_t pos; 206 off_t pos;
207 int sv_errno = errno; 207 int sv_errno = errno;
208 208
209 if (monotonic_sec() - G.start_time > G.abs_timeout) 209 if ((int)(monotonic_sec() - G.end_time) >= 0)
210 goto timed_out; 210 goto timed_out;
211 211
212 if (!G.local_file_fd) 212 if (!G.local_file_fd)
@@ -946,25 +946,29 @@ enum {
946int ftpd_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; 946int ftpd_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
947int ftpd_main(int argc, char **argv) 947int ftpd_main(int argc, char **argv)
948{ 948{
949 unsigned abs_timeout;
949 smallint opts; 950 smallint opts;
950 951
951 INIT_G(); 952 INIT_G();
952 953
953 G.start_time = monotonic_sec(); 954 abs_timeout = 1 * 60 * 60;
954 G.abs_timeout = 1 * 60 * 60;
955 G.timeout = 2 * 60; 955 G.timeout = 2 * 60;
956 opt_complementary = "t+:T+"; 956 opt_complementary = "t+:T+";
957 opts = getopt32(argv, "l1vS" USE_FEATURE_FTP_WRITE("w") "t:T:", &G.timeout, &G.abs_timeout); 957 opts = getopt32(argv, "l1vS" USE_FEATURE_FTP_WRITE("w") "t:T:", &G.timeout, &abs_timeout);
958
959 if (opts & (OPT_l|OPT_1)) { 958 if (opts & (OPT_l|OPT_1)) {
960 /* Our secret backdoor to ls */ 959 /* Our secret backdoor to ls */
961 memset(&G, 0, sizeof(G)); 960 memset(&G, 0, sizeof(G));
962/* TODO: pass -n too? */ 961/* TODO: pass -n too? */
962/* --group-directories-first would be nice, but ls don't do that yet */
963 xchdir(argv[2]); 963 xchdir(argv[2]);
964 argv[2] = (char*)"--"; 964 argv[2] = (char*)"--";
965 return ls_main(argc, argv); 965 return ls_main(argc, argv);
966 } 966 }
967 967 G.end_time = monotonic_sec() + abs_timeout;
968 if (G.timeout > abs_timeout)
969 G.timeout = abs_timeout + 1;
970 strcpy(G.msg_ok + 4, MSG_OK );
971 strcpy(G.msg_err + 4, MSG_ERR);
968 972
969 G.local_addr = get_sock_lsa(STDIN_FILENO); 973 G.local_addr = get_sock_lsa(STDIN_FILENO);
970 if (!G.local_addr) { 974 if (!G.local_addr) {