589 Commits

Author SHA1 Message Date
Daniel Stenberg
2f9c105ec2 wait_socket: make c89 compliant and use two fd_sets for select() 2010-04-15 11:02:41 +02:00
Daniel Stenberg
e22cdcea77 sftp_readdir: simplified and bugfixed
This function no longer has any special purpose code for the
single entry case, as it was pointless.

The previous code would overflow the buffers with an off-by-one
in case the file name or longentry data fields received from the
server were exactly as long as the buffer provided to
libssh2_sftp_readdir_ex.

We now make sure that libssh2_sftp_readdir_ex() ALWAYS zero
terminate the buffers it fills in.

The function no longer calls the libssh2_* function again, but
properly uses the internal sftp_* instead.
2010-04-15 01:15:35 +02:00
Daniel Stenberg
7f740368f4 channel/transport: we now drain the outgoing send buffer when we ignore EAGAIN
When we ignore the EAGAIN from the transport layer within channel_write, we
now drain the outgoing transport layer buffer so that remainders in that
won't cause any problems in the next invoke of _libssh2_transport_write()
2010-04-15 01:12:22 +02:00
Daniel Stenberg
8b63dc9e59 channel_write: if data has been sent, don't return EAGAIN
When sending data in a loop, we must not return EAGAIN if we
managed to send data in an earlier round. This was reported in
bug #126 => http://libssh2.stuge.se/ticket/126
2010-04-14 23:35:40 +02:00
Simon Josefsson
77fa740674 Fix OpenSSL AES-128-CTR detection.
Patch from Paul Howarth <paul@city-fan.org>.
2010-04-14 14:04:45 +02:00
Daniel Stenberg
0ecd0eb37c channel_close: no longer wait for the SSH_MSG_CHANNEL_CLOSE message
As the packet may simply not arrive we cannot have the close
function wait for it unconditionally.
2010-04-13 22:59:52 +02:00
Daniel Stenberg
f514bcac53 less code duplication in the poll vs select code flows
libssh2_keepalive_send and libssh2_session_block_directions are
now used outside of the #ifdef blocks.
2010-04-13 10:45:01 +02:00
Daniel Stenberg
8b7e22cb33 sftp_init() deal with _libssh2_channel_write() returns short
When _libssh2_channel_write() is asked to send off 9 bytes, the
code needs to deal with the situation where less than 9 bytes
were sent off and prepare to send the remaining piece at a later
time.
2010-04-01 20:25:49 +02:00
Daniel Stenberg
1d49f1bc21 handle a NULL password as if it was ""
libssh2_userauth_publickey_fromfile_ex() takes a "passphrase"
but didn't deal with it being set to NULL.
2010-03-29 17:19:58 +02:00
Daniel Stenberg
1711917c2c Reduce used window sizes by factor 10
As reported in bug report #166 http://libssh2.stuge.se/ticket/166
by 'ptjm', the maximum window size must be less crazy for libssh2
to do better with more server implementations. I did not do any
testing to see how this changes raw SCP performance, but the
maximum window size is still almost 4MB. This also has the upside
that libssh2 will use less memory.
2010-03-28 15:36:58 +02:00
Peter Stuge
b6ed60d2cc Correctly clear blocking flag after sending multipart packet
commit 7317edab61d2179febc38a2c2c4da0b951d74cbc cleared the outbound
blocking bit when send_existing() returned PACKET_NONE and *ret=0, as
opposed to before even calling send_existing(), but because *ret=1 when
sending parts 2..n of an existing packet, the bit would only be cleared
when calling libssh2_transport_write() for a new packet.

Clear the direction flag after the final part of a packet has been sent.
2010-03-28 01:35:55 +01:00
Daniel Stenberg
5512d0d593 fix memory leak
we must not assign the pointer a NULL since it keeps allocated
data and at least parts of an error string
2010-03-23 23:16:08 +01:00
Simon Josefsson
6d253324be Fix logic in "on-the-fly" crypto init. 2010-03-23 21:09:32 +01:00
Simon Josefsson
aebcc45a37 Make sure keepalive is working even when poll is used. 2010-03-23 21:08:47 +01:00
Paul Querna
1decccbb52 Use poll when available on blocking API.
Signed-off-by: Simon Josefsson <simon@josefsson.org>
2010-03-23 20:48:58 +01:00
Peter Stuge
4c09324b02 Fix speling 2010-03-20 02:45:46 +01:00
Daniel Stenberg
6d4b1bbb45 fix NULL dereference when window adjusting a non-existing channel
Suyog Jadhav pointed out that when receiving a window adjust to
a channel not found, the code would reference a NULL pointer.
Now it will instead output a message about that fact.
2010-03-19 14:58:05 +01:00
Simon Josefsson
fa4017c613 Fix init/exit logic. Add self-test of it. 2010-03-19 09:27:19 +01:00
Simon Josefsson
55ede3b41b Shorten constant a bit. More documentation. 2010-03-19 09:17:42 +01:00
Simon Josefsson
d00283927f Fix namespace pollution. 2010-03-19 09:14:21 +01:00
Simon Josefsson
9ea5b0625e Add global init/exit points, to do crypto initialization in one place.
By Lars Nordin.
2010-03-19 09:05:52 +01:00
Alexander Lamaison
9abf81de97 Add libssh2_knownhost_addc to handle comments.
Comments in known_hosts file were not handle properly.  They were parsed as
part of the key causing key matching to return a mismatch if the entry had a
comment.  This adds a new API function that takes an optional comment and
changes libssh2_knownhost_readline to parse the comment as pass it to the
new function.

Fixes #164.
2010-03-14 19:52:00 +00:00
Alexander Lamaison
c585828d2b Fix gettimeofday to compile with Visual C++ 6.
Reported by Steven Van Ingelgem.
2010-03-12 11:29:31 +00:00
Simon Josefsson
4cfeade243 keepalive.c: Fix libssh2_error usage. 2010-03-10 13:16:32 +01:00
Simon Josefsson
0d331aade1 Add keep-alive support. 2010-03-10 13:08:42 +01:00
Alexander Lamaison
69520e1564 Untabify. 2010-03-07 17:12:56 +00:00
Alexander Lamaison
f87f4ab836 Fix memory leak in libssh2_knownhost_add. 2010-03-07 16:20:07 +00:00
Daniel Stenberg
1f406feaa4 reduce code duplication and return underlying error better 2010-03-03 23:57:22 +01:00
Daniel Stenberg
c0436fc602 acknowledge when _libssh2_packet_requirev() returns error
when _libssh2_packet_requirev() returns an error when waiting for
SSH_MSG_USERAUTH_SUCCESS or SSH_MSG_USERAUTH_FAILURE, it is an
error and it should be treated as such
2010-03-03 23:44:54 +01:00
Daniel Stenberg
0034a83e4c wrap long lines 2010-03-03 23:44:24 +01:00
Daniel Stenberg
f0f4ba92f0 polished the phrasing in two error strings 2010-03-03 23:37:58 +01:00
Daniel Stenberg
c29ba827e4 silence picky compiler warnings 2010-03-03 23:33:25 +01:00
Daniel Stenberg
a03e1b0457 silence picky compiler warnings 2010-03-03 23:32:56 +01:00
Daniel Stenberg
d4a768af4e removed libssh2_error()'s forth argument
libssh2_error() no longer allocates a string and only accepts a const
error string. I also made a lot of functions use the construct of
return libssh2_error(...) instead of having one call to
libssh2_error() and then a separate return call. In several of those
cases I then also changed the former -1 return code to a more
detailed one - something that I think will not change behaviors
anywhere but it's worth keeping an eye open for any such.
2010-03-03 23:04:05 +01:00
Daniel Stenberg
8bbc109e52 let the err_msg in the session struct be const too 2010-03-01 13:16:19 +01:00
Simon Josefsson
0ef84144ac Revert #ifdef change that pulled in AES-CTR code when explicitly disabled. 2010-03-01 13:09:18 +01:00
Daniel Stenberg
ef27023eb9 fix #ifdefs 2010-03-01 11:42:38 +01:00
Daniel Stenberg
a9621548f8 make function match the new proto 2010-03-01 11:42:04 +01:00
Simon Josefsson
a925bdd5bb Improve AES-CTR check. 2010-03-01 11:38:50 +01:00
Daniel Stenberg
3420e9858c use const to silence a bazillion warnings 2010-03-01 11:05:40 +01:00
Simon Josefsson
2de339b2f7 Use AES-CTR from OpenSSL when available.
Reported by Lars Nordin <Lars.Nordin@SDlabs.se>.
2010-03-01 10:34:00 +01:00
Simon Josefsson
c46cbd46e2 Make it possible to disable DSA.
Patch from Lars Nordin <Lars.Nordin@SDlabs.se>.
2010-03-01 10:30:22 +01:00
Peter Stuge
16af813b81 Send and receive channel EOF before sending SSH_MSG_CHANNEL_CLOSE
Sending SSH_MSG_CHANNEL_CLOSE without channel EOF is explicitly allowed
in RFC 4254, but some non-conforming servers will hang or time out when
the channel is closed before EOF.

Other common clients send and receive EOF before closing, there are no
drawbacks, and some servers need it to work correctly.
2010-03-01 06:43:53 +01:00
Alexander Lamaison
a2157c8391 Style improvements to knownhost error handling.
Made improvements as suggested by Peter Stuge: http://www.libssh2.org/mail/libssh2-devel-archive-2010-02/0161.shtml.
2010-02-26 18:47:54 +00:00
Alexander Lamaison
942a40b482 Call libssh2_error for every knownhost API failure.
The libssh2 API calls should set the last error code and a message when
returning a failure by calling libssh2_error.  This changeset adds these
calls to the libssh2_knownhost_* API as well as libssh2_base64_decode.

This change also makes libssh2_error into a function rather than a macro.
Its implementation is moved to misc.c.  This function returns the error
code passed to it allowing callers to return the error value directly
without duplicating the error code.
2010-02-24 13:45:00 +00:00
Alexander Lamaison
ef096220ce Fix LIBSSH2_ALLOC checks.
These appear to be cut-and paste errors where the wrong variable is checked
for NULLness after calling LIBSSH2_ALLOC.
2010-02-23 22:00:40 +00:00
Alexander Lamaison
3e1a95392e libssh2_knownhost_del: fix write to freed memory.
When removing a known host, libssh2_knownhost_del would remove the node from the linked list, free its memory and then overwrite the struct parameter (which indicated which node to remove) with 0.  However, this struct is actually allocated within the just-freed node meaning we're writing to freed memory.  This made Windows very upset.

The fix is simply to overwrite the struct first before freeing the memory.
2010-02-22 14:50:08 +00:00
Daniel Stenberg
c5609acb17 add missing libssh2_error() calls
To make sure the public API is functional and that the
BLOCK_ADJUST_ERRNO() macro works correctly we MUST make sure to
call libssh2_error() when we return errors.
2010-02-18 13:20:11 +01:00
Daniel Stenberg
37c08983a3 fix memory leak in userauth_keyboard_interactive()
Mr anonymous in bug #125 pointed out that the userauth_keyboard_interactive()
function does in fact assign the same pointer a second time to a new allocated
buffer without properly freeing the previous one, which caused a memory leak.
2010-02-18 13:04:29 +01:00
Daniel Stenberg
72ae0866cb added missing error codes
To allow the libssh2_session_last_error() function to work as
documented, userauth_password() now better makes sure to call
libssh2_error() everywhere before it returns error.

Pointed out by mr anonymous in bug #128
2010-02-18 00:01:33 +01:00