1
0
mirror of https://git.libssh.org/projects/libssh.git synced 2025-11-30 13:01:23 +03:00
Commit Graph

46 Commits

Author SHA1 Message Date
Andreas Schneider
c563ed636a Remove vim modelines from all files
If you want modelines use my vim plugin:
https://github.com/cryptomilk/git-modeline.vim

git config --add vim.modeline "ts=4 sw=4 et"

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-06-28 08:41:08 +02:00
Andreas Schneider
f0ddde4826 Fix config.h includes
We need stdlib.h and string.h in priv.h for free() and memset().

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2017-10-28 14:31:37 +02:00
Aris Adamantiadis
8e42d3959c packet: Improve logging output
Signed-off-by: Aris Adamantiadis <aris@0xbadc0de.be>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2016-05-02 17:27:16 +02:00
Fabiano Fidêncio
05fd0acf45 buffer: do not use ssh_buffer_get_rest_len()
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-19 11:31:08 +01:00
Fabiano Fidêncio
954341dd1f buffer: rename ssh_buffer_get_rest() to ssh_buffer_get()
Signed-off-by: Fabiano Fidêncio <fidencio@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2016-01-19 11:31:07 +01:00
Fabiano Fidêncio
adc8c20ac1 cleanup: use ssh_ prefix in the buffer (non-static) functions
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>
2016-01-19 11:31:07 +01:00
Andreas Schneider
1cb940c44a socket: Cleanup ssh_socket_close() code.
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2015-04-10 13:32:09 +02:00
xjoaalm
f32e5f2191 Sending EOF on Socket that received a Broken Pipe makes call to poll to hang
Reviewed-by: Aris Adamantiadis <aris@0xbadc0de.be>
Signed-off-by: Joao Pedro Almeida Pereira <joao.almeida@blue-tc.com>
2015-02-23 22:01:15 +01:00
Alan Dunn
d5aeebe323 socket: Fix style of ssh_socket_pollcallback
Signed-off-by: Alan Dunn <amdunn@gmail.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2014-03-27 10:54:55 +01:00
Audrius Butkevicius
a277dd9277 Add session/channel byte/packet counters
Signed-off-by: Audrius Butkevicius <audrius.butkevicius@elastichosts.com>
2014-02-12 18:21:16 +01:00
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
Joseph Southwell
6bbdaceaca src: Define MAX_BUF_SIZE globally and use it.
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2014-02-02 22:19:46 +01:00
Andreas Schneider
cb9786b3ae src: Rename buffer_add_data() to ssh_buffer_add_data(). 2014-01-19 20:55:55 +01:00
Andreas Schneider
9c4144689d src: Rename buffer_init to ssh_buffer_init(). 2014-01-19 20:43:29 +01:00
Andreas Schneider
2fe59071b2 src: Do not use deprecated functions. 2014-01-16 15:27:46 +01:00
Aris Adamantiadis
b514957af7 socket: don't attempt reading a non-connected socket 2014-01-05 21:54:08 +01:00
Aris Adamantiadis
ccdc0f1805 sockets: null pointer check 2013-11-18 14:42:40 +01:00
Andreas Schneider
f240ecf328 socket: Fix connect if we pass in a fd.
BUG: https://red.libssh.org/issues/106

Thanks to Saju Panikulam.
2013-11-15 08:47:58 +01:00
Colin Walters
4cc7f4ad03 Add ssh_get_poll_flags()
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-09 12:26:19 +01:00
Aris Adamantiadis
04cb94a2dd socket: Fix check for pending data.
BUG: https://red.libssh.org/issues/119

Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2013-11-03 12:46:27 +01:00
Andreas Schneider
c64ec43eef src: Remove enter_function() and leave_function(). 2013-07-14 13:31:24 +02:00
Andreas Schneider
ebdd0c6ac1 src: Migrate to SSH_LOG. 2013-07-14 12:44:26 +02:00
Andreas Schneider
2b68728552 socket: Check if socket (non)blocking is working. 2013-06-17 13:18:55 +02:00
Andreas Schneider
42c7bc5a21 socket: Check return value of getsockopt(). 2013-06-17 13:09:50 +02:00
Johannes Krude
186116f34a socket: Call data handler as long as handler takes data.
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2013-01-29 10:56:49 +01:00
Andreas Schneider
21db70888a socket: Check return value of buffer function.
Found by Coverity.
2012-10-09 11:09:34 +02:00
Andreas Schneider
43e3a8e497 socket: Add a SSH_WRITE_PENDING socket status. 2012-07-17 18:05:51 +02:00
Andreas Schneider
c2686b8feb socket: Move socket function to right location. 2011-09-18 21:37:17 +02:00
rofl0r
563fbe4de8 channels: Fix checking for fatal errors.
We need this that we don't end up in and infinite poll loop.
2011-08-06 11:11:12 +02:00
Aris Adamantiadis
79434649d0 Fix "connecting to closed port" on MacosX 2011-05-20 15:13:45 +02:00
Oliver Stöneberg
9866763789 socket: Fixed use-after-free.
When s->callbacks->exception() was called in ssh_socket_pollcallback()
we had a use after free bug.
2011-05-17 14:19:51 +02:00
milo
7d2064c289 [socket] fix a segfault at disconnect
(cherry picked from commit 56394917b15e41603c641c22a4e29c33b096d673)
2011-05-02 17:02:25 +02:00
Oliver Stöneberg
3ae01ff9f5 init: Some initialization fixes.
- 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-01 19:42:50 +02:00
Oliver Stöneberg
040a543f57 socket: Fixed poll input event. 2011-05-01 19:42:38 +02:00
Andreas Schneider
8b95328b1b poll: Fix poll input events.
bug#38
2011-04-15 19:14:15 +02:00
Oliver Stöneberg
166ee451c5 build: Fixed some VS2010 problems. 2011-04-11 11:18:57 +02:00
Aris Adamantiadis
dff4e4e6d3 Implement ssh_blocking_flush()
Based on code from Jan Willamowius
2011-03-22 11:49:57 +01:00
Bernhard R. Link
071b0034db socket: Set errors on return.
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2011-02-14 22:48:53 +01:00
Aris Adamantiadis
84df46f805 Fix use-after-free when socket is closed in a callback handler 2011-01-19 16:01:21 +01:00
Aris Adamantiadis
b945cbca52 Fix double-connect testcase 2011-01-15 22:43:58 +01:00
Aris Adamantiadis
bedc65313f Removed the extern char *environ 2010-09-30 10:42:55 +02:00
Aris Adamantiadis
9f53906209 Remove extern environ from the requirements 2010-09-29 17:06:54 +02:00
Aris Adamantiadis
75a0281a6b Fixed outgoing flow control + writes behaviours 2010-09-26 22:33:58 +02:00
Vic Lee
a92545517a socket.c: Fixed setting max_fd which breaks ssh_select().
Signed-off-by: Andreas Schneider <asn@cynapses.org>
2010-09-20 19:22:19 +02:00
Andreas Schneider
ab2dafc44a socket: Make code easier to read and debug. 2010-09-07 18:50:38 +02:00
Andreas Schneider
f7842e3a4b misc: Rename libssh/ to src/ 2010-09-06 14:28:38 +02:00