720998f3 kex.c: fix simple typo, niumber -> number (#545) cfe0bf64 session.c: Correct a typo which may lead to stack overflow (#533) REVERT: f75f3488 add some debugging for understanding how these flags are set.. REVERT: 57635ddf disable read ahead algorithm so we don't waste bandwidth.. git-subtree-dir: libssh2 git-subtree-split: 720998f322f4bffffe531d5ec6a240c8c18459b2remotes/client/ssh-main
@@ -4069,7 +4069,7 @@ LIBSSH2_API int libssh2_session_supported_algs(LIBSSH2_SESSION* session, | |||||
supported algorithms (needed to allocate the proper size of array) and | supported algorithms (needed to allocate the proper size of array) and | ||||
the second time to actually copy the pointers. Typically this function | the second time to actually copy the pointers. Typically this function | ||||
will not be called often (typically at the beginning of a session) and | will not be called often (typically at the beginning of a session) and | ||||
the number of algorithms (i.e. niumber of iterations in one loop) will | |||||
the number of algorithms (i.e. number of iterations in one loop) will | |||||
not be high (typically it will not exceed 20) for quite a long time. | not be high (typically it will not exceed 20) for quite a long time. | ||||
So double looping really shouldn't be an issue and it is definitely a | So double looping really shouldn't be an issue and it is definitely a | ||||
@@ -219,7 +219,7 @@ banner_send(LIBSSH2_SESSION * session) | |||||
} | } | ||||
else { | else { | ||||
memcpy(banner_dup, banner, 255); | memcpy(banner_dup, banner, 255); | ||||
banner[255] = '\0'; | |||||
banner_dup[255] = '\0'; | |||||
} | } | ||||
_libssh2_debug(session, LIBSSH2_TRACE_TRANS, "Sending Banner: %s", | _libssh2_debug(session, LIBSSH2_TRACE_TRANS, "Sending Banner: %s", | ||||
@@ -1414,9 +1414,12 @@ static ssize_t sftp_read(LIBSSH2_SFTP_HANDLE * handle, char *buffer, | |||||
/* Number of bytes asked for that haven't been acked yet */ | /* Number of bytes asked for that haven't been acked yet */ | ||||
size_t already = (size_t)(filep->offset_sent - filep->offset); | size_t already = (size_t)(filep->offset_sent - filep->offset); | ||||
size_t max_read_ahead = buffer_size; | |||||
size_t max_read_ahead = buffer_size*4; | |||||
unsigned long recv_window; | unsigned long recv_window; | ||||
if(max_read_ahead > LIBSSH2_CHANNEL_WINDOW_DEFAULT*4) | |||||
max_read_ahead = LIBSSH2_CHANNEL_WINDOW_DEFAULT*4; | |||||
/* if the buffer_size passed in now is smaller than what has | /* if the buffer_size passed in now is smaller than what has | ||||
already been sent, we risk getting count become a very large | already been sent, we risk getting count become a very large | ||||
number */ | number */ | ||||
@@ -1469,8 +1472,8 @@ static ssize_t sftp_read(LIBSSH2_SFTP_HANDLE * handle, char *buffer, | |||||
uint32_t request_id; | uint32_t request_id; | ||||
uint32_t size = count; | uint32_t size = count; | ||||
//if(size < buffer_size) | |||||
// size = buffer_size; | |||||
if(size < buffer_size) | |||||
size = buffer_size; | |||||
if(size > MAX_SFTP_READ_SIZE) | if(size > MAX_SFTP_READ_SIZE) | ||||
size = MAX_SFTP_READ_SIZE; | size = MAX_SFTP_READ_SIZE; | ||||
@@ -1573,7 +1576,7 @@ static ssize_t sftp_read(LIBSSH2_SFTP_HANDLE * handle, char *buffer, | |||||
else { | else { | ||||
/* we should never reach this point */ | /* we should never reach this point */ | ||||
return _libssh2_error(session, LIBSSH2_ERROR_SFTP_PROTOCOL, | return _libssh2_error(session, LIBSSH2_ERROR_SFTP_PROTOCOL, | ||||
"sftp_read() internal error a"); | |||||
"sftp_read() internal error"); | |||||
} | } | ||||
} | } | ||||
@@ -1719,7 +1722,7 @@ static ssize_t sftp_read(LIBSSH2_SFTP_HANDLE * handle, char *buffer, | |||||
/* we should never reach this point */ | /* we should never reach this point */ | ||||
return _libssh2_error(session, LIBSSH2_ERROR_SFTP_PROTOCOL, | return _libssh2_error(session, LIBSSH2_ERROR_SFTP_PROTOCOL, | ||||
"sftp_read() internal error b"); | |||||
"sftp_read() internal error"); | |||||
} | } | ||||
/* libssh2_sftp_read | /* libssh2_sftp_read | ||||
@@ -376,8 +376,6 @@ int _libssh2_transport_read(LIBSSH2_SESSION * session) | |||||
if((nread < 0) && (nread == -EAGAIN)) { | if((nread < 0) && (nread == -EAGAIN)) { | ||||
session->socket_block_directions |= | session->socket_block_directions |= | ||||
LIBSSH2_SESSION_BLOCK_INBOUND; | LIBSSH2_SESSION_BLOCK_INBOUND; | ||||
_libssh2_debug(session, LIBSSH2_TRACE_SOCKET, | |||||
"setting INBOUND flag, nread: %d", nread); | |||||
return LIBSSH2_ERROR_EAGAIN; | return LIBSSH2_ERROR_EAGAIN; | ||||
} | } | ||||
_libssh2_debug(session, LIBSSH2_TRACE_SOCKET, | _libssh2_debug(session, LIBSSH2_TRACE_SOCKET, | ||||
@@ -413,8 +411,6 @@ int _libssh2_transport_read(LIBSSH2_SESSION * session) | |||||
check is only done for the initial block since once we have | check is only done for the initial block since once we have | ||||
got the start of a block we can in fact deal with fractions | got the start of a block we can in fact deal with fractions | ||||
*/ | */ | ||||
_libssh2_debug(session, LIBSSH2_TRACE_SOCKET, | |||||
"setting INBOUND flag, numbytes: %d, blocksize: %d", numbytes, blocksize); | |||||
session->socket_block_directions |= | session->socket_block_directions |= | ||||
LIBSSH2_SESSION_BLOCK_INBOUND; | LIBSSH2_SESSION_BLOCK_INBOUND; | ||||
return LIBSSH2_ERROR_EAGAIN; | return LIBSSH2_ERROR_EAGAIN; | ||||