Files
libssh/src
Jon Simons 95782ada1f socket: fix read of non-connected socket
Ensure to check whether the socket at hand is indeed still connected
throughout POLLIN processing in ssh_socket_pollcallback.

Before this change, the POLLIN block in ssh_socket_pollcallback is
predicated against the condition (s->state == SSH_SOCKET_CONNECTED).
Once entered, data from the socket is consumed through the data
callback in this loop:

  do {
    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);
  } while (r > 0);

However, it is possible for the socket data callback to change the
state of the socket (closing it, for example).  Fix the loop to only
continue so long as the socket remains connected: this also entails
setting the ssh_socket state to SSH_SOCKET_CLOSED upon close.

The bug can be observed before the change by sending a bogus banner
to the server: 'echo -e "A\r\nB\r\n" | nc localhost 22'.  Each of
'A' and 'B' will be processed by 'callback_receive_banner', even
though the client socket is closed after rejection of 'A'.

Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2014-02-02 22:19:46 +01:00
..
2012-03-09 18:14:13 +01:00
2014-01-07 16:08:23 +01:00
2014-01-07 16:08:23 +01:00
2011-09-18 21:37:17 +02:00
2014-01-23 11:21:51 +01:00
2014-01-07 15:18:15 +01:00
2014-01-07 15:18:15 +01:00
2011-05-01 19:42:50 +02:00
2014-02-02 20:50:36 +01:00
2014-01-16 15:27:46 +01:00
2013-10-18 23:22:24 +02:00
2012-10-05 11:22:15 +02:00
2014-01-07 15:18:15 +01:00
2012-10-09 11:09:34 +02:00
2014-01-07 16:08:23 +01:00
2014-01-07 16:08:23 +01:00
2014-01-08 18:57:31 +01:00
2014-01-07 15:18:15 +01:00