ssh_packet_next(): after a kex callback has been called we need to

get the next packet, too. otherwise we end up waiting for input
even if there is a packet ready. the same applies to the proxy
This commit is contained in:
Markus Friedl
2012-02-07 23:54:56 +01:00
parent 1edbfe0a1b
commit 91fa188bfb
2 changed files with 24 additions and 16 deletions

View File

@@ -282,9 +282,13 @@ ssh_packet_fwd(struct side *from, struct side *to)
if (!from->ssh || !to->ssh)
return 0;
if ((ret = ssh_packet_next(from->ssh, &type)) != 0)
return ret;
if (type) {
for (;;) {
if ((ret = ssh_packet_next(from->ssh, &type)) != 0)
return ret;
if (!type) {
debug3("no packet on %d", from->fd);
break;
}
data = ssh_packet_payload(from->ssh, &len);
debug("ssh_packet_fwd %d->%d type %d len %d",
from->fd, to->fd, type, len);
@@ -302,8 +306,6 @@ ssh_packet_fwd(struct side *from, struct side *to)
}
if ((ret = ssh_packet_put(to->ssh, type, data, len)) != 0)
return ret;
} else {
debug3("no packet on %d", from->fd);
}
ssh_output_ptr(from->ssh, &len);
if (len) {

View File

@@ -196,24 +196,30 @@ ssh_packet_next(struct ssh *ssh, u_char *typep)
if (ssh->kex->client_version_string == NULL ||
ssh->kex->server_version_string == NULL)
return _ssh_exchange_banner(ssh);
if ((r = ssh_packet_read_poll2(ssh, &type, &seqnr)) != 0)
return r;
/*
* If we enough data and we have a dispatch function, call the
* function and return SSH_MSG_NONE. Otherwise return the packet type to
* the caller so it can decide how to go on.
* If we enough data and a dispatch function then
* call the function and get the next packet.
* Otherwise return the packet type to the caller so it
* can decide how to go on.
*
* We will only call the dispatch function for:
* 20-29 Algorithm negotiation
* 30-49 Key exchange method specific (numbers can be reused for
* different authentication methods)
*/
if (type > 0 && type < DISPATCH_MAX &&
type >= SSH2_MSG_KEXINIT && type <= SSH2_MSG_TRANSPORT_MAX &&
ssh->dispatch[type] != NULL)
return (*ssh->dispatch[type])(type, seqnr, ssh);
*typep = type;
return 0;
for (;;) {
if ((r = ssh_packet_read_poll2(ssh, &type, &seqnr)) != 0)
return r;
if (type > 0 && type < DISPATCH_MAX &&
type >= SSH2_MSG_KEXINIT && type <= SSH2_MSG_TRANSPORT_MAX &&
ssh->dispatch[type] != NULL) {
if ((r = (*ssh->dispatch[type])(type, seqnr, ssh)) != 0)
return r;
} else {
*typep = type;
return 0;
}
}
}
void *