Compare commits
16 Commits
libssh2-1.
...
libssh2-1.
Author | SHA1 | Date | |
---|---|---|---|
![]() |
507d5f96cf | ||
![]() |
84d8728835 | ||
![]() |
296d57bb2c | ||
![]() |
9e79031ad7 | ||
![]() |
689fc5c596 | ||
![]() |
31a9e8860d | ||
![]() |
b26c3e7cce | ||
![]() |
e4eeb85f01 | ||
![]() |
7de77e94bf | ||
![]() |
8c0294db66 | ||
![]() |
900c90ccbe | ||
![]() |
d5eec4aad9 | ||
![]() |
19864f0f64 | ||
![]() |
420f0b7793 | ||
![]() |
7aa4bfc671 | ||
![]() |
462996b064 |
@@ -26,10 +26,9 @@ vms/libssh2_make_kit.dcl vms/libssh2_make_lib.dcl vms/man2help.c \
|
||||
vms/readme.vms vms/libssh2_config.h
|
||||
|
||||
|
||||
WIN32FILES = win32/Makefile.win32 win32/libssh2.dsw \
|
||||
win32/config.mk win32/Makefile win32/test/Makefile.win32 \
|
||||
win32/libssh2_config.h win32/tests.dsp win32/rules.mk $(DSP) \
|
||||
win32/msvcproj.head win32/msvcproj.foot win32/libssh2.rc \
|
||||
WIN32FILES = win32/libssh2.dsw win32/config.mk win32/Makefile \
|
||||
win32/libssh2_config.h win32/tests.dsp win32/rules.mk $(DSP) \
|
||||
win32/msvcproj.head win32/msvcproj.foot win32/libssh2.rc \
|
||||
win32/Makefile.Watcom
|
||||
|
||||
EXTRA_DIST = $(WIN32FILES) buildconf $(NETWAREFILES) get_ver.awk HACKING \
|
||||
|
@@ -1,35 +1,19 @@
|
||||
libssh2 1.2.9
|
||||
libssh2 1.3.0
|
||||
|
||||
This release includes the following changes:
|
||||
|
||||
o Added libssh2_session_set_timeout() and libssh2_session_get_timeout()
|
||||
to make blocking calls get a timeout
|
||||
o Added custom callbacks for performing low level socket I/O
|
||||
|
||||
This release includes the following bugfixes:
|
||||
|
||||
o configure and pkg-config: fix $VERSION
|
||||
o s/\.NF/.nf/ to fix wrong macro name caught by man --warnings
|
||||
o keepalive: add first basic man pages
|
||||
o sftp_write: flush the packetlist on error
|
||||
o sftp_write: clean offsets on error
|
||||
o msvcproj: added libs and debug stuff
|
||||
o SCP: fix incorrect error code
|
||||
o session_startup: init state properly
|
||||
o sftp_write_sliding: send the complete file
|
||||
o userauth_keyboard_interactive: skip code on zero length auth
|
||||
o _libssh2_wait_socket: fix timeouts for poll() uses
|
||||
o agent_list_identities: fix out of scope access
|
||||
o _libssh2_recv(): handle ENOENT error as EAGAIN
|
||||
o userauth_keyboard_interactive: fix buffer overflow
|
||||
o removed man pages for non-existing functions!
|
||||
o gettimeofday: fix name space pollution
|
||||
o _libssh2_channel_write: handle window_size == 0 better
|
||||
o sftp_read: advance offset correctly for buffered copies
|
||||
o libssh2_sftp_seek64: flush packetlist and buffered data
|
||||
o _libssh2_packet_add: adjust window size when truncating
|
||||
o sftp_read: a short read is not end of file
|
||||
|
||||
This release would not have looked like this without help, code, reports and
|
||||
advice from friends like these:
|
||||
|
||||
Alfred Gebert, Dan Fandrich, Douglas Masterson, Guenter Knauf, Matt Lilley,
|
||||
Mikhail Gusarov, Peter Stuge, zl liu, Paul Howarth, Mark Smith, Bill Segall,
|
||||
Henrik Nordstr<74>m
|
||||
Henrik Nordstrom, liuzl, Guenter Knauf
|
||||
|
||||
Thanks! (and sorry if I forgot to mention someone)
|
||||
|
@@ -33,6 +33,12 @@ Called when a mismatched MAC has been detected in the transport layer. If the
|
||||
function returns 0, the packet will be accepted nonetheless.
|
||||
.IP LIBSSH2_CALLBACK_X11
|
||||
Called when an X11 connection has been accepted
|
||||
.IP LIBSSH2_CALLBACK_SEND
|
||||
Called when libssh2 wants to send some data on the connection.
|
||||
Can be set to a custom function to handle I/O your own way.
|
||||
.IP LIBSSH2_CALLBACK_RECV
|
||||
Called when libssh2 wants to receive some data from the connection.
|
||||
Can be set to a custom function to handle I/O your own way.
|
||||
.SH RETURN VALUE
|
||||
Pointer to previous callback handler. Returns NULL if no prior callback
|
||||
handler was set or the callback type was unknown.
|
||||
|
@@ -25,7 +25,7 @@
|
||||
#endif
|
||||
|
||||
#ifndef INADDR_NONE
|
||||
#define INADDR_NONE (in_addr_t)-1
|
||||
#define INADDR_NONE (in_addr_t)~0
|
||||
#endif
|
||||
|
||||
const char *keyfile1 = "/home/username/.ssh/id_rsa.pub";
|
||||
@@ -41,7 +41,7 @@ enum {
|
||||
AUTH_PUBLICKEY
|
||||
};
|
||||
|
||||
int netconf_write(LIBSSH2_CHANNEL *channel, const char *buf, size_t len)
|
||||
static int netconf_write(LIBSSH2_CHANNEL *channel, const char *buf, size_t len)
|
||||
{
|
||||
int i;
|
||||
ssize_t wr = 0;
|
||||
@@ -53,12 +53,13 @@ int netconf_write(LIBSSH2_CHANNEL *channel, const char *buf, size_t len)
|
||||
return -1;
|
||||
}
|
||||
wr += i;
|
||||
} while (i > 0 && wr < len);
|
||||
} while (i > 0 && wr < (ssize_t)len);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int netconf_read_until(LIBSSH2_CHANNEL *channel, const char *endtag, char *buf, size_t buflen)
|
||||
static int netconf_read_until(LIBSSH2_CHANNEL *channel, const char *endtag,
|
||||
char *buf, size_t buflen)
|
||||
{
|
||||
ssize_t len, rd = 0;
|
||||
char *endreply, *specialsequence = NULL;
|
||||
@@ -97,7 +98,6 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
int rc, sock = -1, i, auth = AUTH_NONE;
|
||||
struct sockaddr_in sin;
|
||||
socklen_t sinlen;
|
||||
const char *fingerprint;
|
||||
char *userauthlist;
|
||||
LIBSSH2_SESSION *session;
|
||||
@@ -106,12 +106,9 @@ int main(int argc, char *argv[])
|
||||
ssize_t len;
|
||||
|
||||
#ifdef WIN32
|
||||
char sockopt;
|
||||
WSADATA wsadata;
|
||||
|
||||
WSAStartup(MAKEWORD(2,0), &wsadata);
|
||||
#else
|
||||
int sockopt;
|
||||
#endif
|
||||
|
||||
if (argc > 1)
|
||||
|
@@ -46,13 +46,13 @@
|
||||
to make the BANNER define (used by src/session.c) be a valid SSH
|
||||
banner. Release versions have no appended strings and may of course not
|
||||
have dashes either. */
|
||||
#define LIBSSH2_VERSION "1.2.9_DEV"
|
||||
#define LIBSSH2_VERSION "1.3.0_DEV"
|
||||
|
||||
/* The numeric version number is also available "in parts" by using these
|
||||
defines: */
|
||||
#define LIBSSH2_VERSION_MAJOR 1
|
||||
#define LIBSSH2_VERSION_MINOR 2
|
||||
#define LIBSSH2_VERSION_PATCH 9
|
||||
#define LIBSSH2_VERSION_MINOR 3
|
||||
#define LIBSSH2_VERSION_PATCH 0
|
||||
|
||||
/* This is the numeric version of the libssh2 version number, meant for easier
|
||||
parsing and comparions by programs. The LIBSSH2_VERSION_NUM define will
|
||||
@@ -69,7 +69,7 @@
|
||||
and it is always a greater number in a more recent release. It makes
|
||||
comparisons with greater than and less than work.
|
||||
*/
|
||||
#define LIBSSH2_VERSION_NUM 0x010209
|
||||
#define LIBSSH2_VERSION_NUM 0x010300
|
||||
|
||||
/*
|
||||
* This is the date and time when the full source package was created. The
|
||||
@@ -237,12 +237,22 @@ typedef struct _LIBSSH2_USERAUTH_KBDINT_RESPONSE
|
||||
void name(LIBSSH2_SESSION *session, void **session_abstract, \
|
||||
LIBSSH2_CHANNEL *channel, void **channel_abstract)
|
||||
|
||||
/* I/O callbacks */
|
||||
#define LIBSSH2_RECV_FUNC(name) ssize_t name(int socket, \
|
||||
void *buffer, size_t length, \
|
||||
int flags, void **abstract)
|
||||
#define LIBSSH2_SEND_FUNC(name) ssize_t name(int socket, \
|
||||
const void *buffer, size_t length,\
|
||||
int flags, void **abstract)
|
||||
|
||||
/* libssh2_session_callback_set() constants */
|
||||
#define LIBSSH2_CALLBACK_IGNORE 0
|
||||
#define LIBSSH2_CALLBACK_DEBUG 1
|
||||
#define LIBSSH2_CALLBACK_DISCONNECT 2
|
||||
#define LIBSSH2_CALLBACK_MACERROR 3
|
||||
#define LIBSSH2_CALLBACK_X11 4
|
||||
#define LIBSSH2_CALLBACK_SEND 5
|
||||
#define LIBSSH2_CALLBACK_RECV 6
|
||||
|
||||
/* libssh2_session_method_pref() constants */
|
||||
#define LIBSSH2_METHOD_KEX 0
|
||||
|
@@ -79,7 +79,7 @@ endif
|
||||
CP = cp -afv
|
||||
# RM = rm -f
|
||||
# Here you can find a native Win32 binary of the original awk:
|
||||
# http://www.gknw.net/development/prgtools/awk-20070501.zip
|
||||
# http://www.gknw.net/development/prgtools/awk-20100523.zip
|
||||
AWK = awk
|
||||
# If you want to mark the target as MTSAFE you will need a tool for
|
||||
# generating the xdc data for the linker; here's a minimal tool:
|
||||
|
@@ -73,7 +73,7 @@ endif
|
||||
CP = cp -afv
|
||||
# RM = rm -f
|
||||
# Here you can find a native Win32 binary of the original awk:
|
||||
# http://www.gknw.net/development/prgtools/awk-20070501.zip
|
||||
# http://www.gknw.net/development/prgtools/awk-20100523.zip
|
||||
AWK = awk
|
||||
# If you want to mark the target as MTSAFE you will need a tool for
|
||||
# generating the xdc data for the linker; here's a minimal tool:
|
||||
|
@@ -177,7 +177,7 @@ agent_transact_unix(LIBSSH2_AGENT *agent, agent_transaction_ctx_t transctx)
|
||||
/* Send the length of the request */
|
||||
if (transctx->state == agent_NB_state_request_created) {
|
||||
_libssh2_htonu32(buf, transctx->request_len);
|
||||
rc = _libssh2_send(agent->fd, buf, sizeof buf, 0);
|
||||
rc = LIBSSH2_SEND_FD(agent->session, agent->fd, buf, sizeof buf, 0);
|
||||
if (rc == -EAGAIN)
|
||||
return LIBSSH2_ERROR_EAGAIN;
|
||||
else if (rc < 0)
|
||||
@@ -188,7 +188,7 @@ agent_transact_unix(LIBSSH2_AGENT *agent, agent_transaction_ctx_t transctx)
|
||||
|
||||
/* Send the request body */
|
||||
if (transctx->state == agent_NB_state_request_length_sent) {
|
||||
rc = _libssh2_send(agent->fd, transctx->request,
|
||||
rc = LIBSSH2_SEND_FD(agent->session, agent->fd, transctx->request,
|
||||
transctx->request_len, 0);
|
||||
if (rc == -EAGAIN)
|
||||
return LIBSSH2_ERROR_EAGAIN;
|
||||
@@ -200,7 +200,7 @@ agent_transact_unix(LIBSSH2_AGENT *agent, agent_transaction_ctx_t transctx)
|
||||
|
||||
/* Receive the length of a response */
|
||||
if (transctx->state == agent_NB_state_request_sent) {
|
||||
rc = _libssh2_recv(agent->fd, buf, sizeof buf, 0);
|
||||
rc = LIBSSH2_RECV_FD(agent->session, agent->fd, buf, sizeof buf, 0);
|
||||
if (rc < 0) {
|
||||
if (rc == -EAGAIN)
|
||||
return LIBSSH2_ERROR_EAGAIN;
|
||||
@@ -218,7 +218,7 @@ agent_transact_unix(LIBSSH2_AGENT *agent, agent_transaction_ctx_t transctx)
|
||||
|
||||
/* Receive the response body */
|
||||
if (transctx->state == agent_NB_state_response_length_received) {
|
||||
rc = _libssh2_recv(agent->fd, transctx->response,
|
||||
rc = LIBSSH2_RECV_FD(agent->session, agent->fd, transctx->response,
|
||||
transctx->response_len, 0);
|
||||
if (rc < 0) {
|
||||
if (rc == -EAGAIN)
|
||||
|
@@ -163,13 +163,31 @@ static inline int writev(int sock, struct iovec *iov, int nvecs)
|
||||
session->ssh_msg_debug((session), (always_display), (message), \
|
||||
(message_len), (language), (language_len), \
|
||||
&(session)->abstract)
|
||||
#define LIBSSH2_DISCONNECT(session, reason, message, message_len, language, language_len) \
|
||||
session->ssh_msg_disconnect((session), (reason), (message), (message_len), (language), (language_len), &(session)->abstract)
|
||||
#define LIBSSH2_DISCONNECT(session, reason, message, message_len, \
|
||||
language, language_len) \
|
||||
session->ssh_msg_disconnect((session), (reason), (message), \
|
||||
(message_len), (language), (language_len), \
|
||||
&(session)->abstract)
|
||||
|
||||
#define LIBSSH2_MACERROR(session, data, datalen) session->macerror((session), (data), (datalen), &(session)->abstract)
|
||||
#define LIBSSH2_X11_OPEN(channel, shost, sport) channel->session->x11(((channel)->session), (channel), (shost), (sport), (&(channel)->session->abstract))
|
||||
#define LIBSSH2_MACERROR(session, data, datalen) \
|
||||
session->macerror((session), (data), (datalen), &(session)->abstract)
|
||||
#define LIBSSH2_X11_OPEN(channel, shost, sport) \
|
||||
channel->session->x11(((channel)->session), (channel), \
|
||||
(shost), (sport), (&(channel)->session->abstract))
|
||||
|
||||
#define LIBSSH2_CHANNEL_CLOSE(session, channel) channel->close_cb((session), &(session)->abstract, (channel), &(channel)->abstract)
|
||||
#define LIBSSH2_CHANNEL_CLOSE(session, channel) \
|
||||
channel->close_cb((session), &(session)->abstract, \
|
||||
(channel), &(channel)->abstract)
|
||||
|
||||
#define LIBSSH2_SEND_FD(session, fd, buffer, length, flags) \
|
||||
session->send(fd, buffer, length, flags, &session->abstract)
|
||||
#define LIBSSH2_RECV_FD(session, fd, buffer, length, flags) \
|
||||
session->recv(fd, buffer, length, flags, &session->abstract)
|
||||
|
||||
#define LIBSSH2_SEND(session, buffer, length, flags) \
|
||||
LIBSSH2_SEND_FD(session, session->socket_fd, buffer, length, flags)
|
||||
#define LIBSSH2_RECV(session, buffer, length, flags) \
|
||||
LIBSSH2_RECV_FD(session, session->socket_fd, buffer, length, flags)
|
||||
|
||||
typedef struct _LIBSSH2_KEX_METHOD LIBSSH2_KEX_METHOD;
|
||||
typedef struct _LIBSSH2_HOSTKEY_METHOD LIBSSH2_HOSTKEY_METHOD;
|
||||
@@ -539,6 +557,8 @@ struct _LIBSSH2_SESSION
|
||||
LIBSSH2_DISCONNECT_FUNC((*ssh_msg_disconnect));
|
||||
LIBSSH2_MACERROR_FUNC((*macerror));
|
||||
LIBSSH2_X11_OPEN_FUNC((*x11));
|
||||
LIBSSH2_SEND_FUNC((*send));
|
||||
LIBSSH2_RECV_FUNC((*recv));
|
||||
|
||||
/* Method preferences -- NULL yields "load order" */
|
||||
char *kex_prefs;
|
||||
@@ -794,8 +814,10 @@ struct _LIBSSH2_SESSION
|
||||
|
||||
/* session.flag helpers */
|
||||
#ifdef MSG_NOSIGNAL
|
||||
#define LIBSSH2_SOCKET_SEND_FLAGS(session) (((session)->flag.sigpipe) ? 0 : MSG_NOSIGNAL)
|
||||
#define LIBSSH2_SOCKET_RECV_FLAGS(session) (((session)->flag.sigpipe) ? 0 : MSG_NOSIGNAL)
|
||||
#define LIBSSH2_SOCKET_SEND_FLAGS(session) \
|
||||
(((session)->flag.sigpipe) ? 0 : MSG_NOSIGNAL)
|
||||
#define LIBSSH2_SOCKET_RECV_FLAGS(session) \
|
||||
(((session)->flag.sigpipe) ? 0 : MSG_NOSIGNAL)
|
||||
#else
|
||||
/* If MSG_NOSIGNAL isn't defined we're SOL on blocking SIGPIPE */
|
||||
#define LIBSSH2_SOCKET_SEND_FLAGS(session) 0
|
||||
@@ -972,9 +994,9 @@ _libssh2_debug(LIBSSH2_SESSION * session, int context, const char *format, ...)
|
||||
#define SSH_OPEN_RESOURCE_SHORTAGE 4
|
||||
|
||||
ssize_t _libssh2_recv(libssh2_socket_t socket, void *buffer,
|
||||
size_t length, int flags);
|
||||
size_t length, int flags, void **abstract);
|
||||
ssize_t _libssh2_send(libssh2_socket_t socket, const void *buffer,
|
||||
size_t length, int flags);
|
||||
size_t length, int flags, void **abstract);
|
||||
|
||||
#define LIBSSH2_READ_TIMEOUT 60 /* generic timeout in seconds used when
|
||||
waiting for more data to arrive */
|
||||
|
@@ -94,7 +94,7 @@ static int wsa2errno(void)
|
||||
* Replacement for the standard recv, return -errno on failure.
|
||||
*/
|
||||
ssize_t
|
||||
_libssh2_recv(libssh2_socket_t sock, void *buffer, size_t length, int flags)
|
||||
_libssh2_recv(libssh2_socket_t sock, void *buffer, size_t length, int flags, void **abstract)
|
||||
{
|
||||
ssize_t rc = recv(sock, buffer, length, flags);
|
||||
#ifdef WIN32
|
||||
@@ -126,7 +126,7 @@ _libssh2_recv(libssh2_socket_t sock, void *buffer, size_t length, int flags)
|
||||
*/
|
||||
ssize_t
|
||||
_libssh2_send(libssh2_socket_t sock, const void *buffer, size_t length,
|
||||
int flags)
|
||||
int flags, void **abstract)
|
||||
{
|
||||
ssize_t rc = send(sock, buffer, length, flags);
|
||||
#ifdef WIN32
|
||||
|
@@ -257,7 +257,7 @@ aes_ctr_init(EVP_CIPHER_CTX *ctx, const unsigned char *key,
|
||||
static int
|
||||
aes_ctr_do_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
|
||||
const unsigned char *in,
|
||||
unsigned int inl) /* encrypt/decrypt data */
|
||||
size_t inl) /* encrypt/decrypt data */
|
||||
{
|
||||
aes_ctr_ctx *c = EVP_CIPHER_CTX_get_app_data(ctx);
|
||||
unsigned char b1[AES_BLOCK_SIZE];
|
||||
|
@@ -706,6 +706,7 @@ _libssh2_packet_add(LIBSSH2_SESSION * session, unsigned char *data,
|
||||
"Remote sent more data than current "
|
||||
"window allows, truncating");
|
||||
datalen = channelp->remote.window_size + data_head;
|
||||
channelp->remote.window_size = 0;
|
||||
}
|
||||
else
|
||||
/* Now that we've received it, shrink our window */
|
||||
|
@@ -889,7 +889,7 @@ scp_send(LIBSSH2_SESSION * session, const char *path, int mode,
|
||||
session->scpSend_response_len =
|
||||
snprintf((char *) session->scpSend_response,
|
||||
LIBSSH2_SCP_RESPONSE_BUFLEN, "T%ld 0 %ld 0\n",
|
||||
mtime, atime);
|
||||
(long)mtime, (long)atime);
|
||||
_libssh2_debug(session, LIBSSH2_TRACE_SCP, "Sent %s",
|
||||
session->scpSend_response);
|
||||
}
|
||||
|
@@ -115,7 +115,7 @@ banner_receive(LIBSSH2_SESSION * session)
|
||||
/* no incoming block yet! */
|
||||
session->socket_block_directions &= ~LIBSSH2_SESSION_BLOCK_INBOUND;
|
||||
|
||||
ret = _libssh2_recv(session->socket_fd, &c, 1,
|
||||
ret = LIBSSH2_RECV(session, &c, 1,
|
||||
LIBSSH2_SOCKET_RECV_FLAGS(session));
|
||||
if (ret < 0) {
|
||||
if(session->api_block_mode || (ret != -EAGAIN))
|
||||
@@ -227,7 +227,7 @@ banner_send(LIBSSH2_SESSION * session)
|
||||
/* no outgoing block yet! */
|
||||
session->socket_block_directions &= ~LIBSSH2_SESSION_BLOCK_OUTBOUND;
|
||||
|
||||
ret = _libssh2_send(session->socket_fd,
|
||||
ret = LIBSSH2_SEND(session,
|
||||
banner + session->banner_TxRx_total_send,
|
||||
banner_len - session->banner_TxRx_total_send,
|
||||
LIBSSH2_SOCKET_SEND_FLAGS(session));
|
||||
@@ -481,6 +481,8 @@ libssh2_session_init_ex(LIBSSH2_ALLOC_FUNC((*my_alloc)),
|
||||
session->alloc = local_alloc;
|
||||
session->free = local_free;
|
||||
session->realloc = local_realloc;
|
||||
session->send = _libssh2_send;
|
||||
session->recv = _libssh2_recv;
|
||||
session->abstract = abstract;
|
||||
session->api_timeout = 0; /* timeout-free API by default */
|
||||
session->api_block_mode = 1; /* blocking API by default */
|
||||
@@ -532,6 +534,15 @@ libssh2_session_callback_set(LIBSSH2_SESSION * session,
|
||||
session->x11 = callback;
|
||||
return oldcb;
|
||||
|
||||
case LIBSSH2_CALLBACK_SEND:
|
||||
oldcb = session->send;
|
||||
session->send = callback;
|
||||
return oldcb;
|
||||
|
||||
case LIBSSH2_CALLBACK_RECV:
|
||||
oldcb = session->recv;
|
||||
session->recv = callback;
|
||||
return oldcb;
|
||||
}
|
||||
_libssh2_debug(session, LIBSSH2_TRACE_TRANS, "Setting Callback %d", cbtype);
|
||||
|
||||
|
22
src/sftp.c
22
src/sftp.c
@@ -1098,6 +1098,7 @@ static ssize_t sftp_read(LIBSSH2_SFTP_HANDLE * handle, char *buffer,
|
||||
|
||||
total_read += copy;
|
||||
filep->data_left -= copy;
|
||||
filep->offset += copy;
|
||||
|
||||
if(filep->data_left)
|
||||
return total_read;
|
||||
@@ -1241,9 +1242,12 @@ static ssize_t sftp_read(LIBSSH2_SFTP_HANDLE * handle, char *buffer,
|
||||
return _libssh2_error(session, LIBSSH2_ERROR_SFTP_PROTOCOL,
|
||||
"SFTP Protocol badness");
|
||||
|
||||
if(rc32 != chunk->len)
|
||||
/* a short read means this is the last read in the file */
|
||||
filep->eof = TRUE;
|
||||
if(rc32 != chunk->len) {
|
||||
/* a short read does not imply end of file, but we must adjust
|
||||
the offset_sent since it was advanced with a full
|
||||
chunk->len before */
|
||||
filep->offset_sent -= (chunk->len - rc32);
|
||||
}
|
||||
|
||||
if(total_read + rc32 > buffer_size) {
|
||||
/* figure out the overlap amount */
|
||||
@@ -1858,8 +1862,18 @@ libssh2_sftp_fstat_ex(LIBSSH2_SFTP_HANDLE *hnd,
|
||||
LIBSSH2_API void
|
||||
libssh2_sftp_seek64(LIBSSH2_SFTP_HANDLE *handle, libssh2_uint64_t offset)
|
||||
{
|
||||
if(handle)
|
||||
if(handle) {
|
||||
handle->u.file.offset = handle->u.file.offset_sent = offset;
|
||||
/* discard all pending requests and currently read data */
|
||||
sftp_packetlist_flush(handle);
|
||||
|
||||
/* free the left received buffered data */
|
||||
if (handle->u.file.data_left) {
|
||||
LIBSSH2_FREE(handle->sftp->channel->session, handle->u.file.data);
|
||||
handle->u.file.data_left = handle->u.file.data_len = 0;
|
||||
handle->u.file.data = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* libssh2_sftp_seek
|
||||
|
@@ -357,7 +357,7 @@ int _libssh2_transport_read(LIBSSH2_SESSION * session)
|
||||
|
||||
/* now read a big chunk from the network into the temp buffer */
|
||||
nread =
|
||||
_libssh2_recv(session->socket_fd, &p->buf[remainbuf],
|
||||
LIBSSH2_RECV(session, &p->buf[remainbuf],
|
||||
PACKETBUFSIZE - remainbuf,
|
||||
LIBSSH2_SOCKET_RECV_FLAGS(session));
|
||||
if (nread <= 0) {
|
||||
@@ -610,7 +610,7 @@ send_existing(LIBSSH2_SESSION *session, const unsigned char *data,
|
||||
/* number of bytes left to send */
|
||||
length = p->ototal_num - p->osent;
|
||||
|
||||
rc = _libssh2_send(session->socket_fd, &p->outbuf[p->osent], length,
|
||||
rc = LIBSSH2_SEND(session, &p->outbuf[p->osent], length,
|
||||
LIBSSH2_SOCKET_SEND_FLAGS(session));
|
||||
if (rc < 0)
|
||||
_libssh2_debug(session, LIBSSH2_TRACE_SOCKET,
|
||||
@@ -823,7 +823,7 @@ int _libssh2_transport_send(LIBSSH2_SESSION *session,
|
||||
|
||||
session->local.seqno++;
|
||||
|
||||
ret = _libssh2_send(session->socket_fd, p->outbuf, total_length,
|
||||
ret = LIBSSH2_SEND(session, p->outbuf, total_length,
|
||||
LIBSSH2_SOCKET_SEND_FLAGS(session));
|
||||
if (ret < 0)
|
||||
_libssh2_debug(session, LIBSSH2_TRACE_SOCKET,
|
||||
|
@@ -1,7 +1,7 @@
|
||||
#########################################################################
|
||||
#
|
||||
## Makefile for building libssh2 (Win32 version - gnu make)
|
||||
## Use: make -f Makefile.win32 [help|all|clean|dev|devclean|dist|distclean|dll|objclean]
|
||||
## Use: make -f Makefile.mingw [help|all|clean|dev|devclean|dist|distclean|dll|objclean]
|
||||
##
|
||||
## Comments to: Guenter Knauf http://www.gknw.net/phpbb
|
||||
#
|
||||
@@ -19,15 +19,20 @@ ifndef OPENSSL_PATH
|
||||
OPENSSL_PATH = ../../openssl-0.9.8r
|
||||
endif
|
||||
|
||||
# Edit the var below to set to your architecture or set environment var.
|
||||
ifndef ARCH
|
||||
ARCH = w32
|
||||
endif
|
||||
|
||||
# Edit the path below to point to your Distribution folder.
|
||||
ifndef DISTDIR
|
||||
DISTDIR = libssh2-$(LIBSSH2_VERSION_STR)-bin-w32
|
||||
DISTDIR = libssh2-$(LIBSSH2_VERSION_STR)-bin-$(ARCH)
|
||||
endif
|
||||
DISTARC = $(DISTDIR).zip
|
||||
|
||||
# Edit the path below to point to your Development folder.
|
||||
ifndef DEVLDIR
|
||||
DEVLDIR = libssh2-$(LIBSSH2_VERSION_STR)-dev-w32
|
||||
DEVLDIR = libssh2-$(LIBSSH2_VERSION_STR)-dev-$(ARCH)
|
||||
endif
|
||||
DEVLARC = $(DEVLDIR).zip
|
||||
|
||||
@@ -57,22 +62,38 @@ endif
|
||||
# Include the version info retrieved from libssh2.h
|
||||
-include $(OBJDIR)/version.inc
|
||||
|
||||
ifeq ($(findstring /sh,$(SHELL)),/sh)
|
||||
CP = cp -afv
|
||||
# RM = rm -f
|
||||
MD = mkdir
|
||||
RD = rm -fr
|
||||
DL = '
|
||||
DS = /
|
||||
else
|
||||
CP = copy
|
||||
RM = del /q /f 2>NUL
|
||||
MD = md
|
||||
RD = rd /q /s 2>NUL
|
||||
XX =
|
||||
DS = $(XX)\$(XX)
|
||||
endif
|
||||
# Here you can find a native Win32 binary of the original awk:
|
||||
# http://www.gknw.net/development/prgtools/awk-20100523.zip
|
||||
AWK = awk
|
||||
ZIP = zip -qzr9
|
||||
|
||||
# The following line defines your compiler.
|
||||
ifdef METROWERKS
|
||||
CC = mwcc
|
||||
else
|
||||
CC = $(CROSSPREFIX)gcc
|
||||
endif
|
||||
CP = cp -afv
|
||||
# RM = rm -f
|
||||
MD = mkdir
|
||||
# Here you can find a native Win32 binary of the original awk:
|
||||
# http://www.gknw.net/development/prgtools/awk-20070501.zip
|
||||
AWK = awk
|
||||
ZIP = zip -qzr9
|
||||
|
||||
# Global flags for all compilers
|
||||
CFLAGS = $(OPT) -D$(DB) -DWIN32 -DLIBSSH2_WIN32 # -DHAVE_CONFIG_H
|
||||
ifeq ($(ARCH),w64)
|
||||
CFLAGS += -D_AMD64_
|
||||
endif
|
||||
|
||||
ifeq ($(CC),mwcc)
|
||||
LD = mwld
|
||||
@@ -120,14 +141,6 @@ endif
|
||||
|
||||
CFLAGS += $(INCLUDES)
|
||||
|
||||
ifeq ($(findstring /sh,$(SHELL)),/sh)
|
||||
DL = '
|
||||
DS = /
|
||||
else
|
||||
XX =
|
||||
DS = $(XX)\$(XX)
|
||||
endif
|
||||
|
||||
vpath %.c . ../src
|
||||
|
||||
# include Makefile.inc to get CSOURCES define
|
||||
@@ -147,7 +160,7 @@ prebuild: $(OBJDIR) $(OBJDIR)/version.inc
|
||||
# libssh2_config.h
|
||||
|
||||
test: all
|
||||
$(MAKE) -C test -f Makefile.win32
|
||||
$(MAKE) -C test -f Makefile.mingw
|
||||
|
||||
$(OBJDIR)/%.o: %.c
|
||||
# @echo Compiling $<
|
||||
@@ -158,38 +171,38 @@ $(OBJDIR)/version.inc: ../include/libssh2.h $(OBJDIR)
|
||||
@$(AWK) -f ../get_ver.awk $< > $@
|
||||
|
||||
dist: all $(DISTDIR) $(DISTDIR)/readme.txt
|
||||
@-mkdir $(DISTDIR)$(DS)bin
|
||||
@-$(CP) ../INSTALL $(DISTDIR)
|
||||
@-$(CP) ../LICENSE $(DISTDIR)
|
||||
@-$(CP) ../README $(DISTDIR)
|
||||
@$(CP) $(TARGET).dll $(DISTDIR)/bin
|
||||
@-$(MD) $(DISTDIR)$(DS)bin
|
||||
@-$(CP) ..$(DS)INSTALL $(DISTDIR)
|
||||
@-$(CP) ..$(DS)LICENSE $(DISTDIR)
|
||||
@-$(CP) ..$(DS)README $(DISTDIR)
|
||||
@$(CP) $(TARGET).dll $(DISTDIR)$(DS)bin
|
||||
@echo Creating $(DISTARC)
|
||||
@$(ZIP) $(DISTARC) $(DISTDIR)/* < $(DISTDIR)/readme.txt
|
||||
|
||||
dev: all $(DEVLDIR) $(DEVLDIR)/readme.txt
|
||||
@-mkdir $(DEVLDIR)$(DS)bin
|
||||
@-mkdir $(DEVLDIR)$(DS)include
|
||||
@-mkdir $(DEVLDIR)$(DS)win32
|
||||
@-$(CP) ../INSTALL $(DEVLDIR)
|
||||
@-$(CP) ../LICENSE $(DEVLDIR)
|
||||
@-$(CP) ../README $(DEVLDIR)
|
||||
@$(CP) $(TARGET).dll $(DEVLDIR)/bin
|
||||
@$(CP) ../include/*.h $(DEVLDIR)/include
|
||||
@-$(MD) $(DEVLDIR)$(DS)bin
|
||||
@-$(MD)$(DEVLDIR)$(DS)include
|
||||
@-$(MD) $(DEVLDIR)$(DS)win32
|
||||
@-$(CP) ..$(DS)INSTALL $(DEVLDIR)
|
||||
@-$(CP) ..$(DS)LICENSE $(DEVLDIR)
|
||||
@-$(CP) ..$(DS)README $(DEVLDIR)
|
||||
@$(CP) $(TARGET).dll $(DEVLDIR)$(DS)bin
|
||||
@$(CP) ..$(DS)include$(DS)*.h $(DEVLDIR)$(DS)include
|
||||
@$(CP) libssh2_config.h $(DEVLDIR)/include
|
||||
@$(CP) *.$(LIBEXT) $(DEVLDIR)/win32
|
||||
@echo Creating $(DEVLARC)
|
||||
@$(ZIP) $(DEVLARC) $(DEVLDIR)/* < $(DEVLDIR)/readme.txt
|
||||
|
||||
distclean: clean
|
||||
-$(RM) -r $(DISTDIR)
|
||||
-$(RD) $(DISTDIR)
|
||||
-$(RM) $(DISTARC)
|
||||
|
||||
devclean: clean
|
||||
-$(RM) -r $(DEVLDIR)
|
||||
-$(RD) $(DEVLDIR)
|
||||
-$(RM) $(DEVLARC)
|
||||
|
||||
objclean: all
|
||||
-$(RM) -r $(OBJDIR)
|
||||
-$(RD) $(OBJDIR)
|
||||
|
||||
testclean: clean
|
||||
$(MAKE) -C test -f Makefile.win32 clean
|
||||
@@ -197,7 +210,7 @@ testclean: clean
|
||||
clean:
|
||||
# -$(RM) libssh2_config.h
|
||||
-$(RM) $(TARGET).dll $(TARGET).$(LIBEXT) $(TARGET)dll.$(LIBEXT)
|
||||
-$(RM) -r $(OBJDIR)
|
||||
-$(RD) $(OBJDIR)
|
||||
|
||||
$(OBJDIR):
|
||||
@$(MD) $@
|
@@ -1,7 +1,7 @@
|
||||
#########################################################################
|
||||
#
|
||||
## Makefile for building libssh2 samples (Win32 version - gnu make)
|
||||
## Use: make -f Makefile.win32 [help]
|
||||
## Use: make -f Makefile.mingw [help]
|
||||
##
|
||||
## Comments to: Guenter Knauf http://www.gknw.net/phpbb
|
||||
#
|
||||
@@ -14,7 +14,12 @@ endif
|
||||
|
||||
# Edit the path below to point to the base of your OpenSSL package.
|
||||
ifndef OPENSSL_PATH
|
||||
OPENSSL_PATH = ../../../openssl-0.9.8q
|
||||
OPENSSL_PATH = ../../../openssl-0.9.8r
|
||||
endif
|
||||
|
||||
# Edit the var below to set to your architecture or set environment var.
|
||||
ifndef ARCH
|
||||
ARCH = w32
|
||||
endif
|
||||
|
||||
# Edit the var below to enable static linking of libssh2 and libz
|
||||
@@ -23,7 +28,7 @@ LINK_STATIC = 1
|
||||
# Edit the vars below to change target settings.
|
||||
TARGETS = scp.exe sftp.exe sftpdir.exe ssh2.exe
|
||||
VERSION = $(LIBSSH2_VERSION)
|
||||
COPYR = (c) 2004-2010 The libssh2 project and its contributors.
|
||||
COPYR = (c) $(LIBSSH2_COPYRIGHT_STR)
|
||||
WWWURL = http://www.libssh2.org/
|
||||
DESCR = libssh2 $(subst .def,,$(notdir $@)) $(LIBSSH2_VERSION_STR)
|
||||
#STACK = 64000
|
||||
@@ -45,6 +50,26 @@ endif
|
||||
# Include the version info retrieved from libssh2.h
|
||||
-include $(OBJDIR)/version.inc
|
||||
|
||||
ifeq ($(findstring /sh,$(SHELL)),/sh)
|
||||
CP = cp -afv
|
||||
# RM = rm -f
|
||||
MD = mkdir
|
||||
RD = rm -fr
|
||||
DL = '
|
||||
DS = /
|
||||
else
|
||||
CP = copy
|
||||
RM = del /q /f 2>NUL
|
||||
MD = md
|
||||
RD = rd /q /s 2>NUL
|
||||
XX =
|
||||
DS = $(XX)\$(XX)
|
||||
endif
|
||||
# Here you can find a native Win32 binary of the original awk:
|
||||
# http://www.gknw.net/development/prgtools/awk-20100523.zip
|
||||
AWK = awk
|
||||
ZIP = zip -qzr9
|
||||
|
||||
# The following line defines your compiler.
|
||||
ifdef METROWERKS
|
||||
CC = mwcc
|
||||
@@ -60,6 +85,9 @@ ZIP = zip -qzr9
|
||||
|
||||
# Global flags for all compilers
|
||||
CFLAGS = $(OPT) -D$(DB) -DWIN32 -DLIBSSH2_WIN32 # -DHAVE_CONFIG_H
|
||||
ifeq ($(ARCH),w64)
|
||||
CFLAGS += -D_AMD64_
|
||||
endif
|
||||
CFLAGS += -DWINSOCK_VERSION=MAKEWORD(2,0)
|
||||
|
||||
ifeq ($(CC),mwcc)
|
||||
@@ -115,13 +143,6 @@ endif
|
||||
|
||||
CFLAGS += $(INCLUDES)
|
||||
|
||||
ifeq ($(findstring /sh,$(SHELL)),/sh)
|
||||
DL = '
|
||||
DS = /
|
||||
else
|
||||
DS = \\
|
||||
endif
|
||||
|
||||
vpath %.c ../../example
|
||||
|
||||
.PRECIOUS: $(OBJDIR)/%.o $(OBJDIR)/%.rc $(OBJDIR)/%.res
|
||||
@@ -140,13 +161,13 @@ $(OBJDIR)/version.inc: ../../include/libssh2.h $(OBJDIR)
|
||||
@$(AWK) -f ../../get_ver.awk $< > $@
|
||||
|
||||
objclean:
|
||||
-$(RM) -r $(OBJDIR)
|
||||
-$(RD) $(OBJDIR)
|
||||
|
||||
clean: objclean
|
||||
-$(RM) $(TARGETS)
|
||||
|
||||
$(OBJDIR):
|
||||
@mkdir $@
|
||||
$(MD) $@
|
||||
|
||||
%.exe: $(OBJDIR)/%.o $(OBJDIR)/%.res
|
||||
@echo Linking $@
|
Reference in New Issue
Block a user