1
1
Fix 64bit warnings by using (s)size_t and dedicated uint32_t types more.
Этот коммит содержится в:
Daniel Stenberg 2010-12-29 23:36:45 +01:00
родитель 306929ee80
Коммит 4552c73cd5
7 изменённых файлов: 66 добавлений и 63 удалений

Просмотреть файл

@ -1229,8 +1229,8 @@ libssh2_channel_x11_req_ex(LIBSSH2_CHANNEL *channel, int single_connection,
*/ */
int int
_libssh2_channel_process_startup(LIBSSH2_CHANNEL *channel, _libssh2_channel_process_startup(LIBSSH2_CHANNEL *channel,
const char *request, unsigned int request_len, const char *request, size_t request_len,
const char *message, unsigned int message_len) const char *message, size_t message_len)
{ {
LIBSSH2_SESSION *session = channel->session; LIBSSH2_SESSION *session = channel->session;
unsigned char *s; unsigned char *s;
@ -1538,7 +1538,7 @@ libssh2_channel_get_exit_signal(LIBSSH2_CHANNEL *channel,
*/ */
int int
_libssh2_channel_receive_window_adjust(LIBSSH2_CHANNEL * channel, _libssh2_channel_receive_window_adjust(LIBSSH2_CHANNEL * channel,
unsigned long adjustment, uint32_t adjustment,
unsigned char force, unsigned char force,
unsigned int *store) unsigned int *store)
{ {

Просмотреть файл

@ -48,7 +48,7 @@
* Always non-blocking. * Always non-blocking.
*/ */
int _libssh2_channel_receive_window_adjust(LIBSSH2_CHANNEL * channel, int _libssh2_channel_receive_window_adjust(LIBSSH2_CHANNEL * channel,
unsigned long adjustment, uint32_t adjustment,
unsigned char force, unsigned char force,
unsigned int *store); unsigned int *store);
@ -102,9 +102,8 @@ _libssh2_channel_open(LIBSSH2_SESSION * session, const char *channel_type,
*/ */
int int
_libssh2_channel_process_startup(LIBSSH2_CHANNEL *channel, _libssh2_channel_process_startup(LIBSSH2_CHANNEL *channel,
const char *request, unsigned int request_len, const char *request, size_t request_len,
const char *message, unsigned int message_len); const char *message, size_t message_len);
/* /*
* _libssh2_channel_read * _libssh2_channel_read

Просмотреть файл

@ -334,7 +334,7 @@ struct _LIBSSH2_CHANNEL
libssh2_channel_data local, remote; libssh2_channel_data local, remote;
/* Amount of bytes to be refunded to receive window (but not yet sent) */ /* Amount of bytes to be refunded to receive window (but not yet sent) */
int adjust_queue; uint32_t adjust_queue;
LIBSSH2_SESSION *session; LIBSSH2_SESSION *session;
@ -461,17 +461,17 @@ struct transportpacket
unsigned char buf[PACKETBUFSIZE]; unsigned char buf[PACKETBUFSIZE];
unsigned char init[5]; /* first 5 bytes of the incoming data stream, unsigned char init[5]; /* first 5 bytes of the incoming data stream,
still encrypted */ still encrypted */
int writeidx; /* at what array index we do the next write into size_t writeidx; /* at what array index we do the next write into
the buffer */ the buffer */
int readidx; /* at what array index we do the next read from size_t readidx; /* at what array index we do the next read from
the buffer */ the buffer */
uint32_t packet_length; /* the most recent packet_length as read from the uint32_t packet_length; /* the most recent packet_length as read from the
network data */ network data */
uint8_t padding_length; /* the most recent padding_length as read from the uint8_t padding_length; /* the most recent padding_length as read from the
network data */ network data */
int data_num; /* How much of the total package that has been read size_t data_num; /* How much of the total package that has been read
so far. */ so far. */
int total_num; /* How much a total package is supposed to be, in size_t total_num; /* How much a total package is supposed to be, in
number of bytes. A full package is number of bytes. A full package is
packet_length + padding_length + 4 + packet_length + padding_length + 4 +
mac_length. */ mac_length. */
@ -738,7 +738,7 @@ struct _LIBSSH2_SESSION
/* State variables used in fullpacket() */ /* State variables used in fullpacket() */
libssh2_nonblocking_states fullpacket_state; libssh2_nonblocking_states fullpacket_state;
int fullpacket_macstate; int fullpacket_macstate;
int fullpacket_payload_len; size_t fullpacket_payload_len;
int fullpacket_packet_type; int fullpacket_packet_type;
/* State variables used in libssh2_sftp_init() */ /* State variables used in libssh2_sftp_init() */

Просмотреть файл

@ -415,16 +415,15 @@ get_socket_nonblocking(int sockfd)
LIBSSH2_API int LIBSSH2_API int
libssh2_banner_set(LIBSSH2_SESSION * session, const char *banner) libssh2_banner_set(LIBSSH2_SESSION * session, const char *banner)
{ {
int banner_len = banner ? strlen(banner) : 0; size_t banner_len = banner ? strlen(banner) : 0;
if (session->local.banner) { if (session->local.banner) {
LIBSSH2_FREE(session, session->local.banner); LIBSSH2_FREE(session, session->local.banner);
session->local.banner = NULL; session->local.banner = NULL;
} }
if (!banner_len) { if (!banner_len)
return 0; return 0;
}
session->local.banner = LIBSSH2_ALLOC(session, banner_len + 3); session->local.banner = LIBSSH2_ALLOC(session, banner_len + 3);
if (!session->local.banner) { if (!session->local.banner) {

Просмотреть файл

@ -169,7 +169,7 @@ sftp_packet_read(LIBSSH2_SFTP *sftp)
LIBSSH2_SESSION *session = channel->session; LIBSSH2_SESSION *session = channel->session;
unsigned char *packet; unsigned char *packet;
size_t packet_len, packet_received; size_t packet_len, packet_received;
int rc; ssize_t rc;
_libssh2_debug(session, LIBSSH2_TRACE_SFTP, "recv packet"); _libssh2_debug(session, LIBSSH2_TRACE_SFTP, "recv packet");
@ -428,7 +428,7 @@ sftp_packet_requirev(LIBSSH2_SFTP *sftp, int num_valid_responses,
/* sftp_attr2bin /* sftp_attr2bin
* Populate attributes into an SFTP block * Populate attributes into an SFTP block
*/ */
static int static ssize_t
sftp_attr2bin(unsigned char *p, const LIBSSH2_SFTP_ATTRIBUTES * attrs) sftp_attr2bin(unsigned char *p, const LIBSSH2_SFTP_ATTRIBUTES * attrs)
{ {
unsigned char *s = p; unsigned char *s = p;
@ -543,7 +543,7 @@ static LIBSSH2_SFTP *sftp_init(LIBSSH2_SESSION *session)
{ {
unsigned char *data, *s; unsigned char *data, *s;
size_t data_len; size_t data_len;
int rc; ssize_t rc;
LIBSSH2_SFTP *sftp_handle; LIBSSH2_SFTP *sftp_handle;
if (session->sftpInit_state == libssh2_NB_state_idle) { if (session->sftpInit_state == libssh2_NB_state_idle) {
@ -591,15 +591,15 @@ static LIBSSH2_SFTP *sftp_init(LIBSSH2_SESSION *session)
} }
if (session->sftpInit_state == libssh2_NB_state_sent) { if (session->sftpInit_state == libssh2_NB_state_sent) {
rc = _libssh2_channel_process_startup(session->sftpInit_channel, int ret = _libssh2_channel_process_startup(session->sftpInit_channel,
"subsystem", "subsystem",
sizeof("subsystem") - 1, "sftp", sizeof("subsystem") - 1, "sftp",
strlen("sftp")); strlen("sftp"));
if (rc == LIBSSH2_ERROR_EAGAIN) { if (ret == LIBSSH2_ERROR_EAGAIN) {
_libssh2_error(session, LIBSSH2_ERROR_EAGAIN, _libssh2_error(session, LIBSSH2_ERROR_EAGAIN,
"Would block to request SFTP subsystem"); "Would block to request SFTP subsystem");
return NULL; return NULL;
} else if (rc) { } else if (ret) {
_libssh2_error(session, LIBSSH2_ERROR_CHANNEL_FAILURE, _libssh2_error(session, LIBSSH2_ERROR_CHANNEL_FAILURE,
"Unable to request SFTP subsystem"); "Unable to request SFTP subsystem");
goto sftp_init_error; goto sftp_init_error;
@ -867,7 +867,7 @@ sftp_open(LIBSSH2_SFTP *sftp, const char *filename,
LIBSSH2_SFTP_ATTR_PERMISSIONS, 0, 0, 0, 0, 0, 0 LIBSSH2_SFTP_ATTR_PERMISSIONS, 0, 0, 0, 0, 0, 0
}; };
unsigned char *s; unsigned char *s;
int rc; ssize_t rc;
int open_file = (open_type == LIBSSH2_SFTP_OPENFILE)?1:0; int open_file = (open_type == LIBSSH2_SFTP_OPENFILE)?1:0;
if (sftp->open_state == libssh2_NB_state_idle) { if (sftp->open_state == libssh2_NB_state_idle) {
@ -1079,7 +1079,7 @@ static ssize_t sftp_read(LIBSSH2_SFTP_HANDLE * handle, char *buffer,
size_t count; size_t count;
struct sftp_pipeline_chunk *chunk; struct sftp_pipeline_chunk *chunk;
struct sftp_pipeline_chunk *next; struct sftp_pipeline_chunk *next;
int rc; ssize_t rc;
size_t eagain = 0; size_t eagain = 0;
size_t total_read = 0; size_t total_read = 0;
struct _libssh2_sftp_handle_file_data *filep = struct _libssh2_sftp_handle_file_data *filep =
@ -1111,11 +1111,11 @@ static ssize_t sftp_read(LIBSSH2_SFTP_HANDLE * handle, char *buffer,
while(count > 0) { while(count > 0) {
unsigned char *s; unsigned char *s;
size_t size = MIN(MAX_SFTP_READ_SIZE, count); uint32_t size = MIN(MAX_SFTP_READ_SIZE, count);
/* 25 = packet_len(4) + packet_type(1) + request_id(4) + /* 25 = packet_len(4) + packet_type(1) + request_id(4) +
handle_len(4) + offset(8) + count(4) */ handle_len(4) + offset(8) + count(4) */
size_t packet_len = handle->handle_len + 25; uint32_t packet_len = (uint32_t)handle->handle_len + 25;
uint32_t request_id; uint32_t request_id;
chunk = LIBSSH2_ALLOC(session, packet_len + chunk = LIBSSH2_ALLOC(session, packet_len +
@ -1245,7 +1245,7 @@ static ssize_t sftp_read(LIBSSH2_SFTP_HANDLE * handle, char *buffer,
/* getting the full packet would overflow the buffer, so /* getting the full packet would overflow the buffer, so
only get the correct amount and keep the remainder */ only get the correct amount and keep the remainder */
rc32 = buffer_size - total_read; rc32 = (uint32_t)(buffer_size - total_read);
/* store data to keep for next call */ /* store data to keep for next call */
filep->data = data; filep->data = data;
@ -1309,10 +1309,10 @@ libssh2_sftp_read(LIBSSH2_SFTP_HANDLE *hnd, char *buffer,
/* sftp_readdir /* sftp_readdir
* Read from an SFTP directory handle * Read from an SFTP directory handle
*/ */
static int sftp_readdir(LIBSSH2_SFTP_HANDLE *handle, char *buffer, static ssize_t sftp_readdir(LIBSSH2_SFTP_HANDLE *handle, char *buffer,
size_t buffer_maxlen, char *longentry, size_t buffer_maxlen, char *longentry,
size_t longentry_maxlen, size_t longentry_maxlen,
LIBSSH2_SFTP_ATTRIBUTES *attrs) LIBSSH2_SFTP_ATTRIBUTES *attrs)
{ {
LIBSSH2_SFTP *sftp = handle->sftp; LIBSSH2_SFTP *sftp = handle->sftp;
LIBSSH2_CHANNEL *channel = sftp->channel; LIBSSH2_CHANNEL *channel = sftp->channel;
@ -1320,11 +1320,11 @@ static int sftp_readdir(LIBSSH2_SFTP_HANDLE *handle, char *buffer,
size_t data_len, filename_len, longentry_len; size_t data_len, filename_len, longentry_len;
uint32_t num_names; 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; uint32_t packet_len = handle->handle_len + 13;
unsigned char *s, *data; unsigned char *s, *data;
static const unsigned char read_responses[2] = { static const unsigned char read_responses[2] = {
SSH_FXP_NAME, SSH_FXP_STATUS }; SSH_FXP_NAME, SSH_FXP_STATUS };
int retcode; ssize_t retcode;
if (sftp->readdir_state == libssh2_NB_state_idle) { if (sftp->readdir_state == libssh2_NB_state_idle) {
if (handle->u.dir.names_left) { if (handle->u.dir.names_left) {
@ -1377,7 +1377,7 @@ static int sftp_readdir(LIBSSH2_SFTP_HANDLE *handle, char *buffer,
_libssh2_debug(session, LIBSSH2_TRACE_SFTP, _libssh2_debug(session, LIBSSH2_TRACE_SFTP,
"libssh2_sftp_readdir_ex() return %d", "libssh2_sftp_readdir_ex() return %d",
filename_len); filename_len);
return filename_len; return (ssize_t)filename_len;
} }
/* Request another entry(entries?) */ /* Request another entry(entries?) */
@ -1405,7 +1405,7 @@ static int sftp_readdir(LIBSSH2_SFTP_HANDLE *handle, char *buffer,
if (retcode == LIBSSH2_ERROR_EAGAIN) { if (retcode == LIBSSH2_ERROR_EAGAIN) {
return retcode; return retcode;
} }
else if (packet_len != retcode) { else if ((ssize_t)packet_len != retcode) {
LIBSSH2_FREE(session, sftp->readdir_packet); LIBSSH2_FREE(session, sftp->readdir_packet);
sftp->readdir_packet = NULL; sftp->readdir_packet = NULL;
sftp->readdir_state = libssh2_NB_state_idle; sftp->readdir_state = libssh2_NB_state_idle;
@ -1522,10 +1522,11 @@ static ssize_t sftp_write(LIBSSH2_SFTP_HANDLE *handle, const 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, retcode; size_t data_len;
ssize_t packet_len; uint32_t retcode;
uint32_t packet_len;
unsigned char *s, *data; unsigned char *s, *data;
int rc; ssize_t rc;
struct sftp_pipeline_chunk *chunk; struct sftp_pipeline_chunk *chunk;
struct sftp_pipeline_chunk *next; struct sftp_pipeline_chunk *next;
size_t acked = 0; size_t acked = 0;
@ -1554,7 +1555,7 @@ static ssize_t sftp_write(LIBSSH2_SFTP_HANDLE *handle, const char *buffer,
while(count) { while(count) {
/* TODO: Possibly this should have some logic to prevent a very very /* TODO: Possibly this should have some logic to prevent a very very
small fraction to be left but lets ignore that for now */ small fraction to be left but lets ignore that for now */
size_t size = MIN(MAX_SFTP_OUTGOING_SIZE, count); uint32_t size = MIN(MAX_SFTP_OUTGOING_SIZE, count);
uint32_t request_id; uint32_t request_id;
/* 25 = packet_len(4) + packet_type(1) + request_id(4) + /* 25 = packet_len(4) + packet_type(1) + request_id(4) +
@ -1719,12 +1720,12 @@ static int sftp_fstat(LIBSSH2_SFTP_HANDLE *handle,
LIBSSH2_SESSION *session = channel->session; LIBSSH2_SESSION *session = channel->session;
size_t data_len; size_t data_len;
/* 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 = uint32_t packet_len =
handle->handle_len + 13 + (setstat ? sftp_attrsize(attrs->flags) : 0); handle->handle_len + 13 + (setstat ? sftp_attrsize(attrs->flags) : 0);
unsigned char *s, *data; unsigned char *s, *data;
static const unsigned char fstat_responses[2] = static const unsigned char fstat_responses[2] =
{ SSH_FXP_ATTRS, SSH_FXP_STATUS }; { SSH_FXP_ATTRS, SSH_FXP_STATUS };
int rc; ssize_t rc;
if (sftp->fstat_state == libssh2_NB_state_idle) { if (sftp->fstat_state == libssh2_NB_state_idle) {
_libssh2_debug(session, LIBSSH2_TRACE_SFTP, "Issuing %s command", _libssh2_debug(session, LIBSSH2_TRACE_SFTP, "Issuing %s command",
@ -1754,7 +1755,8 @@ static int sftp_fstat(LIBSSH2_SFTP_HANDLE *handle,
packet_len); packet_len);
if (rc == LIBSSH2_ERROR_EAGAIN) { if (rc == LIBSSH2_ERROR_EAGAIN) {
return rc; return rc;
} else if (packet_len != rc) { }
else if ((ssize_t)packet_len != rc) {
LIBSSH2_FREE(session, sftp->fstat_packet); LIBSSH2_FREE(session, sftp->fstat_packet);
sftp->fstat_packet = NULL; sftp->fstat_packet = NULL;
sftp->fstat_state = libssh2_NB_state_idle; sftp->fstat_state = libssh2_NB_state_idle;
@ -1782,7 +1784,7 @@ static int sftp_fstat(LIBSSH2_SFTP_HANDLE *handle,
sftp->fstat_state = libssh2_NB_state_idle; sftp->fstat_state = libssh2_NB_state_idle;
if (data[0] == SSH_FXP_STATUS) { if (data[0] == SSH_FXP_STATUS) {
int retcode; uint32_t retcode;
retcode = _libssh2_ntohu32(data + 5); retcode = _libssh2_ntohu32(data + 5);
LIBSSH2_FREE(session, data); LIBSSH2_FREE(session, data);
@ -1900,7 +1902,7 @@ sftp_close_handle(LIBSSH2_SFTP_HANDLE *handle)
size_t data_len; size_t data_len;
int retcode; int retcode;
/* 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; uint32_t packet_len = handle->handle_len + 13;
unsigned char *s, *data = NULL; unsigned char *s, *data = NULL;
int rc; int rc;
@ -1926,7 +1928,7 @@ sftp_close_handle(LIBSSH2_SFTP_HANDLE *handle)
packet_len); packet_len);
if (rc == LIBSSH2_ERROR_EAGAIN) { if (rc == LIBSSH2_ERROR_EAGAIN) {
return rc; return rc;
} else if (packet_len != rc) { } else if ((ssize_t)packet_len != rc) {
LIBSSH2_FREE(session, handle->close_packet); LIBSSH2_FREE(session, handle->close_packet);
handle->close_packet = NULL; handle->close_packet = NULL;
handle->close_state = libssh2_NB_state_idle; handle->close_state = libssh2_NB_state_idle;
@ -2010,14 +2012,14 @@ libssh2_sftp_close_handle(LIBSSH2_SFTP_HANDLE *hnd)
* Delete a file from the remote server * Delete a file from the remote server
*/ */
static int sftp_unlink(LIBSSH2_SFTP *sftp, const char *filename, static int sftp_unlink(LIBSSH2_SFTP *sftp, const char *filename,
unsigned int filename_len) size_t filename_len)
{ {
LIBSSH2_CHANNEL *channel = sftp->channel; LIBSSH2_CHANNEL *channel = sftp->channel;
LIBSSH2_SESSION *session = channel->session; LIBSSH2_SESSION *session = channel->session;
size_t data_len; size_t data_len;
int retcode; int retcode;
/* 13 = packet_len(4) + packet_type(1) + request_id(4) + filename_len(4) */ /* 13 = packet_len(4) + packet_type(1) + request_id(4) + filename_len(4) */
ssize_t packet_len = filename_len + 13; uint32_t packet_len = filename_len + 13;
unsigned char *s, *data; unsigned char *s, *data;
int rc; int rc;
@ -2043,7 +2045,7 @@ static int sftp_unlink(LIBSSH2_SFTP *sftp, const char *filename,
packet_len); packet_len);
if (rc == LIBSSH2_ERROR_EAGAIN) { if (rc == LIBSSH2_ERROR_EAGAIN) {
return rc; return rc;
} else if (packet_len != rc) { } else if ((ssize_t)packet_len != rc) {
LIBSSH2_FREE(session, sftp->unlink_packet); LIBSSH2_FREE(session, sftp->unlink_packet);
sftp->unlink_packet = NULL; sftp->unlink_packet = NULL;
sftp->unlink_state = libssh2_NB_state_idle; sftp->unlink_state = libssh2_NB_state_idle;
@ -2111,13 +2113,13 @@ static int sftp_rename(LIBSSH2_SFTP *sftp, const char *source_filename,
LIBSSH2_SESSION *session = channel->session; LIBSSH2_SESSION *session = channel->session;
size_t data_len; size_t data_len;
int retcode; int retcode;
ssize_t packet_len = uint32_t packet_len =
source_filename_len + dest_filename_len + 17 + (sftp->version >= source_filename_len + dest_filename_len + 17 + (sftp->version >=
5 ? 4 : 0); 5 ? 4 : 0);
/* packet_len(4) + packet_type(1) + request_id(4) + /* packet_len(4) + packet_type(1) + request_id(4) +
source_filename_len(4) + dest_filename_len(4) + flags(4){SFTP5+) */ source_filename_len(4) + dest_filename_len(4) + flags(4){SFTP5+) */
unsigned char *data; unsigned char *data;
int rc; ssize_t rc;
if (sftp->version < 2) { if (sftp->version < 2) {
return _libssh2_error(session, LIBSSH2_ERROR_SFTP_PROTOCOL, return _libssh2_error(session, LIBSSH2_ERROR_SFTP_PROTOCOL,
@ -2154,7 +2156,7 @@ static int sftp_rename(LIBSSH2_SFTP *sftp, const char *source_filename,
sftp->rename_s - sftp->rename_packet); sftp->rename_s - sftp->rename_packet);
if (rc == LIBSSH2_ERROR_EAGAIN) { if (rc == LIBSSH2_ERROR_EAGAIN) {
return rc; return rc;
} else if (packet_len != rc) { } else if ((ssize_t)packet_len != rc) {
LIBSSH2_FREE(session, sftp->rename_packet); LIBSSH2_FREE(session, sftp->rename_packet);
sftp->rename_packet = NULL; sftp->rename_packet = NULL;
sftp->rename_state = libssh2_NB_state_idle; sftp->rename_state = libssh2_NB_state_idle;
@ -2244,9 +2246,9 @@ static int sftp_fstatvfs(LIBSSH2_SFTP_HANDLE *handle, LIBSSH2_SFTP_STATVFS *st)
/* 17 = packet_len(4) + packet_type(1) + request_id(4) + ext_len(4) /* 17 = packet_len(4) + packet_type(1) + request_id(4) + ext_len(4)
+ handle_len (4) */ + handle_len (4) */
/* 20 = strlen ("fstatvfs@openssh.com") */ /* 20 = strlen ("fstatvfs@openssh.com") */
ssize_t packet_len = handle->handle_len + 20 + 17; uint32_t packet_len = handle->handle_len + 20 + 17;
unsigned char *packet, *s, *data; unsigned char *packet, *s, *data;
int rc; ssize_t rc;
unsigned int flag; unsigned int flag;
if (sftp->fstatvfs_state == libssh2_NB_state_idle) { if (sftp->fstatvfs_state == libssh2_NB_state_idle) {
@ -2274,7 +2276,8 @@ static int sftp_fstatvfs(LIBSSH2_SFTP_HANDLE *handle, LIBSSH2_SFTP_STATVFS *st)
if (sftp->fstatvfs_state == libssh2_NB_state_created) { if (sftp->fstatvfs_state == libssh2_NB_state_created) {
rc = _libssh2_channel_write(channel, 0, packet, packet_len); rc = _libssh2_channel_write(channel, 0, packet, packet_len);
if (rc == LIBSSH2_ERROR_EAGAIN || (0 <= rc && rc < packet_len)) { if (rc == LIBSSH2_ERROR_EAGAIN ||
(0 <= rc && rc < (ssize_t)packet_len)) {
sftp->fstatvfs_packet = packet; sftp->fstatvfs_packet = packet;
return LIBSSH2_ERROR_EAGAIN; return LIBSSH2_ERROR_EAGAIN;
} }
@ -2356,9 +2359,9 @@ static int sftp_statvfs(LIBSSH2_SFTP *sftp, const char *path,
/* 17 = packet_len(4) + packet_type(1) + request_id(4) + ext_len(4) /* 17 = packet_len(4) + packet_type(1) + request_id(4) + ext_len(4)
+ path_len (4) */ + path_len (4) */
/* 19 = strlen ("statvfs@openssh.com") */ /* 19 = strlen ("statvfs@openssh.com") */
ssize_t packet_len = path_len + 19 + 17; uint32_t packet_len = path_len + 19 + 17;
unsigned char *packet, *s, *data; unsigned char *packet, *s, *data;
int rc; ssize_t rc;
unsigned int flag; unsigned int flag;
if (sftp->statvfs_state == libssh2_NB_state_idle) { if (sftp->statvfs_state == libssh2_NB_state_idle) {
@ -2386,7 +2389,8 @@ static int sftp_statvfs(LIBSSH2_SFTP *sftp, const char *path,
if (sftp->statvfs_state == libssh2_NB_state_created) { if (sftp->statvfs_state == libssh2_NB_state_created) {
rc = _libssh2_channel_write(channel, 0, packet, packet_len); rc = _libssh2_channel_write(channel, 0, packet, packet_len);
if (rc == LIBSSH2_ERROR_EAGAIN || (0 <= rc && rc < packet_len)) { if (rc == LIBSSH2_ERROR_EAGAIN ||
(0 <= rc && rc < (ssize_t)packet_len)) {
sftp->statvfs_packet = packet; sftp->statvfs_packet = packet;
return LIBSSH2_ERROR_EAGAIN; return LIBSSH2_ERROR_EAGAIN;
} }

Просмотреть файл

@ -154,7 +154,7 @@ struct _LIBSSH2_SFTP
/* State variables used in libssh2_sftp_open_ex() */ /* State variables used in libssh2_sftp_open_ex() */
libssh2_nonblocking_states open_state; libssh2_nonblocking_states open_state;
unsigned char *open_packet; unsigned char *open_packet;
size_t open_packet_len; uint32_t open_packet_len; /* 32 bit on the wire */
size_t open_packet_sent; size_t open_packet_sent;
uint32_t open_request_id; uint32_t open_request_id;

Просмотреть файл

@ -664,7 +664,7 @@ int _libssh2_transport_send(LIBSSH2_SESSION *session,
(session->state & LIBSSH2_STATE_NEWKEYS) ? (session->state & LIBSSH2_STATE_NEWKEYS) ?
session->local.crypt->blocksize : 8; session->local.crypt->blocksize : 8;
int padding_length; int padding_length;
int packet_length; size_t packet_length;
int total_length; int total_length;
#ifdef RANDOM_PADDING #ifdef RANDOM_PADDING
int rand_max; int rand_max;
@ -672,7 +672,6 @@ int _libssh2_transport_send(LIBSSH2_SESSION *session,
#endif #endif
struct transportpacket *p = &session->packet; struct transportpacket *p = &session->packet;
int encrypted; int encrypted;
int i;
ssize_t ret; ssize_t ret;
int rc; int rc;
const unsigned char *orgdata = data; const unsigned char *orgdata = data;
@ -791,6 +790,8 @@ int _libssh2_transport_send(LIBSSH2_SESSION *session,
_libssh2_random(p->outbuf + 5 + data_len, padding_length); _libssh2_random(p->outbuf + 5 + data_len, padding_length);
if (encrypted) { if (encrypted) {
size_t i;
/* Calculate MAC hash. Put the output at index packet_length, /* Calculate MAC hash. Put the output at index packet_length,
since that size includes the whole packet. The MAC is since that size includes the whole packet. The MAC is
calculated on the entire unencrypted packet, including all calculated on the entire unencrypted packet, including all