mirror of
https://github.com/curl/curl.git
synced 2026-08-24 14:23:30 +03:00
lib/v*: tidy up types and casts
Also add a couple of negative checks. Cherry-picked from #13489 Closes #13622
This commit is contained in:
parent
1d63e331de
commit
0887297100
20 changed files with 157 additions and 145 deletions
|
|
@ -740,7 +740,8 @@ static CURLcode myssh_statemach_act(struct Curl_easy *data, bool *block)
|
|||
break;
|
||||
}
|
||||
|
||||
sshc->auth_methods = ssh_userauth_list(sshc->ssh_session, NULL);
|
||||
sshc->auth_methods =
|
||||
(unsigned int)ssh_userauth_list(sshc->ssh_session, NULL);
|
||||
if(sshc->auth_methods)
|
||||
infof(data, "SSH authentication methods available: %s%s%s%s",
|
||||
sshc->auth_methods & SSH_AUTH_METHOD_PUBLICKEY ?
|
||||
|
|
@ -2611,7 +2612,7 @@ static ssize_t sftp_recv(struct Curl_easy *data, int sockindex,
|
|||
|
||||
nread = sftp_async_read(conn->proto.sshc.sftp_file,
|
||||
mem, (uint32_t)len,
|
||||
conn->proto.sshc.sftp_file_index);
|
||||
(uint32_t)conn->proto.sshc.sftp_file_index);
|
||||
|
||||
myssh_block2waitfor(conn, (nread == SSH_AGAIN)?TRUE:FALSE);
|
||||
|
||||
|
|
|
|||
|
|
@ -422,20 +422,20 @@ static int sshkeycallback(struct Curl_easy *easy,
|
|||
#define SCP_SEND(a,b,c,d) libssh2_scp_send_ex(a, b, (int)(c), (size_t)d, 0, 0)
|
||||
#else
|
||||
#define SCP_SEND(a,b,c,d) libssh2_scp_send64(a, b, (int)(c), \
|
||||
(libssh2_uint64_t)d, 0, 0)
|
||||
(libssh2_int64_t)d, 0, 0)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* libssh2 1.2.8 fixed the problem with 32bit ints used for sockets on win64.
|
||||
* libssh2 1.2.8 fixed the problem with 32-bit ints used for sockets on win64.
|
||||
*/
|
||||
#ifdef HAVE_LIBSSH2_SESSION_HANDSHAKE
|
||||
#define session_startup(x,y) libssh2_session_handshake(x, y)
|
||||
#else
|
||||
#define session_startup(x,y) libssh2_session_startup(x, (int)y)
|
||||
#endif
|
||||
static int convert_ssh2_keytype(int sshkeytype)
|
||||
static enum curl_khtype convert_ssh2_keytype(int sshkeytype)
|
||||
{
|
||||
int keytype = CURLKHTYPE_UNKNOWN;
|
||||
enum curl_khtype keytype = CURLKHTYPE_UNKNOWN;
|
||||
switch(sshkeytype) {
|
||||
case LIBSSH2_HOSTKEY_TYPE_RSA:
|
||||
keytype = CURLKHTYPE_RSA;
|
||||
|
|
@ -780,10 +780,10 @@ static CURLcode ssh_check_fingerprint(struct Curl_easy *data)
|
|||
const char *remotekey = libssh2_session_hostkey(sshc->ssh_session,
|
||||
&keylen, &sshkeytype);
|
||||
if(remotekey) {
|
||||
int keytype = convert_ssh2_keytype(sshkeytype);
|
||||
enum curl_khtype keytype = convert_ssh2_keytype(sshkeytype);
|
||||
Curl_set_in_callback(data, true);
|
||||
rc = data->set.ssh_hostkeyfunc(data->set.ssh_hostkeyfunc_userp,
|
||||
keytype, remotekey, keylen);
|
||||
(int)keytype, remotekey, keylen);
|
||||
Curl_set_in_callback(data, false);
|
||||
if(rc!= CURLKHMATCH_OK) {
|
||||
state(data, SSH_SESSION_FREE);
|
||||
|
|
@ -1860,7 +1860,7 @@ static CURLcode ssh_statemach_act(struct Curl_easy *data, bool *block)
|
|||
case SSH_SFTP_QUOTE_MKDIR:
|
||||
rc = libssh2_sftp_mkdir_ex(sshc->sftp_session, sshc->quote_path1,
|
||||
curlx_uztoui(strlen(sshc->quote_path1)),
|
||||
data->set.new_directory_perms);
|
||||
(long)data->set.new_directory_perms);
|
||||
if(rc == LIBSSH2_ERROR_EAGAIN) {
|
||||
break;
|
||||
}
|
||||
|
|
@ -2026,7 +2026,7 @@ static CURLcode ssh_statemach_act(struct Curl_easy *data, bool *block)
|
|||
break;
|
||||
}
|
||||
if(rc == 0) {
|
||||
data->info.filetime = attrs.mtime;
|
||||
data->info.filetime = (time_t)attrs.mtime;
|
||||
}
|
||||
|
||||
state(data, SSH_SFTP_TRANS_INIT);
|
||||
|
|
@ -2090,7 +2090,7 @@ static CURLcode ssh_statemach_act(struct Curl_easy *data, bool *block)
|
|||
sshc->sftp_handle =
|
||||
libssh2_sftp_open_ex(sshc->sftp_session, sshp->path,
|
||||
curlx_uztoui(strlen(sshp->path)),
|
||||
flags, data->set.new_file_perms,
|
||||
flags, (long)data->set.new_file_perms,
|
||||
LIBSSH2_SFTP_OPENFILE);
|
||||
|
||||
if(!sshc->sftp_handle) {
|
||||
|
|
@ -2254,7 +2254,7 @@ static CURLcode ssh_statemach_act(struct Curl_easy *data, bool *block)
|
|||
/* 'mode' - parameter is preliminary - default to 0644 */
|
||||
rc = libssh2_sftp_mkdir_ex(sshc->sftp_session, sshp->path,
|
||||
curlx_uztoui(strlen(sshp->path)),
|
||||
data->set.new_directory_perms);
|
||||
(long)data->set.new_directory_perms);
|
||||
if(rc == LIBSSH2_ERROR_EAGAIN) {
|
||||
break;
|
||||
}
|
||||
|
|
@ -2402,7 +2402,8 @@ static CURLcode ssh_statemach_act(struct Curl_easy *data, bool *block)
|
|||
rc =
|
||||
libssh2_sftp_symlink_ex(sshc->sftp_session,
|
||||
Curl_dyn_ptr(&sshp->readdir_link),
|
||||
(int)Curl_dyn_len(&sshp->readdir_link),
|
||||
(unsigned int)
|
||||
Curl_dyn_len(&sshp->readdir_link),
|
||||
sshp->readdir_filename,
|
||||
PATH_MAX, LIBSSH2_SFTP_READLINK);
|
||||
if(rc == LIBSSH2_ERROR_EAGAIN) {
|
||||
|
|
@ -2463,7 +2464,7 @@ static CURLcode ssh_statemach_act(struct Curl_easy *data, bool *block)
|
|||
sshc->sftp_handle =
|
||||
libssh2_sftp_open_ex(sshc->sftp_session, sshp->path,
|
||||
curlx_uztoui(strlen(sshp->path)),
|
||||
LIBSSH2_FXF_READ, data->set.new_file_perms,
|
||||
LIBSSH2_FXF_READ, (long)data->set.new_file_perms,
|
||||
LIBSSH2_SFTP_OPENFILE);
|
||||
if(!sshc->sftp_handle) {
|
||||
if(libssh2_session_last_errno(sshc->ssh_session) ==
|
||||
|
|
@ -3290,7 +3291,7 @@ static CURLcode ssh_connect(struct Curl_easy *data, bool *done)
|
|||
#if LIBSSH2_VERSION_NUM >= 0x010B00
|
||||
if(data->set.server_response_timeout > 0) {
|
||||
libssh2_session_set_read_timeout(sshc->ssh_session,
|
||||
data->set.server_response_timeout / 1000);
|
||||
(long)(data->set.server_response_timeout / 1000));
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -163,7 +163,7 @@ struct ssh_conn {
|
|||
unsigned kbd_state; /* 0 or 1 */
|
||||
ssh_key privkey;
|
||||
ssh_key pubkey;
|
||||
int auth_methods;
|
||||
unsigned int auth_methods;
|
||||
ssh_session ssh_session;
|
||||
ssh_scp scp_session;
|
||||
sftp_session sftp_session;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue