mirror of
https://github.com/libssh2/libssh2.git
synced 2025-11-20 02:42:09 +03:00
@@ -104,10 +104,10 @@ static uint32_t Blowfish_stream2word(const uint8_t *, uint16_t, uint16_t *);
|
||||
|
||||
/* Function for Feistel Networks */
|
||||
|
||||
#define F(s, x) ((((s)[ (((x)>>24)&0xFF)] \
|
||||
+ (s)[0x100 + (((x)>>16)&0xFF)]) \
|
||||
^ (s)[0x200 + (((x)>> 8)&0xFF)]) \
|
||||
+ (s)[0x300 + ( (x) &0xFF)])
|
||||
#define F(s, x) ((((s)[ (((x) >> 24) & 0xFF)] \
|
||||
+ (s)[0x100 + (((x) >> 16) & 0xFF)]) \
|
||||
^ (s)[0x200 + (((x) >> 8) & 0xFF)]) \
|
||||
+ (s)[0x300 + ( (x) & 0xFF)])
|
||||
|
||||
#define BLFRND(s,p,i,j,n) (i ^= F(s,j) ^ (p)[n])
|
||||
|
||||
|
||||
@@ -1181,10 +1181,10 @@ static int channel_request_auth_agent(LIBSSH2_CHANNEL *channel,
|
||||
size_t data_len;
|
||||
unsigned char code;
|
||||
|
||||
rc = _libssh2_packet_requirev(
|
||||
session, reply_codes, &data, &data_len, 1,
|
||||
channel->req_auth_agent_local_channel,
|
||||
4, &channel->req_auth_agent_requirev_state);
|
||||
rc = _libssh2_packet_requirev(session, reply_codes, &data, &data_len,
|
||||
1, channel->req_auth_agent_local_channel,
|
||||
4,
|
||||
&channel->req_auth_agent_requirev_state);
|
||||
if(rc == LIBSSH2_ERROR_EAGAIN) {
|
||||
return rc;
|
||||
}
|
||||
@@ -1654,7 +1654,7 @@ LIBSSH2_API void
|
||||
libssh2_channel_set_blocking(LIBSSH2_CHANNEL * channel, int blocking)
|
||||
{
|
||||
if(channel)
|
||||
(void) _libssh2_session_set_blocking(channel->session, blocking);
|
||||
(void)_libssh2_session_set_blocking(channel->session, blocking);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -2387,7 +2387,7 @@ _libssh2_channel_write(LIBSSH2_CHANNEL *channel, int stream_id,
|
||||
*/
|
||||
session->socket_block_directions = LIBSSH2_SESSION_BLOCK_INBOUND;
|
||||
|
||||
return (rc == LIBSSH2_ERROR_EAGAIN?rc:0);
|
||||
return rc == LIBSSH2_ERROR_EAGAIN ? rc : 0;
|
||||
}
|
||||
|
||||
channel->write_bufwrite = buflen;
|
||||
|
||||
18
src/comp.c
18
src/comp.c
@@ -61,12 +61,12 @@ comp_method_none_comp(LIBSSH2_SESSION *session,
|
||||
size_t src_len,
|
||||
void **abstract)
|
||||
{
|
||||
(void) session;
|
||||
(void) abstract;
|
||||
(void) dest;
|
||||
(void) dest_len;
|
||||
(void) src;
|
||||
(void) src_len;
|
||||
(void)session;
|
||||
(void)abstract;
|
||||
(void)dest;
|
||||
(void)dest_len;
|
||||
(void)src;
|
||||
(void)src_len;
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -84,9 +84,9 @@ comp_method_none_decomp(LIBSSH2_SESSION * session,
|
||||
const unsigned char *src,
|
||||
size_t src_len, void **abstract)
|
||||
{
|
||||
(void) session;
|
||||
(void) payload_limit;
|
||||
(void) abstract;
|
||||
(void)session;
|
||||
(void)payload_limit;
|
||||
(void)abstract;
|
||||
*dest = (unsigned char *) src;
|
||||
*dest_len = src_len;
|
||||
return 0;
|
||||
|
||||
@@ -200,7 +200,7 @@ hostkey_method_ssh_rsa_sig_verify(LIBSSH2_SESSION * session,
|
||||
size_t m_len, void **abstract)
|
||||
{
|
||||
libssh2_rsa_ctx *rsactx = (libssh2_rsa_ctx *) (*abstract);
|
||||
(void) session;
|
||||
(void)session;
|
||||
|
||||
/* Skip past keyname_len(4) + keyname(7){"ssh-rsa"} + signature_len(4) */
|
||||
if(sig_len < 15)
|
||||
@@ -266,7 +266,7 @@ hostkey_method_ssh_rsa_sha2_256_sig_verify(LIBSSH2_SESSION * session,
|
||||
size_t m_len, void **abstract)
|
||||
{
|
||||
libssh2_rsa_ctx *rsactx = (libssh2_rsa_ctx *) (*abstract);
|
||||
(void) session;
|
||||
(void)session;
|
||||
|
||||
/* Skip past keyname_len(4) + keyname(12){"rsa-sha2-256"} +
|
||||
signature_len(4) */
|
||||
@@ -336,7 +336,7 @@ hostkey_method_ssh_rsa_sha2_512_sig_verify(LIBSSH2_SESSION * session,
|
||||
size_t m_len, void **abstract)
|
||||
{
|
||||
libssh2_rsa_ctx *rsactx = (libssh2_rsa_ctx *) (*abstract);
|
||||
(void) session;
|
||||
(void)session;
|
||||
|
||||
/* Skip past keyname_len(4) + keyname(12){"rsa-sha2-512"} +
|
||||
signature_len(4) */
|
||||
@@ -404,7 +404,7 @@ static int
|
||||
hostkey_method_ssh_rsa_dtor(LIBSSH2_SESSION * session, void **abstract)
|
||||
{
|
||||
libssh2_rsa_ctx *rsactx = (libssh2_rsa_ctx *) (*abstract);
|
||||
(void) session;
|
||||
(void)session;
|
||||
|
||||
_libssh2_rsa_free(rsactx);
|
||||
|
||||
@@ -673,7 +673,7 @@ static int
|
||||
hostkey_method_ssh_dss_dtor(LIBSSH2_SESSION * session, void **abstract)
|
||||
{
|
||||
libssh2_dsa_ctx *dsactx = (libssh2_dsa_ctx *) (*abstract);
|
||||
(void) session;
|
||||
(void)session;
|
||||
|
||||
_libssh2_dsa_free(dsactx);
|
||||
|
||||
@@ -866,7 +866,7 @@ hostkey_method_ssh_ecdsa_sig_verify(LIBSSH2_SESSION * session,
|
||||
struct string_buf buf;
|
||||
libssh2_ecdsa_ctx *ctx = (libssh2_ecdsa_ctx *) (*abstract);
|
||||
|
||||
(void) session;
|
||||
(void)session;
|
||||
|
||||
if(sig_len < 35)
|
||||
return -1;
|
||||
@@ -952,7 +952,7 @@ static int
|
||||
hostkey_method_ssh_ecdsa_dtor(LIBSSH2_SESSION * session, void **abstract)
|
||||
{
|
||||
libssh2_ecdsa_ctx *keyctx = (libssh2_ecdsa_ctx *) (*abstract);
|
||||
(void) session;
|
||||
(void)session;
|
||||
|
||||
if(keyctx)
|
||||
_libssh2_ecdsa_free(keyctx);
|
||||
@@ -1172,7 +1172,7 @@ hostkey_method_ssh_ed25519_sig_verify(LIBSSH2_SESSION * session,
|
||||
size_t m_len, void **abstract)
|
||||
{
|
||||
libssh2_ed25519_ctx *ctx = (libssh2_ed25519_ctx *) (*abstract);
|
||||
(void) session;
|
||||
(void)session;
|
||||
|
||||
if(sig_len < 19)
|
||||
return -1;
|
||||
@@ -1221,7 +1221,7 @@ static int
|
||||
hostkey_method_ssh_ed25519_dtor(LIBSSH2_SESSION * session, void **abstract)
|
||||
{
|
||||
libssh2_ed25519_ctx *keyctx = (libssh2_ed25519_ctx*) (*abstract);
|
||||
(void) session;
|
||||
(void)session;
|
||||
|
||||
if(keyctx)
|
||||
_libssh2_ed25519_free(keyctx);
|
||||
|
||||
@@ -42,7 +42,7 @@
|
||||
/* Keep-alive stuff. */
|
||||
|
||||
LIBSSH2_API void
|
||||
libssh2_keepalive_config (LIBSSH2_SESSION *session,
|
||||
libssh2_keepalive_config(LIBSSH2_SESSION *session,
|
||||
int want_reply,
|
||||
unsigned interval)
|
||||
{
|
||||
@@ -54,7 +54,7 @@ libssh2_keepalive_config (LIBSSH2_SESSION *session,
|
||||
}
|
||||
|
||||
LIBSSH2_API int
|
||||
libssh2_keepalive_send (LIBSSH2_SESSION *session,
|
||||
libssh2_keepalive_send(LIBSSH2_SESSION *session,
|
||||
int *seconds_to_next)
|
||||
{
|
||||
time_t now;
|
||||
|
||||
48
src/kex.c
48
src/kex.c
@@ -1325,8 +1325,9 @@ kex_method_diffie_hellman_group18_sha512_key_exchange(LIBSSH2_SESSION *session,
|
||||
* Negotiates random(ish) group for secret derivation
|
||||
*/
|
||||
static int
|
||||
kex_method_diffie_hellman_group_exchange_sha1_key_exchange
|
||||
(LIBSSH2_SESSION * session, key_exchange_state_low_t * key_state)
|
||||
kex_method_diffie_hellman_group_exchange_sha1_key_exchange(
|
||||
LIBSSH2_SESSION * session,
|
||||
key_exchange_state_low_t * key_state)
|
||||
{
|
||||
int ret = 0;
|
||||
int rc;
|
||||
@@ -1442,8 +1443,9 @@ kex_method_diffie_hellman_group_exchange_sha1_key_exchange
|
||||
* Negotiates random(ish) group for secret derivation
|
||||
*/
|
||||
static int
|
||||
kex_method_diffie_hellman_group_exchange_sha256_key_exchange
|
||||
(LIBSSH2_SESSION * session, key_exchange_state_low_t * key_state)
|
||||
kex_method_diffie_hellman_group_exchange_sha256_key_exchange(
|
||||
LIBSSH2_SESSION * session,
|
||||
key_exchange_state_low_t * key_state)
|
||||
{
|
||||
int ret = 0;
|
||||
int rc;
|
||||
@@ -2173,7 +2175,6 @@ static int ecdh_sha2_nistp(LIBSSH2_SESSION *session, libssh2_curve_type type,
|
||||
}
|
||||
_libssh2_debug((session, LIBSSH2_TRACE_KEX,
|
||||
"Server to Client compression initialized"));
|
||||
|
||||
}
|
||||
|
||||
clean_exit:
|
||||
@@ -2322,7 +2323,6 @@ ecdh_clean_exit:
|
||||
/* curve25519_sha256
|
||||
* Elliptic Curve Key Exchange
|
||||
*/
|
||||
|
||||
static int
|
||||
curve25519_sha256(LIBSSH2_SESSION *session, unsigned char *data,
|
||||
size_t data_len,
|
||||
@@ -2809,7 +2809,6 @@ clean_exit:
|
||||
* Elliptic Curve X25519 Key Exchange with SHA256 hash
|
||||
*
|
||||
*/
|
||||
|
||||
static int
|
||||
kex_method_curve25519_key_exchange
|
||||
(LIBSSH2_SESSION * session, key_exchange_state_low_t * key_state)
|
||||
@@ -3533,7 +3532,7 @@ static int kex_agree_crypt(LIBSSH2_SESSION * session,
|
||||
const LIBSSH2_CRYPT_METHOD **cryptp = libssh2_crypt_methods();
|
||||
unsigned char *s;
|
||||
|
||||
(void) session;
|
||||
(void)session;
|
||||
|
||||
if(endpoint->crypt_prefs) {
|
||||
s = (unsigned char *) endpoint->crypt_prefs;
|
||||
@@ -3588,7 +3587,7 @@ static int kex_agree_mac(LIBSSH2_SESSION * session,
|
||||
{
|
||||
const LIBSSH2_MAC_METHOD **macp = _libssh2_mac_methods();
|
||||
unsigned char *s;
|
||||
(void) session;
|
||||
(void)session;
|
||||
|
||||
if(endpoint->mac_prefs) {
|
||||
s = (unsigned char *) endpoint->mac_prefs;
|
||||
@@ -3641,7 +3640,7 @@ static int kex_agree_comp(LIBSSH2_SESSION *session,
|
||||
{
|
||||
const LIBSSH2_COMP_METHOD **compp = _libssh2_comp_methods(session);
|
||||
unsigned char *s;
|
||||
(void) session;
|
||||
(void)session;
|
||||
|
||||
if(endpoint->comp_prefs) {
|
||||
s = (unsigned char *) endpoint->comp_prefs;
|
||||
@@ -3950,44 +3949,42 @@ libssh2_session_method_pref(LIBSSH2_SESSION * session, int method_type,
|
||||
switch(method_type) {
|
||||
case LIBSSH2_METHOD_KEX:
|
||||
prefvar = &session->kex_prefs;
|
||||
mlist = (const LIBSSH2_COMMON_METHOD **) libssh2_kex_methods;
|
||||
mlist = (const LIBSSH2_COMMON_METHOD **)libssh2_kex_methods;
|
||||
break;
|
||||
|
||||
case LIBSSH2_METHOD_HOSTKEY:
|
||||
prefvar = &session->hostkey_prefs;
|
||||
mlist = (const LIBSSH2_COMMON_METHOD **) libssh2_hostkey_methods();
|
||||
mlist = (const LIBSSH2_COMMON_METHOD **)libssh2_hostkey_methods();
|
||||
break;
|
||||
|
||||
case LIBSSH2_METHOD_CRYPT_CS:
|
||||
prefvar = &session->local.crypt_prefs;
|
||||
mlist = (const LIBSSH2_COMMON_METHOD **) libssh2_crypt_methods();
|
||||
mlist = (const LIBSSH2_COMMON_METHOD **)libssh2_crypt_methods();
|
||||
break;
|
||||
|
||||
case LIBSSH2_METHOD_CRYPT_SC:
|
||||
prefvar = &session->remote.crypt_prefs;
|
||||
mlist = (const LIBSSH2_COMMON_METHOD **) libssh2_crypt_methods();
|
||||
mlist = (const LIBSSH2_COMMON_METHOD **)libssh2_crypt_methods();
|
||||
break;
|
||||
|
||||
case LIBSSH2_METHOD_MAC_CS:
|
||||
prefvar = &session->local.mac_prefs;
|
||||
mlist = (const LIBSSH2_COMMON_METHOD **) _libssh2_mac_methods();
|
||||
mlist = (const LIBSSH2_COMMON_METHOD **)_libssh2_mac_methods();
|
||||
break;
|
||||
|
||||
case LIBSSH2_METHOD_MAC_SC:
|
||||
prefvar = &session->remote.mac_prefs;
|
||||
mlist = (const LIBSSH2_COMMON_METHOD **) _libssh2_mac_methods();
|
||||
mlist = (const LIBSSH2_COMMON_METHOD **)_libssh2_mac_methods();
|
||||
break;
|
||||
|
||||
case LIBSSH2_METHOD_COMP_CS:
|
||||
prefvar = &session->local.comp_prefs;
|
||||
mlist = (const LIBSSH2_COMMON_METHOD **)
|
||||
_libssh2_comp_methods(session);
|
||||
mlist = (const LIBSSH2_COMMON_METHOD **)_libssh2_comp_methods(session);
|
||||
break;
|
||||
|
||||
case LIBSSH2_METHOD_COMP_SC:
|
||||
prefvar = &session->remote.comp_prefs;
|
||||
mlist = (const LIBSSH2_COMMON_METHOD **)
|
||||
_libssh2_comp_methods(session);
|
||||
mlist = (const LIBSSH2_COMMON_METHOD **)_libssh2_comp_methods(session);
|
||||
break;
|
||||
|
||||
case LIBSSH2_METHOD_LANG_CS:
|
||||
@@ -4077,27 +4074,26 @@ LIBSSH2_API int libssh2_session_supported_algs(LIBSSH2_SESSION* session,
|
||||
|
||||
switch(method_type) {
|
||||
case LIBSSH2_METHOD_KEX:
|
||||
mlist = (const LIBSSH2_COMMON_METHOD **) libssh2_kex_methods;
|
||||
mlist = (const LIBSSH2_COMMON_METHOD **)libssh2_kex_methods;
|
||||
break;
|
||||
|
||||
case LIBSSH2_METHOD_HOSTKEY:
|
||||
mlist = (const LIBSSH2_COMMON_METHOD **) libssh2_hostkey_methods();
|
||||
mlist = (const LIBSSH2_COMMON_METHOD **)libssh2_hostkey_methods();
|
||||
break;
|
||||
|
||||
case LIBSSH2_METHOD_CRYPT_CS:
|
||||
case LIBSSH2_METHOD_CRYPT_SC:
|
||||
mlist = (const LIBSSH2_COMMON_METHOD **) libssh2_crypt_methods();
|
||||
mlist = (const LIBSSH2_COMMON_METHOD **)libssh2_crypt_methods();
|
||||
break;
|
||||
|
||||
case LIBSSH2_METHOD_MAC_CS:
|
||||
case LIBSSH2_METHOD_MAC_SC:
|
||||
mlist = (const LIBSSH2_COMMON_METHOD **) _libssh2_mac_methods();
|
||||
mlist = (const LIBSSH2_COMMON_METHOD **)_libssh2_mac_methods();
|
||||
break;
|
||||
|
||||
case LIBSSH2_METHOD_COMP_CS:
|
||||
case LIBSSH2_METHOD_COMP_SC:
|
||||
mlist = (const LIBSSH2_COMMON_METHOD **)
|
||||
_libssh2_comp_methods(session);
|
||||
mlist = (const LIBSSH2_COMMON_METHOD **)_libssh2_comp_methods(session);
|
||||
break;
|
||||
|
||||
case LIBSSH2_METHOD_SIGN_ALGO:
|
||||
|
||||
@@ -122,7 +122,7 @@ static struct libssh2_knownhost *knownhost_to_external(struct known_host *node)
|
||||
ext->magic = KNOWNHOST_MAGIC;
|
||||
ext->node = node;
|
||||
ext->name = ((node->typemask & LIBSSH2_KNOWNHOST_TYPE_MASK) ==
|
||||
LIBSSH2_KNOWNHOST_TYPE_PLAIN)? node->name:NULL;
|
||||
LIBSSH2_KNOWNHOST_TYPE_PLAIN) ? node->name : NULL;
|
||||
ext->key = node->key;
|
||||
ext->typemask = node->typemask;
|
||||
|
||||
|
||||
@@ -59,14 +59,14 @@ _libssh2_rsa_new(libssh2_rsa_ctx ** rsa,
|
||||
const unsigned char *coeffdata, unsigned long coefflen)
|
||||
{
|
||||
int rc;
|
||||
(void) e1data;
|
||||
(void) e1len;
|
||||
(void) e2data;
|
||||
(void) e2len;
|
||||
|
||||
(void)e1data;
|
||||
(void)e1len;
|
||||
(void)e2data;
|
||||
(void)e2len;
|
||||
|
||||
if(ddata) {
|
||||
rc = gcry_sexp_build
|
||||
(rsa, NULL,
|
||||
rc = gcry_sexp_build(rsa, NULL,
|
||||
"(private-key(rsa(n%b)(e%b)(d%b)(q%b)(p%b)(u%b)))",
|
||||
nlen, ndata, elen, edata, dlen, ddata, plen, pdata,
|
||||
qlen, qdata, coefflen, coeffdata);
|
||||
@@ -130,8 +130,7 @@ _libssh2_dsa_new(libssh2_dsa_ctx ** dsactx,
|
||||
int rc;
|
||||
|
||||
if(x_len) {
|
||||
rc = gcry_sexp_build
|
||||
(dsactx, NULL,
|
||||
rc = gcry_sexp_build(dsactx, NULL,
|
||||
"(private-key(dsa(p%b)(q%b)(g%b)(y%b)(x%b)))",
|
||||
p_len, p, q_len, q, g_len, g, y_len, y, x_len, x);
|
||||
}
|
||||
@@ -198,7 +197,7 @@ _libssh2_rsa_new_private(libssh2_rsa_ctx ** rsa,
|
||||
ret = -1;
|
||||
goto fail;
|
||||
}
|
||||
/* First read Version field (should be 0). */
|
||||
/* First read Version field (should be 0). */
|
||||
ret = _libssh2_pem_decode_integer(&data, &datalen, &n, &nlen);
|
||||
if(ret || (nlen != 1 && *n != '\0')) {
|
||||
ret = -1;
|
||||
@@ -316,7 +315,7 @@ _libssh2_dsa_new_private(libssh2_dsa_ctx ** dsa,
|
||||
goto fail;
|
||||
}
|
||||
|
||||
/* First read Version field (should be 0). */
|
||||
/* First read Version field (should be 0). */
|
||||
ret = _libssh2_pem_decode_integer(&data, &datalen, &p, &plen);
|
||||
if(ret || (plen != 1 && *p != '\0')) {
|
||||
ret = -1;
|
||||
@@ -464,7 +463,7 @@ _libssh2_dsa_sha1_sign(libssh2_dsa_ctx * dsactx,
|
||||
|
||||
memset(sig, 0, 40);
|
||||
|
||||
/* Extract R. */
|
||||
/* Extract R. */
|
||||
|
||||
data = gcry_sexp_find_token(sig_sexp, "r", 0);
|
||||
if(!data)
|
||||
@@ -486,7 +485,7 @@ _libssh2_dsa_sha1_sign(libssh2_dsa_ctx * dsactx,
|
||||
|
||||
gcry_sexp_release(data);
|
||||
|
||||
/* Extract S. */
|
||||
/* Extract S. */
|
||||
|
||||
data = gcry_sexp_find_token(sig_sexp, "s", 0);
|
||||
if(!data)
|
||||
@@ -560,7 +559,7 @@ _libssh2_cipher_init(_libssh2_cipher_ctx * h,
|
||||
int mode = _libssh2_gcry_mode(algo);
|
||||
size_t keylen = gcry_cipher_get_algo_keylen(cipher);
|
||||
|
||||
(void) encrypt;
|
||||
(void)encrypt;
|
||||
|
||||
ret = gcry_cipher_open(h, cipher, mode, 0);
|
||||
if(ret) {
|
||||
|
||||
12
src/mac.c
12
src/mac.c
@@ -84,7 +84,7 @@ mac_method_common_init(LIBSSH2_SESSION * session, unsigned char *key,
|
||||
{
|
||||
*abstract = key;
|
||||
*free_key = 0;
|
||||
(void) session;
|
||||
(void)session;
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -121,7 +121,7 @@ mac_method_hmac_sha2_512_hash(LIBSSH2_SESSION * session,
|
||||
{
|
||||
libssh2_hmac_ctx ctx;
|
||||
unsigned char seqno_buf[4];
|
||||
(void) session;
|
||||
(void)session;
|
||||
|
||||
_libssh2_htonu32(seqno_buf, seqno);
|
||||
|
||||
@@ -166,7 +166,7 @@ mac_method_hmac_sha2_256_hash(LIBSSH2_SESSION * session,
|
||||
{
|
||||
libssh2_hmac_ctx ctx;
|
||||
unsigned char seqno_buf[4];
|
||||
(void) session;
|
||||
(void)session;
|
||||
|
||||
_libssh2_htonu32(seqno_buf, seqno);
|
||||
|
||||
@@ -211,7 +211,7 @@ mac_method_hmac_sha1_hash(LIBSSH2_SESSION * session,
|
||||
{
|
||||
libssh2_hmac_ctx ctx;
|
||||
unsigned char seqno_buf[4];
|
||||
(void) session;
|
||||
(void)session;
|
||||
|
||||
_libssh2_htonu32(seqno_buf, seqno);
|
||||
|
||||
@@ -284,7 +284,7 @@ mac_method_hmac_md5_hash(LIBSSH2_SESSION * session, unsigned char *buf,
|
||||
{
|
||||
libssh2_hmac_ctx ctx;
|
||||
unsigned char seqno_buf[4];
|
||||
(void) session;
|
||||
(void)session;
|
||||
|
||||
_libssh2_htonu32(seqno_buf, seqno);
|
||||
|
||||
@@ -357,7 +357,7 @@ mac_method_hmac_ripemd160_hash(LIBSSH2_SESSION * session,
|
||||
{
|
||||
libssh2_hmac_ctx ctx;
|
||||
unsigned char seqno_buf[4];
|
||||
(void) session;
|
||||
(void)session;
|
||||
|
||||
_libssh2_htonu32(seqno_buf, seqno);
|
||||
|
||||
|
||||
@@ -145,8 +145,8 @@ _libssh2_mbedtls_cipher_crypt(_libssh2_cipher_ctx *ctx,
|
||||
unsigned char *output;
|
||||
size_t osize, olen, finish_olen;
|
||||
|
||||
(void) encrypt;
|
||||
(void) algo;
|
||||
(void)encrypt;
|
||||
(void)algo;
|
||||
|
||||
osize = blocklen + mbedtls_cipher_get_block_size(ctx);
|
||||
|
||||
@@ -614,7 +614,8 @@ _libssh2_mbedtls_rsa_sha1_sign(LIBSSH2_SESSION * session,
|
||||
libssh2_rsa_ctx * rsactx,
|
||||
const unsigned char *hash,
|
||||
size_t hash_len,
|
||||
unsigned char **signature, size_t *signature_len)
|
||||
unsigned char **signature,
|
||||
size_t *signature_len)
|
||||
{
|
||||
return _libssh2_mbedtls_rsa_sha2_sign(session, rsactx, hash, hash_len,
|
||||
signature, signature_len);
|
||||
|
||||
14
src/misc.c
14
src/misc.c
@@ -162,7 +162,7 @@ _libssh2_recv(libssh2_socket_t sock, void *buffer, size_t length,
|
||||
{
|
||||
ssize_t rc;
|
||||
|
||||
(void) abstract;
|
||||
(void)abstract;
|
||||
|
||||
rc = recv(sock, buffer, length, flags);
|
||||
#ifdef WIN32
|
||||
@@ -195,7 +195,7 @@ _libssh2_send(libssh2_socket_t sock, const void *buffer, size_t length,
|
||||
{
|
||||
ssize_t rc;
|
||||
|
||||
(void) abstract;
|
||||
(void)abstract;
|
||||
|
||||
rc = send(sock, buffer, length, flags);
|
||||
#ifdef WIN32
|
||||
@@ -545,8 +545,8 @@ _libssh2_debug_low(LIBSSH2_SESSION * session, int context, const char *format,
|
||||
LIBSSH2_API int
|
||||
libssh2_trace(LIBSSH2_SESSION * session, int bitmask)
|
||||
{
|
||||
(void) session;
|
||||
(void) bitmask;
|
||||
(void)session;
|
||||
(void)bitmask;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -554,9 +554,9 @@ LIBSSH2_API int
|
||||
libssh2_trace_sethandler(LIBSSH2_SESSION *session, void *handler_context,
|
||||
libssh2_trace_handler_func callback)
|
||||
{
|
||||
(void) session;
|
||||
(void) handler_context;
|
||||
(void) callback;
|
||||
(void)session;
|
||||
(void)handler_context;
|
||||
(void)callback;
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -491,8 +491,9 @@ _libssh2_cipher_crypt(_libssh2_cipher_ctx * ctx,
|
||||
unsigned char buf[EVP_MAX_BLOCK_LENGTH];
|
||||
int ret;
|
||||
int rc = 1;
|
||||
(void) algo;
|
||||
(void) encrypt;
|
||||
|
||||
(void)algo;
|
||||
(void)encrypt;
|
||||
|
||||
#ifdef HAVE_OPAQUE_STRUCTS
|
||||
ret = EVP_Cipher(*ctx, buf, block, (unsigned int) blocksize);
|
||||
@@ -544,7 +545,8 @@ static int
|
||||
passphrase_cb(char *buf, int size, int rwflag, char *passphrase)
|
||||
{
|
||||
int passphrase_len = (int) strlen(passphrase);
|
||||
(void) rwflag;
|
||||
|
||||
(void)rwflag;
|
||||
|
||||
if(passphrase_len > (size - 1)) {
|
||||
passphrase_len = size - 1;
|
||||
@@ -1003,11 +1005,14 @@ _libssh2_dsa_new_private_frommemory(libssh2_dsa_ctx ** dsa,
|
||||
_libssh2_init_if_needed();
|
||||
|
||||
rc = read_private_key_from_memory((void **)dsa, read_dsa,
|
||||
filedata, filedata_len, passphrase);
|
||||
filedata, filedata_len,
|
||||
passphrase);
|
||||
|
||||
if(rc) {
|
||||
rc = read_openssh_private_key_from_memory((void **)dsa, session,
|
||||
"ssh-dsa", filedata, filedata_len, passphrase);
|
||||
"ssh-dsa",
|
||||
filedata, filedata_len,
|
||||
passphrase);
|
||||
}
|
||||
|
||||
return rc;
|
||||
@@ -1299,7 +1304,8 @@ _libssh2_dsa_new_private(libssh2_dsa_ctx ** dsa,
|
||||
int
|
||||
_libssh2_ecdsa_new_private_frommemory(libssh2_ecdsa_ctx ** ec_ctx,
|
||||
LIBSSH2_SESSION * session,
|
||||
const char *filedata, size_t filedata_len,
|
||||
const char *filedata,
|
||||
size_t filedata_len,
|
||||
unsigned const char *passphrase)
|
||||
{
|
||||
int rc;
|
||||
@@ -1310,12 +1316,14 @@ _libssh2_ecdsa_new_private_frommemory(libssh2_ecdsa_ctx ** ec_ctx,
|
||||
_libssh2_init_if_needed();
|
||||
|
||||
rc = read_private_key_from_memory((void **) ec_ctx, read_ec,
|
||||
filedata, filedata_len, passphrase);
|
||||
filedata, filedata_len,
|
||||
passphrase);
|
||||
|
||||
if(rc) {
|
||||
rc = read_openssh_private_key_from_memory((void **)ec_ctx, session,
|
||||
"ssh-ecdsa", filedata,
|
||||
filedata_len, passphrase);
|
||||
"ssh-ecdsa",
|
||||
filedata, filedata_len,
|
||||
passphrase);
|
||||
}
|
||||
|
||||
return rc;
|
||||
@@ -1942,7 +1950,8 @@ _libssh2_ed25519_new_private_frommemory(libssh2_ed25519_ctx ** ed_ctx,
|
||||
if(read_private_key_from_memory((void **)&ctx,
|
||||
(pem_read_bio_func)
|
||||
&PEM_read_bio_PrivateKey,
|
||||
filedata, filedata_len, passphrase) == 0) {
|
||||
filedata, filedata_len,
|
||||
passphrase) == 0) {
|
||||
if(EVP_PKEY_id(ctx) != EVP_PKEY_ED25519) {
|
||||
_libssh2_ed25519_free(ctx);
|
||||
return _libssh2_error(session, LIBSSH2_ERROR_PROTO,
|
||||
@@ -2082,7 +2091,8 @@ _libssh2_dsa_sha1_sign(libssh2_dsa_ctx * dsactx,
|
||||
const BIGNUM * r;
|
||||
const BIGNUM * s;
|
||||
int r_len, s_len;
|
||||
(void) hash_len;
|
||||
|
||||
(void)hash_len;
|
||||
|
||||
sig = DSA_do_sign(hash, SHA_DIGEST_LENGTH, dsactx);
|
||||
if(!sig) {
|
||||
|
||||
@@ -282,7 +282,7 @@ scp_recv(LIBSSH2_SESSION * session, const char *path, libssh2_struct_stat * sb)
|
||||
session->scpRecv_atime = 0;
|
||||
|
||||
session->scpRecv_command_len =
|
||||
_libssh2_shell_quotedsize(path) + sizeof("scp -f ") + (sb?1:0);
|
||||
_libssh2_shell_quotedsize(path) + sizeof("scp -f ") + (sb ? 1 : 0);
|
||||
|
||||
session->scpRecv_command =
|
||||
LIBSSH2_ALLOC(session, session->scpRecv_command_len);
|
||||
@@ -296,7 +296,7 @@ scp_recv(LIBSSH2_SESSION * session, const char *path, libssh2_struct_stat * sb)
|
||||
|
||||
snprintf((char *)session->scpRecv_command,
|
||||
session->scpRecv_command_len,
|
||||
"scp -%sf ", sb?"p":"");
|
||||
"scp -%sf ", sb ? "p" : "");
|
||||
|
||||
cmd_len = strlen((char *)session->scpRecv_command);
|
||||
cmd_len += shell_quotearg(path,
|
||||
@@ -843,7 +843,7 @@ scp_send(LIBSSH2_SESSION * session, const char *path, int mode,
|
||||
if(session->scpSend_state == libssh2_NB_state_idle) {
|
||||
session->scpSend_command_len =
|
||||
_libssh2_shell_quotedsize(path) + sizeof("scp -t ") +
|
||||
((mtime || atime)?1:0);
|
||||
((mtime || atime) ? 1 : 0);
|
||||
|
||||
session->scpSend_command =
|
||||
LIBSSH2_ALLOC(session, session->scpSend_command_len);
|
||||
@@ -857,7 +857,7 @@ scp_send(LIBSSH2_SESSION * session, const char *path, int mode,
|
||||
|
||||
snprintf((char *)session->scpSend_command,
|
||||
session->scpSend_command_len,
|
||||
"scp -%st ", (mtime || atime)?"p":"");
|
||||
"scp -%st ", (mtime || atime) ? "p" : "");
|
||||
|
||||
cmd_len = strlen((char *)session->scpSend_command);
|
||||
cmd_len += shell_quotearg(path,
|
||||
|
||||
@@ -75,7 +75,7 @@
|
||||
static
|
||||
LIBSSH2_ALLOC_FUNC(libssh2_default_alloc)
|
||||
{
|
||||
(void) abstract;
|
||||
(void)abstract;
|
||||
return malloc(count);
|
||||
}
|
||||
|
||||
@@ -84,7 +84,7 @@ LIBSSH2_ALLOC_FUNC(libssh2_default_alloc)
|
||||
static
|
||||
LIBSSH2_FREE_FUNC(libssh2_default_free)
|
||||
{
|
||||
(void) abstract;
|
||||
(void)abstract;
|
||||
free(ptr);
|
||||
}
|
||||
|
||||
@@ -93,7 +93,7 @@ LIBSSH2_FREE_FUNC(libssh2_default_free)
|
||||
static
|
||||
LIBSSH2_REALLOC_FUNC(libssh2_default_realloc)
|
||||
{
|
||||
(void) abstract;
|
||||
(void)abstract;
|
||||
return realloc(ptr, count);
|
||||
}
|
||||
|
||||
@@ -1428,7 +1428,7 @@ _libssh2_session_set_blocking(LIBSSH2_SESSION *session, int blocking)
|
||||
{
|
||||
int bl = session->api_block_mode;
|
||||
_libssh2_debug((session, LIBSSH2_TRACE_CONN,
|
||||
"Setting blocking mode %s", blocking?"ON":"OFF"));
|
||||
"Setting blocking mode %s", blocking ? "ON" : "OFF"));
|
||||
session->api_block_mode = blocking;
|
||||
|
||||
return bl;
|
||||
@@ -1442,7 +1442,7 @@ _libssh2_session_set_blocking(LIBSSH2_SESSION *session, int blocking)
|
||||
LIBSSH2_API void
|
||||
libssh2_session_set_blocking(LIBSSH2_SESSION * session, int blocking)
|
||||
{
|
||||
(void) _libssh2_session_set_blocking(session, blocking);
|
||||
(void)_libssh2_session_set_blocking(session, blocking);
|
||||
}
|
||||
|
||||
/* libssh2_session_get_blocking
|
||||
|
||||
12
src/sftp.c
12
src/sftp.c
@@ -741,8 +741,8 @@ LIBSSH2_CHANNEL_CLOSE_FUNC(libssh2_sftp_dtor)
|
||||
{
|
||||
LIBSSH2_SFTP *sftp = (LIBSSH2_SFTP *) (*channel_abstract);
|
||||
|
||||
(void) session_abstract;
|
||||
(void) channel;
|
||||
(void)session_abstract;
|
||||
(void)channel;
|
||||
|
||||
/* Free the partial packet storage for sftp_packet_read */
|
||||
if(sftp->partial_packet) {
|
||||
@@ -1107,7 +1107,7 @@ sftp_open(LIBSSH2_SFTP *sftp, const char *filename,
|
||||
};
|
||||
unsigned char *s;
|
||||
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) {
|
||||
sftp->last_errno = LIBSSH2_FX_OK;
|
||||
@@ -2059,7 +2059,7 @@ static ssize_t sftp_write(LIBSSH2_SFTP_HANDLE *handle, const char *buffer,
|
||||
acked but we haven't been able to return as such yet, so we will
|
||||
get that data as well passed in here again.
|
||||
*/
|
||||
already = (size_t) (handle->u.file.offset_sent -
|
||||
already = (size_t)(handle->u.file.offset_sent -
|
||||
handle->u.file.offset)+
|
||||
handle->u.file.acked;
|
||||
|
||||
@@ -2839,8 +2839,8 @@ static int sftp_rename(LIBSSH2_SFTP *sftp, const char *source_filename,
|
||||
size_t data_len = 0;
|
||||
int retcode;
|
||||
uint32_t packet_len =
|
||||
source_filename_len + dest_filename_len + 17 + (sftp->version >=
|
||||
5 ? 4 : 0);
|
||||
source_filename_len + dest_filename_len + 17 +
|
||||
(sftp->version >= 5 ? 4 : 0);
|
||||
/* packet_len(4) + packet_type(1) + request_id(4) +
|
||||
source_filename_len(4) + dest_filename_len(4) + flags(4){SFTP5+) */
|
||||
unsigned char *data = NULL;
|
||||
|
||||
@@ -68,7 +68,7 @@ struct sftp_zombie_requests {
|
||||
};
|
||||
|
||||
#ifndef MIN
|
||||
#define MIN(x,y) ((x)<(y)?(x):(y))
|
||||
#define MIN(x,y) ((x) < (y) ? (x) : (y))
|
||||
#endif
|
||||
|
||||
struct _LIBSSH2_SFTP_PACKET
|
||||
|
||||
@@ -201,8 +201,7 @@ fullpacket(LIBSSH2_SESSION * session, int encrypted /* 1 or 0 */ )
|
||||
session->fullpacket_payload_len -= p->padding_length;
|
||||
|
||||
/* Check for and deal with decompression */
|
||||
compressed =
|
||||
session->local.comp &&
|
||||
compressed = session->local.comp &&
|
||||
session->local.comp->compress &&
|
||||
((session->state & LIBSSH2_STATE_AUTHENTICATED) ||
|
||||
session->local.comp->use_in_auth);
|
||||
@@ -372,8 +371,7 @@ int _libssh2_transport_read(LIBSSH2_SESSION * session)
|
||||
}
|
||||
|
||||
/* now read a big chunk from the network into the temp buffer */
|
||||
nread =
|
||||
LIBSSH2_RECV(session, &p->buf[remainbuf],
|
||||
nread = LIBSSH2_RECV(session, &p->buf[remainbuf],
|
||||
PACKETBUFSIZE - remainbuf,
|
||||
LIBSSH2_SOCKET_RECV_FLAGS(session));
|
||||
if(nread <= 0) {
|
||||
@@ -461,8 +459,7 @@ int _libssh2_transport_read(LIBSSH2_SESSION * session)
|
||||
|
||||
/* total_num is the number of bytes following the initial
|
||||
(5 bytes) packet length and padding length fields */
|
||||
total_num =
|
||||
p->packet_length - 1 +
|
||||
total_num = p->packet_length - 1 +
|
||||
(encrypted ? session->remote.mac->mac_len : 0);
|
||||
|
||||
/* RFC4253 section 6.1 Maximum Packet Length says:
|
||||
@@ -771,8 +768,7 @@ int _libssh2_transport_send(LIBSSH2_SESSION *session,
|
||||
|
||||
encrypted = (session->state & LIBSSH2_STATE_NEWKEYS) ? 1 : 0;
|
||||
|
||||
compressed =
|
||||
session->local.comp &&
|
||||
compressed = session->local.comp &&
|
||||
session->local.comp->compress &&
|
||||
((session->state & LIBSSH2_STATE_AUTHENTICATED) ||
|
||||
session->local.comp->use_in_auth);
|
||||
|
||||
@@ -223,7 +223,7 @@ static char *userauth_list(LIBSSH2_SESSION *session, const char *username,
|
||||
}
|
||||
|
||||
session->userauth_list_state = libssh2_NB_state_idle;
|
||||
return (char *) session->userauth_list_data;
|
||||
return (char *)session->userauth_list_data;
|
||||
}
|
||||
|
||||
/* libssh2_userauth_list
|
||||
@@ -276,7 +276,7 @@ libssh2_userauth_banner(LIBSSH2_SESSION *session, char **banner)
|
||||
LIBSSH2_API int
|
||||
libssh2_userauth_authenticated(LIBSSH2_SESSION * session)
|
||||
{
|
||||
return (session->state & LIBSSH2_STATE_AUTHENTICATED)?1:0;
|
||||
return (session->state & LIBSSH2_STATE_AUTHENTICATED) ? 1 : 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -610,8 +610,8 @@ memory_read_publickey(LIBSSH2_SESSION * session, unsigned char **method,
|
||||
sp2 = pubkey + pubkey_len;
|
||||
}
|
||||
|
||||
if(libssh2_base64_decode(session, (char **) &tmp, &tmp_len,
|
||||
(const char *) sp1,
|
||||
if(libssh2_base64_decode(session, (char **)&tmp, &tmp_len,
|
||||
(const char *)sp1,
|
||||
(unsigned int)(sp2 - sp1))) {
|
||||
LIBSSH2_FREE(session, pubkey);
|
||||
return _libssh2_error(session, LIBSSH2_ERROR_FILE,
|
||||
@@ -715,8 +715,8 @@ file_read_publickey(LIBSSH2_SESSION * session, unsigned char **method,
|
||||
sp2 = pubkey + pubkey_len;
|
||||
}
|
||||
|
||||
if(libssh2_base64_decode(session, (char **) &tmp, &tmp_len,
|
||||
(const char *) sp1,
|
||||
if(libssh2_base64_decode(session, (char **)&tmp, &tmp_len,
|
||||
(const char *)sp1,
|
||||
(unsigned int)(sp2 - sp1))) {
|
||||
LIBSSH2_FREE(session, pubkey);
|
||||
return _libssh2_error(session, LIBSSH2_ERROR_FILE,
|
||||
|
||||
Reference in New Issue
Block a user