[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: libssh and python twisted conch ssh
[Thread Prev] | [Thread Next]
- Subject: Re: libssh and python twisted conch ssh
- From: Johannes Krude <johannes@xxxxxxxx>
- Reply-to: libssh@xxxxxxxxxx
- Date: Tue, 22 Jan 2013 13:12:34 +0100
- To: libssh@xxxxxxxxxx
hi, On Tue, Jan 22, 2013 at 10:57:22AM +0100, Aris Adamantiadis wrote: > I took a look at your pcap (next time please just attach it :)). > It seems like twisted sends the key exchange packet right away before > listening for the client's banner. > As the packet is already buffered, the packet parsing is never triggered > because it's waiting for socket input first. The following fixes this behavior by repeatedly calling the data handler as long as it takes data (https://git.aachen.ccc.de/~johannes/libssh/). johannes diff --git a/src/socket.c b/src/socket.c index 6eab0aa..8569054 100644 --- a/src/socket.c +++ b/src/socket.c @@ -283,12 +283,15 @@ int ssh_socket_pollcallback(struct ssh_poll_handle_struct *p, socket_t fd, int r return -1; } if(s->callbacks && s->callbacks->data){ - r= s->callbacks->data(buffer_get_rest(s->in_buffer), - buffer_get_rest_len(s->in_buffer), - s->callbacks->userdata); - buffer_pass_bytes(s->in_buffer,r); - /* p may have been freed, so don't use it - * anymore in this function */ + r= 1; + while (r > 0) { + r= s->callbacks->data(buffer_get_rest(s->in_buffer), + buffer_get_rest_len(s->in_buffer), + s->callbacks->userdata); + buffer_pass_bytes(s->in_buffer,r); + /* p may have been freed, so don't use it + * anymore in this function */ + } p = NULL; } }
Re: libssh and python twisted conch ssh | Aris Adamantiadis <aris@xxxxxxxxxxxx> |
libssh and python twisted conch ssh | Johannes Krude <johannes@xxxxxxxx> |
Re: libssh and python twisted conch ssh | Aris Adamantiadis <aris@xxxxxxxxxxxx> |