aboutsummaryrefslogtreecommitdiff
path: root/src/socket.c
AgeCommit message (Collapse)AuthorFilesLines
2016-05-02packet: Improve logging outputAris Adamantiadis1-0/+6
Signed-off-by: Aris Adamantiadis <aris@0xbadc0de.be> Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2016-01-19buffer: do not use ssh_buffer_get_rest_len()Fabiano Fidêncio1-5/+5
As ssh_buffer_get_len() actually calls ssh_buffer_get_rest_len(), let's just use the first one. This is a preparatory step for removing ssh_buffer_get_rest_len(). Signed-off-by: Fabiano Fidêncio <fidencio@redhat.com> Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2016-01-19buffer: rename ssh_buffer_get_rest() to ssh_buffer_get()Fabiano Fidêncio1-2/+2
Signed-off-by: Fabiano Fidêncio <fidencio@redhat.com> Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2016-01-19cleanup: use ssh_ prefix in the buffer (non-static) functionsFabiano Fidêncio1-9/+9
Having "ssh_" prefix in the functions' name will avoid possible clashes when compiling libssh statically. Signed-off-by: Fabiano Fidêncio <fidencio@redhat.com> Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2015-04-10socket: Cleanup ssh_socket_close() code.Andreas Schneider1-5/+6
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2015-02-23Sending EOF on Socket that received a Broken Pipe makes call to poll to hangxjoaalm1-9/+18
Reviewed-by: Aris Adamantiadis <aris@0xbadc0de.be> Signed-off-by: Joao Pedro Almeida Pereira <joao.almeida@blue-tc.com>
2014-03-27socket: Fix style of ssh_socket_pollcallbackAlan Dunn1-108/+111
Signed-off-by: Alan Dunn <amdunn@gmail.com> Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2014-02-12Add session/channel byte/packet countersAudrius Butkevicius1-0/+6
Signed-off-by: Audrius Butkevicius <audrius.butkevicius@elastichosts.com>
2014-02-02socket: fix read of non-connected socketJon Simons1-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>
2014-02-02src: Define MAX_BUF_SIZE globally and use it.Joseph Southwell1-1/+1
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2014-01-19src: Rename buffer_add_data() to ssh_buffer_add_data().Andreas Schneider1-2/+2
2014-01-19src: Rename buffer_init to ssh_buffer_init().Andreas Schneider1-2/+2
2014-01-16src: Do not use deprecated functions.Andreas Schneider1-2/+2
2014-01-05socket: don't attempt reading a non-connected socketAris Adamantiadis1-1/+1
2013-11-18sockets: null pointer checkAris Adamantiadis1-5/+7
2013-11-15socket: Fix connect if we pass in a fd.Andreas Schneider1-9/+13
BUG: https://red.libssh.org/issues/106 Thanks to Saju Panikulam.
2013-11-09Add ssh_get_poll_flags()Colin Walters1-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>
2013-11-03socket: Fix check for pending data.Aris Adamantiadis1-3/+3
BUG: https://red.libssh.org/issues/119 Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2013-07-14src: Remove enter_function() and leave_function().Andreas Schneider1-16/+8
2013-07-14src: Migrate to SSH_LOG.Andreas Schneider1-5/+5
2013-06-17socket: Check if socket (non)blocking is working.Andreas Schneider1-9/+12
2013-06-17socket: Check return value of getsockopt().Andreas Schneider1-1/+4
2013-01-29socket: Call data handler as long as handler takes data.Johannes Krude1-4/+6
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2012-10-09socket: Check return value of buffer function.Andreas Schneider1-1/+4
Found by Coverity.
2012-07-17socket: Add a SSH_WRITE_PENDING socket status.Andreas Schneider1-0/+4
2011-09-18socket: Move socket function to right location.Andreas Schneider1-1/+22
2011-08-06channels: Fix checking for fatal errors.rofl0r1-18/+20
We need this that we don't end up in and infinite poll loop.
2011-05-20Fix "connecting to closed port" on MacosXAris Adamantiadis1-1/+1
2011-05-17socket: Fixed use-after-free.Oliver Stöneberg1-0/+6
When s->callbacks->exception() was called in ssh_socket_pollcallback() we had a use after free bug.
2011-05-02[socket] fix a segfault at disconnectmilo1-4/+15
(cherry picked from commit 56394917b15e41603c641c22a4e29c33b096d673)
2011-05-01init: Some initialization fixes.Oliver Stöneberg1-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)
2011-05-01socket: Fixed poll input event.Oliver Stöneberg1-1/+1
2011-04-15poll: Fix poll input events.Andreas Schneider1-1/+1
bug#38
2011-04-11build: Fixed some VS2010 problems.Oliver Stöneberg1-1/+1
2011-03-22Implement ssh_blocking_flush()Aris Adamantiadis1-0/+12
Based on code from Jan Willamowius
2011-02-14socket: Set errors on return.Bernhard R. Link1-1/+16
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2011-01-19Fix use-after-free when socket is closed in a callback handlerAris Adamantiadis1-2/+15
2011-01-15Fix double-connect testcaseAris Adamantiadis1-0/+19
2010-09-30Removed the extern char *environAris Adamantiadis1-3/+0
2010-09-29Remove extern environ from the requirementsAris Adamantiadis1-1/+1
2010-09-26Fixed outgoing flow control + writes behavioursAris Adamantiadis1-24/+28
2010-09-20socket.c: Fixed setting max_fd which breaks ssh_select().Vic Lee1-2/+6
Signed-off-by: Andreas Schneider <asn@cynapses.org>
2010-09-07socket: Make code easier to read and debug.Andreas Schneider1-8/+10
2010-09-06misc: Rename libssh/ to src/Andreas Schneider1-0/+719