1
1

757 Коммитов

Автор SHA1 Сообщение Дата
Daniel Stenberg
ff40c58743 sftp_read: extend and clarify the documentation 2011-09-08 23:02:58 +02:00
Daniel Stenberg
10b66cef08 sftp_read: cap the read ahead maximum amount
Now we only go up to LIBSSH2_CHANNEL_WINDOW_DEFAULT*30 bytes SFTP read
ahead, which currently equals 64K*30 == 1966080 bytes.
2011-09-08 22:47:38 +02:00
Daniel Stenberg
81bdcf61f3 _libssh2_channel_read: fix non-blocking window adjusting
If EAGAIN is returned when adjusting the receive window, we must not
read from the transport directly until we've finished the adjusting.
2011-09-08 14:25:25 +02:00
Daniel Stenberg
7c9b84d1d1 sftp_read: added documenting comment
Taken from some recent email conversations I added some descriptions of
the logic in sftp_read() to aid readers.
2011-09-06 23:31:07 +02:00
Daniel Stenberg
296d57bb2c sftp_read: a short read is not end of file
A returned READ packet that is short will now only reduce the
offset.

This is a temporary fix as it is slightly better than the previous
approach but still not very good.
2011-09-06 22:43:26 +02:00
liuzl
9e79031ad7 _libssh2_packet_add: adjust window size when truncating
When receiving more data than what the window size allows on a
particular channel, make sure that the window size is adjusted in that
case too. Previously it would only adjust the window in the non-error
case.
2011-08-31 10:45:12 +02:00
Guenter Knauf
689fc5c596 Silent compiler warning with MinGW64. 2011-08-29 15:30:18 +02:00
Guenter Knauf
7de77e94bf Fixed aes_ctr_do_cipher() signature. 2011-08-29 13:27:46 +02:00
liuzl
8c0294db66 libssh2_sftp_seek64: flush packetlist and buffered data
When seeking to a new position, flush the packetlist and buffered data
to prevent already received or pending data to wrongly get used when
sftp-reading from the new offset within the file.
2011-08-26 13:47:35 +02:00
Daniel Stenberg
900c90ccbe sftp_read: advance offset correctly for buffered copies
In the case where a read packet has been received from the server, but
the entire contents couldn't be copied to the user-buffer, the data is
instead buffered and copied to the user's buffer in the next invocation
of sftp_read(). When that "extra" copy is made, the 'offset' pointer was
not advanced accordingly.

The biggest impact of this flaw was that the 'already' variable at the
top of the function that figures out how much data "ahead" that has
already been asked for would slowly go more and more out of sync, which
could lead to the file not being read all the way to the end.

This problem was most noticable in cases where the application would
only try to read the exact file size amount, like curl does. In the
examples libssh2 provides the sftp read function is most often called
with a fixed size large buffer and then the bug would not appear as
easily.

This bug was introduced in the SFTP rewrite in 1.2.8.

Bug: http://curl.haxx.se/mail/lib-2011-08/0305.html
     http://www.libssh2.org/mail/libssh2-devel-archive-2011-08/0085.shtml
2011-08-26 11:45:48 +02:00
Daniel Stenberg
d5eec4aad9 wrap some long lines < 80 columns 2011-08-25 22:41:17 +02:00
Daniel Stenberg
19864f0f64 LIBSSH2_RECV: fix typo, use the RECV_FD macro 2011-08-25 22:38:46 +02:00
Henrik Nordstrom
7aa4bfc671 Custom callbacks for performing low level socket I/O 2011-08-21 15:19:44 +02:00
Daniel Stenberg
3c71ad4fce _libssh2_channel_write: handle window_size == 0 better
When about to send data on the channel and the window size is 0, we must
not just return 0 if the transport_read() function returned EAGAIN as it
then causes a busy-loop.

Bug: http://libssh2.org/mail/libssh2-devel-archive-2011-08/0011.shtml
2011-08-11 14:36:05 +02:00
Daniel Stenberg
79f48e4881 gettimeofday: fix name space pollution
For systems without its own gettimeofday() implementation, we still must
not provide one outside our namespace.

Reported by: Bill Segall
2011-08-05 23:50:22 +02:00
Daniel Stenberg
45ffdcfe3c userauth_keyboard_interactive: fix buffer overflow
Partly reverse 566894494b4972ae12 which was simplifying the code far too
much and ended up overflowing a buffer within the LIBSSH2_SESSION
struct. Back to allocating the buffer properly like it used to do.

Bug: http://www.libssh2.org/mail/libssh2-devel-archive-2011-06/0032.shtml
Reported by: Alfred Gebert
2011-06-29 21:32:50 +02:00
Alfred Gebert
733bf877f8 _libssh2_recv(): handle ENOENT error as EAGAIN
A sftp session failed with error "failure establishing ssh session" on
Solaris and HP-UX. Sometimes the first recv() function call sets errno
to ENOENT. In the man pages for recv of Solaris and HP-UX the error
ENOENT is not documented.

I tested Solaris SPARC and x86, HP-UX i64, AIX, Windows and Linux.
2011-06-28 22:43:50 +02:00
Daniel Stenberg
2db7d9c655 agent_list_identities: fix out of scope access
An auto variable out of scope was being referenced and used.

fixes #220
2011-06-20 00:08:51 +02:00
Daniel Stenberg
9a24b03402 _libssh2_wait_socket: fix timeouts for poll() uses 2011-06-20 00:08:51 +02:00
Daniel Stenberg
5b004a4b67 keyb-interactive: add the fixed buffer
Belongs to commit 5668944
2011-05-31 23:35:49 +02:00
Daniel Stenberg
da64618c9a code cleanup: don't use C99/c++ comments
We aim for C89 compliance
2011-05-31 23:35:06 +02:00
Daniel Stenberg
566894494b keyb-interactive: allow zero length fields
Allow zero length fields so they don't cause malloc(0) calls

Avoid free()ing NULL pointers

Avoid a malloc of a fixed 5 byte buffer.
2011-05-31 23:33:56 +02:00
Daniel Stenberg
dade304c47 userauth_keyboard_interactive: skip code on zero length auth 2011-05-25 22:39:25 +02:00
Douglas Masterson
ce8f0b29a4 session_startup: init state properly
libssh2_session_startup() didn't set the state correctly so it could get
confused.

Fixes #218
2011-05-05 23:24:40 +02:00
Daniel Stenberg
4ed1e9d96b BLOCK_ADJUST_ERRNO: move rc to right level
We can't declare the variable within the block and use it in the final
do-while() expression to be properly portable C89.
2011-05-04 23:06:13 +02:00
Matt Lilley
c5ec167881 adds a timeout to blocking calls
Fixes bug #160 as per Daniel's suggestion

Adds libssh2_session_set_timeout() and libssh2_session_get_timeout()
2011-05-04 22:58:21 +02:00
Daniel Stenberg
e652b4c7b8 SCP: fix incorrect error code
After an error occurs in libssh2_scp_recv() or libssh2_scp_send(), the
function libssh2_session_last_error() would return
LIBSSH2_ERROR_SOCKET_NONE on error.

Bug: http://trac.libssh2.org/ticket/216
Patch by: "littlesavage"

Fixes #216
2011-05-02 22:27:29 +02:00
Daniel Stenberg
d881e7e8ef sftp_write: clean offsets on error
When an error has occurred on FXP_WRITE, we must make sure that the
offset, sent offset and acked counter are reset properly.
2011-04-13 13:59:50 +02:00
Daniel Stenberg
9f477073bc sftp_write: flush the packetlist on error
When an error occurs during write, flush the entire list of pending
outgoing SFTP packets.
2011-04-13 10:30:30 +02:00
Daniel Stenberg
2e352d3085 sftp_write: handle FXP_WRITE errors
When an sftp server returns an error back on write, make sure the
function bails out and returns the proper error.
2011-03-30 11:35:37 +02:00
Alexander Lamaison
527c1b2def Support unlimited number of host names in a single line of the known_hosts file.
Previously the code assumed either a single host name or a hostname,ip-address pair.  However, according to the spec [1], there can be any number of comma separated host names or IP addresses.

[1] http://www.openbsd.org/cgi-bin/man.cgi?query=sshd&sektion=8
2011-03-13 00:29:39 +00:00
Peter Stuge
516fa7fdd9 Don't save allocated packet size until it has actually been allocated
The allocated packet size is internal state which needs to match reality
in order to avoid problems. This commit fixes #211.
2011-02-26 05:21:01 +01:00
Alfred Gebert
3ce2628140 session_startup: manage server data before server identification
Fix the bug that libssh2 could not connect if the sftp server
sends data before sending the version string.

http://tools.ietf.org/html/rfc4253#section-4.2

"The server MAY send other lines of data before sending the version
string.  Each line SHOULD be terminated by a Carriage Return and Line
Feed.  Such lines MUST NOT begin with "SSH-", and SHOULD be encoded
in ISO-10646 UTF-8 [RFC3629] (language is not specified).  Clients
MUST be able to process such lines."
2011-02-21 23:19:27 +01:00
Alfred Gebert
ad88325b3f fullpacket: decompression only after init
The buffer for the decompression (remote.comp_abstract) is initialised
in time when it is needed.  With this fix decompression is disabled when
the buffer (remote.comp_abstract) is not initialised.

Bug: http://trac.libssh2.org/ticket/200
2011-02-16 13:57:58 +01:00
Daniel Stenberg
2db4863e6e _libssh2_channel_read: store last error
When the transport layer returns EAGAIN this function didn't call
_libssh2_error() which made the last_error not get set.
2011-02-15 23:21:38 +01:00
Daniel Stenberg
691cabc048 sftp_write: clarified the comment header 2011-01-20 09:01:59 +01:00
Daniel Stenberg
90b4b4073f sftp_read: avoid wrapping counter to insanity
As pointed out in bug #206, if a second invoke of libssh2_sftp_read()
would shrink the buffer size, libssh2 would go nuts and send out read
requests like crazy. This was due to an unsigned variable turning
"negative" by some wrong math, and that value would be the amount of
data attempt to pre-buffer!

Bug: http://trac.libssh2.org/ticket/206
2011-01-17 22:39:47 +01:00
Daniel Stenberg
8ce9a66ccf sftp_packet_read: use 32bit variables for 32bit data 2011-01-09 00:34:09 +01:00
Daniel Stenberg
164838c7dd sftp_readdir: return error if buffer is too small
If asked to read data into a buffer and the buffer is too small to hold
the data, this function now returns an error instead of as previously
just copy as much as fits.
2011-01-04 14:30:04 +01:00
Daniel Stenberg
f9b1b95059 sftp_symlink: return error if receive buffer too small
and clean up some variable type mismatches

Discussion: http://www.libssh2.org/mail/libssh2-devel-archive-2011-01/0001.shtml
2011-01-04 14:15:57 +01:00
Daniel Stenberg
0da37e0924 channel_request_pty_size: fix reqPTY_state
The state variable isn't properly set so every other call to the
function fails!

Bug: http://libssh2.org/mail/libssh2-devel-archive-2010-12/0096.shtml
Reported by: Steve Legg
2011-01-01 16:16:32 +01:00
Daniel Stenberg
4552c73cd5 data size: cleanup
Fix 64bit warnings by using (s)size_t and dedicated uint32_t types more.
2010-12-30 00:09:53 +01:00
Guenter Knauf
aa4f861643 Expanded tabs to spaces. 2010-12-22 14:27:55 +01:00
Joey Degges
fd691deb17 _libssh2_ntohu64: fix conversion from network bytes to uint64
Cast individual bytes to uint64 to avoid overflow in arithmetic.
2010-12-21 13:15:42 +01:00
Daniel Stenberg
3ab7af095a crypto: unify the generic functions
Added crypto.h that is the unified header to include when using crypto
functionality. It should be the only header that needs to adapt to the
underlying crypto library in use. It provides the set of prototypes that
are library agnostic.
2010-12-19 00:00:50 +01:00
Mark Smith
5b1a7ec2f1 userauth: derive publickey from private
Pass a NULL pointer for the publickey parameter of
libssh2_userauth_publickey_fromfile and
libssh2_userauth_hostbased_fromfile functions.  In this case, the
functions recompute the public key from the private key file data.

This is work done by Jean-Louis CHARTON
<Jean-Louis.CHARTON@oikialog.com>, then adapted by Mark Smith and
slightly edited further by me Daniel.

WARNING: this does leave the feature NOT WORKING when libssh2 is built
to use libgcrypt instead of OpenSSL simply due to lack of
implementation.
2010-12-18 23:38:08 +01:00
Daniel Stenberg
2165ceacd3 _libssh2_packet_add: fix SSH_MSG_DEBUG weirdness
I believe I may have caused this weird typo style error when I cleaned
up this function a while ago. Corrected now.
2010-12-15 21:57:06 +01:00
Daniel Stenberg
121237ce2f uint32: more longs converted to proper types
I also moved the MAC struct over to the mac.h header file and made sure
that the users of that struct include that file.
2010-12-15 09:52:18 +01:00
Daniel Stenberg
b3e832172b SFTP: more types to uint32_t
The 'num_names' field in the SSH_FXP_NAME response is an unsigned 32bit
value so we make sure to treat it like that.
2010-12-15 09:31:37 +01:00
Daniel Stenberg
3faa8bc940 SFTP: request_ids are uint32_t
I went over the code and made sure we use uint32_t all over for the
request_id data. It is an unsigned 32bit value on the wire.
2010-12-15 09:27:00 +01:00