projects
/
u
/
mdw
/
putty
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
sbcsgen.pl uses 'select' to point Perl at a different default output
[u/mdw/putty]
/
unix
/
uxsftp.c
diff --git
a/unix/uxsftp.c
b/unix/uxsftp.c
index
a92cfc9
..
57f2841
100644
(file)
--- a/
unix/uxsftp.c
+++ b/
unix/uxsftp.c
@@
-443,7
+443,7
@@
static int ssh_sftp_do_select(int include_stdin, int no_fds_ok)
fd_set rset, wset, xset;
int i, fdcount, fdsize, *fdlist;
int fd, fdstate, rwx, ret, maxfd;
fd_set rset, wset, xset;
int i, fdcount, fdsize, *fdlist;
int fd, fdstate, rwx, ret, maxfd;
- long now = GETTICKCOUNT();
+
unsigned
long now = GETTICKCOUNT();
fdlist = NULL;
fdcount = fdsize = 0;
fdlist = NULL;
fdcount = fdsize = 0;
@@
-489,13
+489,17
@@
static int ssh_sftp_do_select(int include_stdin, int no_fds_ok)
FD_SET_MAX(0, maxfd, rset);
do {
FD_SET_MAX(0, maxfd, rset);
do {
- long next, ticks;
+ unsigned long next, then;
+ long ticks;
struct timeval tv, *ptv;
if (run_timers(now, &next)) {
struct timeval tv, *ptv;
if (run_timers(now, &next)) {
- ticks = next - GETTICKCOUNT();
- if (ticks <= 0)
- ticks = 1; /* just in case */
+ then = now;
+ now = GETTICKCOUNT();
+ if (now - then > next - then)
+ ticks = 0;
+ else
+ ticks = next - now;
tv.tv_sec = ticks / 1000;
tv.tv_usec = ticks % 1000 * 1000;
ptv = &tv;
tv.tv_sec = ticks / 1000;
tv.tv_usec = ticks % 1000 * 1000;
ptv = &tv;
@@
-561,6
+565,7
@@
char *ssh_sftp_get_cmdline(char *prompt, int no_fds_ok)
ret = ssh_sftp_do_select(TRUE, no_fds_ok);
if (ret < 0) {
printf("connection died\n");
ret = ssh_sftp_do_select(TRUE, no_fds_ok);
if (ret < 0) {
printf("connection died\n");
+ sfree(buf);
return NULL; /* woop woop */
}
if (ret > 0) {
return NULL; /* woop woop */
}
if (ret > 0) {
@@
-571,10
+576,12
@@
char *ssh_sftp_get_cmdline(char *prompt, int no_fds_ok)
ret = read(0, buf+buflen, 1);
if (ret < 0) {
perror("read");
ret = read(0, buf+buflen, 1);
if (ret < 0) {
perror("read");
+ sfree(buf);
return NULL;
}
if (ret == 0) {
/* eof on stdin; no error, but no answer either */
return NULL;
}
if (ret == 0) {
/* eof on stdin; no error, but no answer either */
+ sfree(buf);
return NULL;
}
return NULL;
}