1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-03-22 06:38:37 -05:00

Call ssh_check_frozen when BPP consumes input.

In commit 0f405ae8a, I arranged to stop reading from the SSH
connection if the in_raw bufchain got too big. But in at least some
tools (this bit me just now with PSCP), nothing actually calls
ssh_check_frozen again when the bufchain clears, so it stays frozen.

Now ssh_check_frozen is non-static, and all the BPP implementations
call it whenever they consume data from ssh->in_raw.
This commit is contained in:
Simon Tatham 2019-02-17 19:06:03 +00:00
parent 85550641d7
commit 5bc6db4b96
7 changed files with 10 additions and 1 deletions

2
ssh.c
View File

@ -317,7 +317,7 @@ static void ssh_got_ssh_version(struct ssh_version_receiver *rcv,
ssh_bpp_free(old_bpp); ssh_bpp_free(old_bpp);
} }
static void ssh_check_frozen(Ssh *ssh) void ssh_check_frozen(Ssh *ssh)
{ {
if (!ssh->s) if (!ssh->s)
return; return;

1
ssh.h
View File

@ -380,6 +380,7 @@ void ssh_got_fallback_cmd(Ssh *ssh);
/* Communications back to ssh.c from the BPP */ /* Communications back to ssh.c from the BPP */
void ssh_conn_processed_data(Ssh *ssh); void ssh_conn_processed_data(Ssh *ssh);
void ssh_check_frozen(Ssh *ssh);
/* Functions to abort the connection, for various reasons. */ /* Functions to abort the connection, for various reasons. */
void ssh_remote_error(Ssh *ssh, const char *fmt, ...); void ssh_remote_error(Ssh *ssh, const char *fmt, ...);

View File

@ -124,6 +124,7 @@ void ssh1_bpp_start_compression(BinaryPacketProtocol *bpp)
s->bpp.input_eof); \ s->bpp.input_eof); \
if (!success) \ if (!success) \
goto eof; \ goto eof; \
ssh_check_frozen(s->bpp.ssh); \
} while (0) } while (0)
static void ssh1_bpp_handle_input(BinaryPacketProtocol *bpp) static void ssh1_bpp_handle_input(BinaryPacketProtocol *bpp)

View File

@ -59,6 +59,7 @@ static void ssh2_bare_bpp_free(BinaryPacketProtocol *bpp)
s->bpp.input_eof); \ s->bpp.input_eof); \
if (!success) \ if (!success) \
goto eof; \ goto eof; \
ssh_check_frozen(s->bpp.ssh); \
} while (0) } while (0)
static void ssh2_bare_bpp_handle_input(BinaryPacketProtocol *bpp) static void ssh2_bare_bpp_handle_input(BinaryPacketProtocol *bpp)

View File

@ -269,6 +269,7 @@ static void ssh2_bpp_enable_pending_compression(struct ssh2_bpp_state *s)
s->bpp.input_eof); \ s->bpp.input_eof); \
if (!success) \ if (!success) \
goto eof; \ goto eof; \
ssh_check_frozen(s->bpp.ssh); \
} while (0) } while (0)
#define userauth_range(pkttype) ((unsigned)((pkttype) - 50) < 20) #define userauth_range(pkttype) ((unsigned)((pkttype) - 50) < 20)

View File

@ -76,6 +76,7 @@ void share_setup_x11_channel(ssh_sharing_connstate *cs, share_channel *chan,
Channel *agentf_new(SshChannel *c) { return NULL; } Channel *agentf_new(SshChannel *c) { return NULL; }
bool agent_exists(void) { return false; } bool agent_exists(void) { return false; }
void ssh_got_exitcode(Ssh *ssh, int exitcode) {} void ssh_got_exitcode(Ssh *ssh, int exitcode) {}
void ssh_check_frozen(Ssh *ssh) {}
mainchan *mainchan_new( mainchan *mainchan_new(
PacketProtocolLayer *ppl, ConnectionLayer *cl, Conf *conf, PacketProtocolLayer *ppl, ConnectionLayer *cl, Conf *conf,

View File

@ -242,6 +242,7 @@ void ssh_verstring_handle_input(BinaryPacketProtocol *bpp)
bufchain_fetch(s->bpp.in_raw, s->prefix, s->prefix_wanted.len); bufchain_fetch(s->bpp.in_raw, s->prefix, s->prefix_wanted.len);
if (!memcmp(s->prefix, s->prefix_wanted.ptr, s->prefix_wanted.len)) { if (!memcmp(s->prefix, s->prefix_wanted.ptr, s->prefix_wanted.len)) {
bufchain_consume(s->bpp.in_raw, s->prefix_wanted.len); bufchain_consume(s->bpp.in_raw, s->prefix_wanted.len);
ssh_check_frozen(s->bpp.ssh);
break; break;
} }
@ -258,9 +259,11 @@ void ssh_verstring_handle_input(BinaryPacketProtocol *bpp)
data = bufchain_prefix(s->bpp.in_raw); data = bufchain_prefix(s->bpp.in_raw);
if ((nl = memchr(data.ptr, '\012', data.len)) != NULL) { if ((nl = memchr(data.ptr, '\012', data.len)) != NULL) {
bufchain_consume(s->bpp.in_raw, nl - (char *)data.ptr + 1); bufchain_consume(s->bpp.in_raw, nl - (char *)data.ptr + 1);
ssh_check_frozen(s->bpp.ssh);
break; break;
} else { } else {
bufchain_consume(s->bpp.in_raw, data.len); bufchain_consume(s->bpp.in_raw, data.len);
ssh_check_frozen(s->bpp.ssh);
} }
} }
} }
@ -298,6 +301,7 @@ void ssh_verstring_handle_input(BinaryPacketProtocol *bpp)
memcpy(s->vstring + s->vslen, data.ptr, data.len); memcpy(s->vstring + s->vslen, data.ptr, data.len);
s->vslen += data.len; s->vslen += data.len;
bufchain_consume(s->bpp.in_raw, data.len); bufchain_consume(s->bpp.in_raw, data.len);
ssh_check_frozen(s->bpp.ssh);
} while (s->vstring[s->vslen-1] != '\012'); } while (s->vstring[s->vslen-1] != '\012');