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.
This commit is contained in:
parent
3faa8bc940
commit
b3e832172b
@ -1317,7 +1317,8 @@ static int sftp_readdir(LIBSSH2_SFTP_HANDLE *handle, char *buffer,
|
|||||||
LIBSSH2_SFTP *sftp = handle->sftp;
|
LIBSSH2_SFTP *sftp = handle->sftp;
|
||||||
LIBSSH2_CHANNEL *channel = sftp->channel;
|
LIBSSH2_CHANNEL *channel = sftp->channel;
|
||||||
LIBSSH2_SESSION *session = channel->session;
|
LIBSSH2_SESSION *session = channel->session;
|
||||||
size_t data_len, filename_len, longentry_len, num_names;
|
size_t data_len, filename_len, longentry_len;
|
||||||
|
uint32_t num_names;
|
||||||
/* 13 = packet_len(4) + packet_type(1) + request_id(4) + handle_len(4) */
|
/* 13 = packet_len(4) + packet_type(1) + request_id(4) + handle_len(4) */
|
||||||
ssize_t packet_len = handle->handle_len + 13;
|
ssize_t packet_len = handle->handle_len + 13;
|
||||||
unsigned char *s, *data;
|
unsigned char *s, *data;
|
||||||
@ -1449,9 +1450,9 @@ static int sftp_readdir(LIBSSH2_SFTP_HANDLE *handle, char *buffer,
|
|||||||
num_names = _libssh2_ntohu32(data + 5);
|
num_names = _libssh2_ntohu32(data + 5);
|
||||||
_libssh2_debug(session, LIBSSH2_TRACE_SFTP, "%lu entries returned",
|
_libssh2_debug(session, LIBSSH2_TRACE_SFTP, "%lu entries returned",
|
||||||
num_names);
|
num_names);
|
||||||
if (num_names <= 0) {
|
if (!num_names) {
|
||||||
LIBSSH2_FREE(session, data);
|
LIBSSH2_FREE(session, data);
|
||||||
return (num_names == 0) ? 0 : -1;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
handle->u.dir.names_left = num_names;
|
handle->u.dir.names_left = num_names;
|
||||||
|
@ -112,7 +112,7 @@ struct _LIBSSH2_SFTP_HANDLE
|
|||||||
} file;
|
} file;
|
||||||
struct _libssh2_sftp_handle_dir_data
|
struct _libssh2_sftp_handle_dir_data
|
||||||
{
|
{
|
||||||
unsigned long names_left;
|
uint32_t names_left;
|
||||||
void *names_packet;
|
void *names_packet;
|
||||||
char *next_name;
|
char *next_name;
|
||||||
} dir;
|
} dir;
|
||||||
|
Loading…
Reference in New Issue
Block a user