X-Git-Url: https://git.distorted.org.uk/u/mdw/putty/blobdiff_plain/9c41b8ea363252c09541b8bc9a81db93237aacb2..9853b9125c142b77f583aa4736733728c37d0bea:/scp.c diff --git a/scp.c b/scp.c index b831fbbf..03bdfbc9 100644 --- a/scp.c +++ b/scp.c @@ -53,13 +53,12 @@ static int statistics = 1; static int portnumber = 0; static char *password = NULL; static int errs = 0; -static int connection_open = 0; /* GUI Adaptation - Sept 2000 */ #define NAME_STR_MAX 2048 static char statname[NAME_STR_MAX+1]; static unsigned long statsize = 0; static int statperct = 0; -static time_t statelapsed = 0; +static unsigned long statelapsed = 0; static int gui_mode = 0; static char *gui_hwnd = NULL; @@ -72,7 +71,8 @@ static void tell_str(FILE *stream, char *str); static void tell_user(FILE *stream, char *fmt, ...); static void send_char_msg(unsigned int msg_id, char c); static void send_str_msg(unsigned int msg_id, char *str); -static void gui_update_stats(char *name, unsigned long size, int percentage, time_t elapsed); +static void gui_update_stats(char *name, unsigned long size, + int percentage, unsigned long elapsed); void begin_session(void) { } void logevent(char *string) { } @@ -183,7 +183,7 @@ static void tell_user(FILE *stream, char *fmt, ...) tell_str(stream, str); } -static void gui_update_stats(char *name, unsigned long size, int percentage, time_t elapsed) +static void gui_update_stats(char *name, unsigned long size, int percentage, unsigned long elapsed) { unsigned int i; @@ -377,7 +377,7 @@ static void bump(char *fmt, ...) strcat(str, "\n"); tell_str(stderr, str); - if (connection_open) { + if (back->socket() != NULL) { char ch; back->special(TS_EOF); ssh_scp_recv(&ch, 1); @@ -476,8 +476,6 @@ static void do_cmd(char *host, char *user, char *cmd) ssh_scp_init(); if (verbose && realhost != NULL) tell_user(stderr, "Connected to %s\n", realhost); - - connection_open = 1; } /* @@ -493,7 +491,8 @@ static void print_stats(char *name, unsigned long size, unsigned long done, /* GUI Adaptation - Sept 2000 */ if (gui_mode) - gui_update_stats(name, size, ((done *100) / size), now-start); + gui_update_stats(name, size, (int)(100 * (done*1.0/size)), + (unsigned long)difftime(now, start)); else { if (now > start) ratebs = (float) done / (now - start); @@ -829,12 +828,6 @@ static void sink(char *targ, char *src) if (sscanf(buf+1, "%u %lu %[^\n]", &mode, &size, namebuf) != 3) bump("Protocol error: Illegal file descriptor format"); /* Security fix: ensure the file ends up where we asked for it. */ - if (src) { - char *p = src + strlen(src); - while (p > src && p[-1] != '/' && p[-1] != '\\') - p--; - strcpy(namebuf, p); - } if (targisdir) { char t[2048]; char *p; @@ -1235,7 +1228,7 @@ int main(int argc, char *argv[]) tolocal(argc, argv); } - if (connection_open) { + if (back->socket() != NULL) { char ch; back->special(TS_EOF); ssh_scp_recv(&ch, 1);