summaryrefslogtreecommitdiffstats
path: root/src/socket.c
Commit message (Collapse)AuthorAgeFilesLines
* Add session/channel byte/packet countersAudrius Butkevicius2014-02-121-0/+6
| | | | Signed-off-by: Audrius Butkevicius <audrius.butkevicius@elastichosts.com>
* socket: fix read of non-connected socketJon Simons2014-02-021-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* src: Define MAX_BUF_SIZE globally and use it.Joseph Southwell2014-02-021-1/+1
| | | | Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
* src: Rename buffer_add_data() to ssh_buffer_add_data().Andreas Schneider2014-01-191-2/+2
|
* src: Rename buffer_init to ssh_buffer_init().Andreas Schneider2014-01-191-2/+2
|
* src: Do not use deprecated functions.Andreas Schneider2014-01-161-2/+2
|
* socket: don't attempt reading a non-connected socketAris Adamantiadis2014-01-051-1/+1
|
* sockets: null pointer checkAris Adamantiadis2013-11-181-5/+7
|
* socket: Fix connect if we pass in a fd.Andreas Schneider2013-11-151-9/+13
| | | | | | BUG: https://red.libssh.org/issues/106 Thanks to Saju Panikulam.
* Add ssh_get_poll_flags()Colin Walters2013-11-091-0/+11
| | | | | | | | | | For integration with an external mainloop, we need to know how to replicate libssh's internal poll() calls. We originally through ssh_get_status() was that API, but it's not really - those flags only get updated from the *result* of a poll(), where what we really need is to know how libssh would *start* a poll(). Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
* socket: Fix check for pending data.Aris Adamantiadis2013-11-031-3/+3
| | | | | | BUG: https://red.libssh.org/issues/119 Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
* src: Remove enter_function() and leave_function().Andreas Schneider2013-07-141-16/+8
|
* src: Migrate to SSH_LOG.Andreas Schneider2013-07-141-5/+5
|
* socket: Check if socket (non)blocking is working.Andreas Schneider2013-06-171-9/+12
|
* socket: Check return value of getsockopt().Andreas Schneider2013-06-171-1/+4
|
* socket: Call data handler as long as handler takes data.Johannes Krude2013-01-291-4/+6
| | | | Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
* socket: Check return value of buffer function.Andreas Schneider2012-10-091-1/+4
| | | | Found by Coverity.
* socket: Add a SSH_WRITE_PENDING socket status.Andreas Schneider2012-07-171-0/+4
|
* socket: Move socket function to right location.Andreas Schneider2011-09-181-1/+22
|
* channels: Fix checking for fatal errors.rofl0r2011-08-061-18/+20
| | | | We need this that we don't end up in and infinite poll loop.
* Fix "connecting to closed port" on MacosXAris Adamantiadis2011-05-201-1/+1
|
* socket: Fixed use-after-free.Oliver Stöneberg2011-05-171-0/+6
| | | | | When s->callbacks->exception() was called in ssh_socket_pollcallback() we had a use after free bug.
* [socket] fix a segfault at disconnectmilo2011-05-021-4/+15
| | | | (cherry picked from commit 56394917b15e41603c641c22a4e29c33b096d673)
* init: Some initialization fixes.Oliver Stöneberg2011-05-011-6/+18
| | | | | | | | - Check result of ssh_init() in privatekey_from_base64() - Moved code from ssh_finalize() to appropriate subroutines - Only initialize sockets once (caused mismatch of WSAStartup() and WSACleanup() calls and potential usage of bsd_poll when win_poll should be used)
* socket: Fixed poll input event.Oliver Stöneberg2011-05-011-1/+1
|
* poll: Fix poll input events.Andreas Schneider2011-04-151-1/+1
| | | | bug#38
* build: Fixed some VS2010 problems.Oliver Stöneberg2011-04-111-1/+1
|
* Implement ssh_blocking_flush()Aris Adamantiadis2011-03-221-0/+12
| | | | Based on code from Jan Willamowius
* socket: Set errors on return.Bernhard R. Link2011-02-141-1/+16
| | | | Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
* Fix use-after-free when socket is closed in a callback handlerAris Adamantiadis2011-01-191-2/+15
|
* Fix double-connect testcaseAris Adamantiadis2011-01-151-0/+19
|
* Removed the extern char *environAris Adamantiadis2010-09-301-3/+0
|
* Remove extern environ from the requirementsAris Adamantiadis2010-09-291-1/+1
|
* Fixed outgoing flow control + writes behavioursAris Adamantiadis2010-09-261-24/+28
|
* socket.c: Fixed setting max_fd which breaks ssh_select().Vic Lee2010-09-201-2/+6
| | | | Signed-off-by: Andreas Schneider <asn@cynapses.org>
* socket: Make code easier to read and debug.Andreas Schneider2010-09-071-8/+10
|
* misc: Rename libssh/ to src/Andreas Schneider2010-09-061-0/+719