Commit Graph

1644 Commits

Author SHA1 Message Date
Daniel Stenberg
a123051200 sftp_packetlist_flush: zombies must not have responses already
When flushing the packetlist, we must only add the request as a zombie
if no response has already been received. Otherwise we could wrongly
make it a zombie even though the response was already received and then
we'd get a zombie stuck there "forever"...
2012-05-12 22:37:20 +02:00
Daniel Stenberg
62901253a4 sftp_read: on EOF remove packet before flush
Since the sftp_packetlist_flush() function will move all the existing
FXP_READ requests in this handle to the zombie list we must first remove
this just received packet as it is clearly not a zombie.
2012-05-10 23:11:07 +02:00
Daniel Stenberg
7c5ee0fa66 sftp_packet_require: sftp_packet_read() returning 0 is not an error
Exactly as the comment in the code said, checking the return code from
sftp_packet_read() with <= was wrong and it should be < 0. With the new
filtering on incoming packets that are "zombies" we can now see this
getting zero returned.
2012-05-10 23:09:37 +02:00
Daniel Stenberg
1e15075a8e sftp_packetlist_flush: only make it zombie if it was sent
The list of outgoing packets may also contain packets that never were
sent off and we better not make them zombies too.
2012-05-10 23:08:23 +02:00
Alexander Lamaison
ad63fc2df6 Mark outstanding read requests after EOF as zombies.
In order to be fast, sftp_read sends many read requests at once.  With a small
file, this can mean that when EOF is received back, many of these requests are
still outstanding.  Responses arriving after we close the file and abandon the
file handle are queued in the SFTP packet queue and never collected.  This
causes transfer speed to drop as a progressively longer queue must be searched
for every packet.

This change introduces a zombie request-ID list in the SFTP session that is
used to recognise these outstanding requests and prevent them being added to
the queue.
2012-05-10 19:35:25 +02:00
Rafael Kitover
d46185eaa5 Update win32/GNUmakefile to use OpenSSL 1.0.1a
libcrypto on win32 now depends on gdi32.dll, so move the OpenSSL LDLIBS
block to before the compiler definitions, so that libcrypto gets added
first, and then add -lgdi32 into the following common LDLIBS for gcc.
2012-04-23 20:04:41 +02:00
Guenter Knauf
9c4b380dd6 Changed 'Requires' to 'Requires.private'.
Only static builds need to link against the crypto libs.
2012-04-23 12:33:08 +02:00
Guenter Knauf
e887a8bd0f Fixed 'Requires:' names.
The 'Requires:' line lists the names of the .pc files.
2012-04-23 01:11:22 +02:00
Guenter Knauf
04692445d4 Added 'Requires:' line to libssh2.pc.
This is necessary so that other libs which lookup libssh2 info
via pkg-config can add the right crypto lib dependencies.
2012-04-23 00:35:03 +02:00
Guenter Knauf
a955f8428b Updated dependency lib versions. 2012-04-20 13:50:06 +02:00
Peter Stuge
ededdfa9c2 configure.ac: Add option to disable build of the example applications
Examples are built by default. Any of the following options on the
configure command line will skip building them:

  --disable-examples-build
  --enable-examples-build=no
  --enable-examples-build=false
2012-04-18 16:35:05 +02:00
Peter Stuge
11f9dce3d7 userauth.c: fread() from public key file to correctly detect any errors
If the filename parameter for file_read_publickey() was the name of a
directory instead of a file then libssh2 would spin trying to fgetc()
from the FILE * for the opened directory when trying to determine the
length of the encoded public key, since fgetc() can't report errors.

Use fread() instead to correctly detect this error condition along
with many others.

This fixes the problem reported in
http://www.libssh2.org/mail/libssh2-devel-archive-2012-04/0021.shtml

Reported-by: Oleksiy Zagorskyi <zalex_ua@i.ua>
2012-04-18 12:23:04 +02:00
Peter Stuge
6bbebcf36c Return LIBSSH2_ERROR_SOCKET_DISCONNECT on EOF when reading banner 2012-04-18 12:23:04 +02:00
Guenter Knauf
7a87bba02a Fixed copyright year. 2012-04-17 17:29:49 +02:00
Guenter Knauf
c8374cdc10 Updated dependency lib versions in static makefiles. 2012-04-12 22:01:45 +02:00
Daniel Stenberg
9b2bed22fc version: bump to 1.4.2
We're on the 1.4.2 track now (at least)
2012-04-06 15:28:18 +02:00
Daniel Stenberg
c8cc30c996 RELEASE-NOTES: updated for 1.4.1 release 2012-04-04 22:43:11 +02:00
Daniel Stenberg
acd9bd6104 always do "forced" window updates
When calling _libssh2_channel_receive_window_adjust() internally, we now
always use the 'force' option to prevent libssh2 to avoid sending the
update if the update isn't big enough.

It isn't fully analyzed but we have seen corner cases which made a
necessary window update not get send due to this and then the other side
doesn't send data our side then sits waiting for forever.
2012-04-03 22:36:19 +02:00
Daniel Stenberg
2ea40e63e8 channel_read: force window adjusts!
if there's not enough room to receive the data that's being requested,
the window adjustment needs to be sent to the remote and thus the force
option has to be used. _libssh2_channel_receive_window_adjust() would
otherwise "queue" small window adjustments for a later packet but that
is really terribly for the small buffer read that for example is the
final little piece of a very large file as then there is no logical next
packet!

Reported by: Armen Babakhanian
Bug: http://www.libssh2.org/mail/libssh2-devel-archive-2012-03/0130.shtml
2012-03-19 22:34:04 +01:00
Paul Howarth
f4f2298ef3 aes: the init function fails when OpenSSL has AES support
The internal init function only worked fine when the configure script
didn't detect the OpenSSL AES_CTR function!

Bug: http://www.libssh2.org/mail/libssh2-devel-archive-2012-03/0111.shtml
Reported by: Paul Howarth
2012-03-18 15:24:35 +01:00
Matthew Booth
cc4f9d5679 transport_send: Finish in-progress key exchange before sending data
_libssh2_channel_write() first reads outstanding packets before writing
new data. If it reads a key exchange request, it will immediately start
key re-exchange, which will require sending a response. If the output
socket is full, this will result in a return from
_libssh2_transport_read() of LIBSSH2_ERROR_EAGAIN. In order not to block
a write because there is no data to read, this error is explicitly
ignored and the code continues marshalling a packet for sending. When it
is sent, the remote end immediately drops the connection because it was
expecting a continuation of the key exchange, but got a data packet.

This change adds the same check for key exchange to
_libssh2_transport_send() that is in _libssh2_transport_read(). This
ensures that key exchange is completed before any data packet is sent.
2012-03-16 16:40:04 +01:00
Daniel Stenberg
fed0759720 channel_write: acknowledge transport errors
When draining data off the socket with _libssh2_transport_read() (which
in turn has to be done so that we can be sure to have read any possible
window-increasing packets), this code previously ignored errors which
could lead to nasty loops. Now all error codes except EAGAIN will cause
the error to be returned at once.

Bug: http://www.libssh2.org/mail/libssh2-devel-archive-2012-03/0068.shtml
Reported by: Matthew Booth
2012-03-15 13:03:08 +01:00
Steven Dake
a46ef85a56 In examples/x11.c, Make sure sizeof passed to read operation is correct
sizeof(buf) expands to 8 or 4 (since its a pointer).  This variable may
have been static in the past, leading to this error.

Signed-off-by: Steven Dake <sdake@redhat.com>
2012-03-13 22:19:54 +01:00
Steven Dake
626f91da07 Fix suspicious sizeof usage in examples/x11.c
In the x11 example, sizeof(buf) = 8UL (on x86_64), when this should
probably represent the buffer size available.  I am not sure how to
test that this change is actually correct, however.

Signed-off-by: Steven Dake <sdake@redhat.com>
2012-03-13 22:19:18 +01:00
Daniel Stenberg
bf097e37b0 sftp_packet_read: follow-up fix for EAGAIN/window adjust
The commit in 7194a9bd7b wasn't complete. This change makes sure
variables are initialized properly before used in the EAGAIN and window
adjust cases.
2012-03-13 22:02:14 +01:00
Daniel Stenberg
a1c996cef1 sftp_packet_add: use named error code instead of number 2012-03-13 22:01:33 +01:00
Daniel Stenberg
8fc16beda9 sftp_packet_add: verify the packet before accepting it
In order to bail out as quickly as possible when things are wrong and
out of sync, make sure the SFTP message is one we understand.
2012-03-13 21:59:59 +01:00
Daniel Stenberg
9a42fac055 SFTP: preserve the original error code more
Lots of places in the code translated the original error into the more
generic LIBSSH2_ERROR_SOCKET_TIMEOUT but this turns out to distort the
original error reason a lot and makes tracking down the real origin of a
problem really hard. This change makes the original error code be
preserved to a larger extent when return up to the parent function.
2012-03-12 22:52:49 +01:00
Daniel Stenberg
7194a9bd7b sftp_packet_read: adjust window size as necessary
Commit 03ca902075 tried to simplify the window sizing logic but broke
SFTP readdir as there was no window sizing code left there so large
directory listings no longer worked.

This change introduces window sizing logic to the sftp_packet_read()
function so that it now tells the remote about the local size having a
window size that suffice when it is about to ask for directory data.

Bug: http://www.libssh2.org/mail/libssh2-devel-archive-2012-03/0069.shtml
Reported by: Eric
2012-03-12 22:49:25 +01:00
Steven Dake
7e53949e66 Tell C compiler we don't care about return code of libssh2_init
The call of libssh2_init returns a return code, but nothing could be done
within the _libssh2_init_if_needed execution path.

Signed-off-by: Steven Dake <sdake@redhat.com>
2012-03-11 23:22:05 +01:00
Steven Dake
5672e8f4cf Add comment indicating a resource leak is not really a resource leak
While possibly obvious to those investigating the code, coverity complains
about this out of scope leak.

Signed-off-by: Steven Dake <sdake@redhat.com>
2012-03-06 23:25:46 +01:00
Steven Dake
4449905ea5 Use safer snprintf rather then sprintf in scp_send()
Signed-off-by: Steven Dake <sdake@redhat.com>
2012-03-06 23:24:32 +01:00
Steven Dake
8e0cddd01f Use safer snprintf rather then sprintf in scp_recv()
While the buffer is indeed allocated to a safe length, better safe then sorry.

Signed-off-by: Steven Dake <sdake@redhat.com>
2012-03-06 23:23:21 +01:00
Steven Dake
796a5195d3 use snprintf in knownhost_writeline() rather then sprintf
Although the function checks the length, if the code was in error, there
could potentially be a buffer overrun with the use of sprintf.  Instead replace
with snprintf.

Signed-off-by: Steven Dake <sdake@redhat.com>
2012-03-06 23:21:59 +01:00
Steven Dake
15aadb930d Add tracing to print packets left on session at libssh2_session_free
Signed-off-by: Steven Dake <sdake@redhat.com>
2012-03-05 20:04:57 +01:00
Peter Stuge
f28264c6a3 Define and use LIBSSH2_INVALID_SOCKET instead of INVALID_SOCKET
INVALID_SOCKET is a special value in Windows representing a
non-valid socket identifier. We were #defining this to -1 on
non-Windows platforms, causing unneccessary namespace pollution.
Let's have our own identifier instead.

Thanks to Matt Lawson for pointing this out.
2012-03-02 17:36:52 +01:00
Peter Stuge
179d2197dd nw/Makefile.netware: Fix project name typo to avoid needless confusion 2012-02-29 22:31:28 +01:00
Peter Stuge
aa8f2cbf33 example/x11: Set raw terminal mode manually instead of with cfmakeraw()
OpenSolaris has no cfmakeraw() so to make the example more portable
we simply do the equivalent operations on struct termios ourselves.

Thanks to Tom Weber for reporting this problem, and finding a solution.
2012-02-29 22:27:18 +01:00
Daniel Stenberg
e07342443f sftp_write: cannot return acked data *and* EAGAIN
Whenever we have acked data and is about to call a function that *MAY*
return EAGAIN we must return the number now and wait to get called
again. Our API only allows data *or* EAGAIN and we must never try to get
both.
2012-02-17 16:06:21 +01:00
Peter Stuge
4774d500e7 example/x11: Build only when sys/un.h is found by configure
The example can't be built on systems without AF_UNIX sockets.
2012-02-13 00:40:24 +01:00
Alexander Lamaison
1403847429 Simplified sftp_read.
Removed the total_read variable that originally must have tracked how
much data had been written to the buffer.  With non-blocking reads, we
must return straight away once we have read data into the buffer so this
variable served not purpose.

I think it was still hanging around in case the initial processing of
'leftover' data meant we wrote to the buffer but this case, like the
others, must return immediately.  Now that it does, the last remaining
need for the variable is gone.
2012-02-10 16:31:38 +01:00
Alexander Lamaison
0d824e5702 Cleaned up sftp_read and added more explanation.
Replaced the gotos which were implementing the state machine with
a switch statement which makes the states more explicit.
2012-02-10 16:31:38 +01:00
Daniel Stenberg
9836b0889f sftp_read: avoid data *and* EAGAIN
Whenever we have data and is about to call a function that *MAY* return
EAGAIN we must return the data now and wait to get called again. Our API
only allows data *or* EAGAIN and we must never try to get both.
2012-02-10 16:31:38 +01:00
Peter Stuge
e394987911 Add a tcpip-forward example which demonstrates remote port forwarding 2012-02-02 17:25:45 +01:00
Peter Stuge
e95c7de453 libssh2.h: Add missing prototype for libssh2_session_banner_set() 2012-02-01 11:35:05 +01:00
Peter Stuge
effbb72192 example/subsystem_netconf.c: Return error when read buffer is too small
Also remove a little redundancy in the read loop condition.
2012-02-01 11:35:05 +01:00
Peter Stuge
0ebe6f44bd example/subsystem_netconf.c: Add a missing newline in an error message 2012-02-01 11:35:00 +01:00
Peter Stuge
b3ade9a63e Fix undefined reference to _libssh_error in libgcrypt backend
Commit 209de22299 introduced a function
call to a non-existing function, and since then the libgcrypt backend
has not been buildable.
2012-02-01 09:53:44 +01:00
Daniel Stenberg
388920cf3c RELEASE-NOTES: synced with 6bd584d29 for 1.4.0 2012-01-31 23:23:04 +01:00
Daniel Stenberg
6bd584d293 s/1.3.1/1.4.0
We're bumping the minor number
2012-01-31 23:22:30 +01:00