Commit Graph

1267 Commits

Author SHA1 Message Date
Daniel Stenberg
1d11d02aa9 packets: code cleanup
I added size checks in several places. I fixed the code flow to be easier
to read in some places.

I removed unnecessary zeroing of structs. I removed unused struct fields.
2010-11-10 14:56:14 +01:00
Daniel Stenberg
f4ad3e0120 LIBSSH2_CALLBACK_MACERROR: clarify return code use 2010-11-10 14:41:56 +01:00
Daniel Stenberg
772564650d _libssh2_userauth_publickey: avoid shadowing 2010-11-10 13:28:33 +01:00
Daniel Stenberg
05ba8db8aa packet: avoid shadowing global symbols 2010-11-10 13:06:39 +01:00
Daniel Stenberg
1964ccb557 sftp_readdir: avoid shadowing 2010-11-10 13:05:08 +01:00
Daniel Stenberg
bef0ce5392 shadowing: don't shadow the global compress 2010-11-10 13:04:30 +01:00
Daniel Stenberg
fb6afd01a1 _libssh2_packet_add: turn ifs into a single switch 2010-11-10 12:21:48 +01:00
Daniel Stenberg
a302428335 _libssh2_packet_add: check SSH_MSG_GLOBAL_REQUEST packet 2010-11-09 19:59:18 +01:00
Daniel Stenberg
7ad152a6b2 _libssh2_packet_add: SSH_MSG_DEBUG length checks
Verify lengths before using them. Read always_display from the correct
index. Don't copy stuff around just to provide zero-termination of the
strings.
2010-11-09 15:07:32 +01:00
Daniel Stenberg
075ff19574 _libssh2_packet_add: SSH_MSG_IGNORE skip memmove
There's no promise of a zero termination of the data in the callback so
no longer perform ugly operation in order to provide it.
2010-11-09 14:57:36 +01:00
Daniel Stenberg
16f46c1cfc _libssh2_packet_add: SSH_MSG_DISCONNECT length checks
Verify lengths before trying to read data.
2010-11-09 14:53:44 +01:00
Daniel Stenberg
aa2fdb3e7e indent: break lines at 80 columns 2010-11-09 14:32:02 +01:00
Daniel Stenberg
8f10da89c5 SSH_MSG_CHANNEL_OPEN_FAILURE: used defined values
We don't like magic numbers in the code. Now the acceptable failure
codes sent in the SSH_MSG_CHANNEL_OPEN_FAILURE message are added as
defined values in the private header file.
2010-11-09 14:28:29 +01:00
Daniel Stenberg
2dfa5d38cb sftp_write: don't return EAGAIN if no EAGAIN was received
This function now only returns EAGAIN if a lower layer actually returned
EAGAIN to it. If nothing was acked and no EAGAIN was received, it will
now instead return 0.
2010-11-09 13:09:08 +01:00
Daniel Stenberg
095e9e7b3e _libssh2_wait_socket: detect nothing-to-wait-for
If _libssh2_wait_socket() gets called but there's no direction set to
wait for, this causes a "hang". This code now detects this situation,
set a 1 second timeout instead and outputs a debug output about it.
2010-11-09 13:07:15 +01:00
Daniel Stenberg
588c8946fc decomp: remove the free_dest argument
Since the decompress function ALWAYS returns allocated memory we get a
lot simpler code by removing the ability to return data unallocated.
2010-11-03 15:03:57 +01:00
Daniel Stenberg
a6fc9aeec9 decomp: cleaned off old compression stuff
I cleared off legacy code from when the compression and decompression
functions were a single unified function. Makes the code easier to read
too.
2010-11-03 14:52:42 +01:00
TJ Saunders
7603c0f854 decomp: increase decompression buffer sizes 2010-11-03 14:45:52 +01:00
TJ Saunders
8974dc05ae zlib: Add debug tracing of zlib errors 2010-11-03 14:42:44 +01:00
Daniel Stenberg
6395a738fd sftp_packet_read: handle partial reads of the length field
SFTP packets come as [32 bit length][payload] and the code didn't
previously handle that the initial 32 bit field was read only partially
when it was read.
2010-11-02 19:14:33 +01:00
Jasmeet Bagga
73be9fab04 kex_agree_hostkey: fix NULL pointer derefence
While setting up the session, ssh tries to determine the type of
encryption method it can use for the session. This requires looking at
the keys offered by the remote host and comparing these with the methods
supported by libssh2 (rsa & dss). To do this there is an iteration over
the array containing the methods supported by libssh2.

If there is no agreement on the type of encryption we come to the 3rd
entry of the hostkeyp array. Here hostkeyp is valid but *hostkep is
NULL. Thus when we dereference that in (*hostkeyp)->name there is a
crash
2010-11-02 00:02:25 +01:00
Daniel Stenberg
753e55ef23 _libssh2_transport_send: remove dead assignment
'data' isn't accessed beyond this point so there's no need to assign it.
2010-11-01 23:00:07 +01:00
Daniel Stenberg
4760e4d051 scp_recv: remove dead assignment
Instead of assigning a variable we won't read, we now use the more
explicit (void) prefix.
2010-11-01 22:59:15 +01:00
Daniel Stenberg
57af0da9f7 sftp_write: removed superfluous assignment 2010-11-01 22:58:47 +01:00
Daniel Stenberg
024b5d29f5 bugfix: avoid use of uninitialized value 2010-11-01 22:58:12 +01:00
Daniel Stenberg
a0dd0c5992 sftp_packet_require: propagate error codes better
There were some chances that they would cause -1 to get returned by
public functions and as we're hunting down all such occurances and since
the underlying functions do return valuable information the code now
passes back proper return codes better.
2010-11-01 09:33:36 +01:00
Alfred Gebert
92d308c157 fix memory leaks (two times cipher_data) for each sftp session 2010-10-27 23:17:16 +02:00
Daniel Stenberg
4ae71b4838 libssh2_userauth_authenticated: make it work as documented
The man page clearly says it returns 1 for "already authenticated" but
the code said non-zero. I changed the code to use 1 now, as that is also
non-zero but it gets the benefit that it now matches the documentation.

Using 1 instead of non-zero is better for two reasons:

1. We have the opportunity to introduce other return codes in the future for
   things like error and what not.
2. We don't expose the internal bitmask variable value.
2010-10-27 22:59:32 +02:00
Daniel Stenberg
ba190d34c6 userauth_keyboard_interactive: fix indent 2010-10-27 22:58:39 +02:00
Alfred Gebert
b84f69c960 fix memory leak in userauth_keyboard_interactive()
First I wanted to free the memory in session_free() but then
I had still memory leaks because in my test case the function
userauth_keyboard_interactive() is called twice. It is called
twice perhaps because the server has this authentication
methods available: publickey,gssapi-with-mic,keyboard-interactive
The keyboard-interactive method is successful.
2010-10-27 22:47:34 +02:00
Daniel Stenberg
a7aee34522 dist: include sftp.h in dist archives 2010-10-27 14:51:25 +02:00
Simon Josefsson
1dc366109d Update header to match new function prototype, see c48840ba88. 2010-10-27 11:45:07 +02:00
Daniel Stenberg
e1ea2eb7c2 bugfixes: the transport rearrange left some subtle flaws now gone 2010-10-26 00:14:31 +02:00
Daniel Stenberg
610a8ab919 libssh2_userauth_publickey_fromfile_ex.3: cleaned up looks 2010-10-25 23:44:39 +02:00
Daniel Stenberg
8ec21e0afe libssh2_userauth_publickey: add man page
I found an undocumented public function and we can't have it like
that. The description here is incomplete, but should serve as a template
to allow filling in...
2010-10-25 23:18:50 +02:00
Daniel Stenberg
8e0983347b libssh2_sftp_write.3: added blurb about the "write ahead"
Documented the new SFTP write concept
2010-10-25 16:38:37 +02:00
Daniel Stenberg
95db6cc62c sftp_close_handle: free any trailing write chunks 2010-10-25 16:30:09 +02:00
Daniel Stenberg
727043074a _libssh2_channel_write: fix warnings 2010-10-25 16:07:46 +02:00
Daniel Stenberg
5b4ed2717b SFTP: bufgix, move more sftp stuff to sftp.h
The sftp_write function shouldn't assume that the buffer pointer will be
the same in subsequent calls, even if it assumes that the data already
passed in before haven't changed.

The sftp structs are now moved to sftp.h (which I forgot to add before)
2010-10-25 16:05:53 +02:00
Daniel Stenberg
59f74de157 SFTP: use multiple outgoing packets when writing
sftp_write was rewritten to split up outgoing data into multiple packets
and deal with the acks in a more asynchronous manner. This is meant to
help overcome latency and round-trip problems with the SFTP protocol.
2010-10-25 01:43:54 +02:00
Daniel Stenberg
d87562976a TODO: implemented a lot of the ideas now 2010-10-24 23:38:26 +02:00
Daniel Stenberg
a94886f157 _libssh2_channel_write: removed 32500 size limit
Neither _libssh2_channel_write nor sftp_write now have the 32500 size
limit anymore and instead the channel writing function now has its own
logic to send data in multiple calls until everything is sent.
2010-10-23 01:16:12 +02:00
Daniel Stenberg
dec0ea9e70 send_existing: don't tell parent to return when drained
That will just cause unnecessary code execution.
2010-10-23 00:47:51 +02:00
Daniel Stenberg
030b2d9b60 _libssh2_channel_write: general code cleanup
simplified the function and removed some unused struct fields
2010-10-23 00:35:10 +02:00
Daniel Stenberg
c48840ba88 _libssh2_transport_send: replaces _libssh2_transport_write
The new function takes two data areas, combines them and sends them as a
single SSH packet. This allows several functions to allocate and copy
less data.

I also found and fixed a mixed up use of the compression function
arguments that I introduced in my rewrite in a recent commit.
2010-10-23 00:11:59 +02:00
Daniel Stenberg
d9cdd8c0a7 scp_write_nonblock: use select() instead of busyloop
Make this example nicer by not busylooping.
2010-10-22 13:37:14 +02:00
Daniel Stenberg
c49061e708 send_existing: clear olen when the data is sent off 2010-10-22 13:37:14 +02:00
Daniel Stenberg
d674b1a09a _libssh2_transport_write: allow 256 extra bytes around the packet 2010-10-22 13:37:13 +02:00
Daniel Stenberg
5ede32a826 _libssh2_transport_write: remade to send without malloc 2010-10-22 13:37:13 +02:00
Daniel Stenberg
3a391f6cf2 compress: compression disabled by default
We now allow libssh2_session_flag() to enable compression with a new
flag and I added documentation for the previous LIBSSH2_FLAG_SIGPIPE
flag which I wasn't really aware of!
2010-10-22 13:37:13 +02:00