mirror of
https://github.com/libssh2/libssh2.git
synced 2025-11-20 02:42:09 +03:00
src: silence compiler warnings 1
Most of the changes aim to silence warnings by adding casts.
An assortment of other issues, mainly compiler warnings, resolved:
- unreachable code fixed by using `goto` in
`publickey_response_success()` in `publickey.c`.
- potentially uninitialized variable in `sftp_open()`.
- MSVS-specific bogus warnings with `nid_type` in `kex.c`.
- check result of `kex_session_ecdh_curve_type()`.
- add missing function declarations.
- type changes to fit values without casts:
- `cmd_len` in `scp_recv()` and `scp_send()`: `int` -> `size_t`
- `Blowfish_expandstate()`, `Blowfish_expand0state()` loop counters:
`uint16_t` -> `int`
- `RECV_SEND_ALL()`: `int` -> `ssize_t`
- `shell_quotearg()` -> `unsigned` -> `size_t`
- `sig_len` in `_libssh2_mbedtls_rsa_sha2_sign()`:
`unsigned` -> `size_t`
- `prefs_len` in `libssh2_session_method_pref()`: `int` -> `size_t`
- `firstsec` in `_libssh2_debug_low()`: `int` -> `long`
- `method_len` in `libssh2_session_method_pref()`: `int` -> `size_t`
- simplify `_libssh2_ntohu64()`.
- fix `LIBSSH2_INT64_T_FORMAT` for MinGW.
- fix gcc warning by not using a bit field for
`burn_optimistic_kexinit`.
- fix unused variable warning in `_libssh2_cipher_crypt()` in
`libgcrypt.c`.
- fix unused variables with `HAVE_DISABLED_NONBLOCKING`.
- avoid const stripping with `BIO_new_mem_buf()` and OpenSSL 1.0.2 and
newer.
- add a missing const in `wincng.h`.
- FIXME added for public:
- `libssh2_channel_window_read_ex()` `read_avail` argument type.
- `libssh2_base64_decode()` `datalen` argument type.
- fix possible overflow in `sftp_read()`.
Ref: 4552c73cd5
- formatting in `wincng.h`.
See warning details in the PR's individual commits.
Cherry-picked from #846
Closes #876
This commit is contained in:
@@ -126,7 +126,7 @@ _libssh2_mbedtls_cipher_init(_libssh2_cipher_ctx *ctx,
|
||||
if(!ret)
|
||||
ret = mbedtls_cipher_setkey(ctx,
|
||||
secret,
|
||||
mbedtls_cipher_info_get_key_bitlen(cipher_info),
|
||||
(int)mbedtls_cipher_info_get_key_bitlen(cipher_info),
|
||||
op);
|
||||
|
||||
if(!ret)
|
||||
@@ -526,11 +526,11 @@ _libssh2_mbedtls_rsa_sha2_verify(libssh2_rsa_ctx * rsactx,
|
||||
|
||||
#if MBEDTLS_VERSION_NUMBER >= 0x03000000
|
||||
ret = mbedtls_rsa_pkcs1_verify(rsactx,
|
||||
md_type, hash_len,
|
||||
md_type, (unsigned int)hash_len,
|
||||
hash, sig);
|
||||
#else
|
||||
ret = mbedtls_rsa_pkcs1_verify(rsactx, NULL, NULL, MBEDTLS_RSA_PUBLIC,
|
||||
md_type, hash_len,
|
||||
md_type, (unsigned int)hash_len,
|
||||
hash, sig);
|
||||
#endif
|
||||
free(hash);
|
||||
@@ -558,7 +558,7 @@ _libssh2_mbedtls_rsa_sha2_sign(LIBSSH2_SESSION *session,
|
||||
{
|
||||
int ret;
|
||||
unsigned char *sig;
|
||||
unsigned int sig_len;
|
||||
size_t sig_len;
|
||||
int md_type;
|
||||
(void)hash_len;
|
||||
|
||||
@@ -587,11 +587,11 @@ _libssh2_mbedtls_rsa_sha2_sign(LIBSSH2_SESSION *session,
|
||||
ret = mbedtls_rsa_pkcs1_sign(rsa,
|
||||
mbedtls_ctr_drbg_random,
|
||||
&_libssh2_mbedtls_ctr_drbg,
|
||||
md_type, hash_len,
|
||||
md_type, (unsigned int)hash_len,
|
||||
hash, sig);
|
||||
#else
|
||||
ret = mbedtls_rsa_pkcs1_sign(rsa, NULL, NULL, MBEDTLS_RSA_PRIVATE,
|
||||
md_type, hash_len,
|
||||
md_type, (unsigned int)hash_len,
|
||||
hash, sig);
|
||||
#endif
|
||||
}
|
||||
@@ -634,8 +634,8 @@ gen_publickey_from_rsa(LIBSSH2_SESSION *session,
|
||||
unsigned char *key;
|
||||
unsigned char *p;
|
||||
|
||||
e_bytes = mbedtls_mpi_size(&rsa->MBEDTLS_PRIVATE(E));
|
||||
n_bytes = mbedtls_mpi_size(&rsa->MBEDTLS_PRIVATE(N));
|
||||
e_bytes = (int)mbedtls_mpi_size(&rsa->MBEDTLS_PRIVATE(E));
|
||||
n_bytes = (int)mbedtls_mpi_size(&rsa->MBEDTLS_PRIVATE(N));
|
||||
|
||||
/* Key form is "ssh-rsa" + e + n. */
|
||||
len = 4 + 7 + 4 + e_bytes + 4 + n_bytes;
|
||||
|
||||
Reference in New Issue
Block a user