mirror of
https://github.com/libssh2/libssh2.git
synced 2025-11-20 02:42:09 +03:00
lib: fix various compiler warnings
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
/* Copyright (c) 2004-2007 Sara Golemon <sarag@libssh2.org>
|
||||
* Copyright (c) 2005 Mikhail Gusarov <dottedmag@dottedmag.net>
|
||||
* Copyright (c) 2008-2014 by Daniel Stenberg
|
||||
* Copyright (c) 2008-2019 by Daniel Stenberg
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
@@ -1180,7 +1180,7 @@ channel_x11_req(LIBSSH2_CHANNEL *channel, int single_connection,
|
||||
|
||||
_libssh2_random(buffer, LIBSSH2_X11_RANDOM_COOKIE_LEN / 2);
|
||||
for(i = 0; i < (LIBSSH2_X11_RANDOM_COOKIE_LEN / 2); i++) {
|
||||
snprintf((char *)&s[i*2], 3, "%02X%c", buffer[i], '\0');
|
||||
snprintf((char *)&s[i*2], 3, "%02X", buffer[i]);
|
||||
}
|
||||
}
|
||||
s += cookie_len;
|
||||
@@ -1439,7 +1439,7 @@ _libssh2_channel_flush(LIBSSH2_CHANNEL *channel, int streamid)
|
||||
&& ((packet->data_len >= 5)
|
||||
&& (_libssh2_ntohu32(packet->data + 1) == channel->local.id))) {
|
||||
/* It's our channel at least */
|
||||
unsigned int packet_stream_id;
|
||||
int packet_stream_id;
|
||||
|
||||
if(packet_type == SSH_MSG_CHANNEL_DATA) {
|
||||
packet_stream_id = 0;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* Copyright (C) 2009, 2010 Simon Josefsson
|
||||
* Copyright (C) 2006, 2007 The Written Word, Inc. All rights reserved.
|
||||
* Copyright (C) 2010 Daniel Stenberg
|
||||
* Copyright (C) 2010-2019 Daniel Stenberg
|
||||
*
|
||||
* Redistribution and use in source and binary forms,
|
||||
* with or without modification, are permitted provided
|
||||
@@ -233,4 +233,4 @@ int _libssh2_pub_priv_keyfilememory(LIBSSH2_SESSION *session,
|
||||
size_t privatekeydata_len,
|
||||
const char *passphrase);
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* Copyright (c) 2004-2006, Sara Golemon <sarag@libssh2.org>
|
||||
* Copyright (c) 2009-2014 by Daniel Stenberg
|
||||
* Copyright (c) 2009-2019 by Daniel Stenberg
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms,
|
||||
@@ -66,7 +66,7 @@ hostkey_method_ssh_rsa_init(LIBSSH2_SESSION * session,
|
||||
libssh2_rsa_ctx *rsactx;
|
||||
unsigned char *e, *n;
|
||||
int e_len, n_len;
|
||||
struct string_buf buf = { .len = 0, .offset = 0 };
|
||||
struct string_buf buf;
|
||||
|
||||
if(*abstract) {
|
||||
hostkey_method_ssh_rsa_dtor(session, abstract);
|
||||
@@ -79,6 +79,7 @@ hostkey_method_ssh_rsa_init(LIBSSH2_SESSION * session,
|
||||
return -1;
|
||||
}
|
||||
|
||||
buf.offset = 0;
|
||||
buf.data = (unsigned char*)hostkey_data;
|
||||
buf.dataptr = buf.data;
|
||||
buf.len = hostkey_data_len;
|
||||
@@ -88,7 +89,7 @@ hostkey_method_ssh_rsa_init(LIBSSH2_SESSION * session,
|
||||
|
||||
if((e_len = _libssh2_get_c_string(&buf, &e)) <= 0)
|
||||
return -1;
|
||||
|
||||
|
||||
if((n_len = _libssh2_get_c_string(&buf, &n)) <= 0)
|
||||
return -1;
|
||||
|
||||
@@ -284,8 +285,8 @@ hostkey_method_ssh_dss_init(LIBSSH2_SESSION * session,
|
||||
libssh2_dsa_ctx *dsactx;
|
||||
unsigned char *p, *q, *g, *y;
|
||||
int p_len, q_len, g_len, y_len;
|
||||
struct string_buf buf = { .len = 0, .offset = 0 };
|
||||
|
||||
struct string_buf buf;
|
||||
|
||||
if(*abstract) {
|
||||
hostkey_method_ssh_dss_dtor(session, abstract);
|
||||
*abstract = NULL;
|
||||
@@ -296,23 +297,24 @@ hostkey_method_ssh_dss_init(LIBSSH2_SESSION * session,
|
||||
"host key length too short");
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
buf.offset = 0;
|
||||
buf.data = (unsigned char*)hostkey_data;
|
||||
buf.dataptr = buf.data;
|
||||
buf.len = hostkey_data_len;
|
||||
|
||||
|
||||
if(_libssh2_match_string(&buf, "ssh-dss") != 0)
|
||||
return -1;
|
||||
|
||||
|
||||
if((p_len = _libssh2_get_c_string(&buf, &p)) < 0)
|
||||
return -1;
|
||||
|
||||
|
||||
if((q_len = _libssh2_get_c_string(&buf, &q)) < 0)
|
||||
return -1;
|
||||
|
||||
|
||||
if((g_len = _libssh2_get_c_string(&buf, &g)) < 0)
|
||||
return -1;
|
||||
|
||||
|
||||
if((y_len = _libssh2_get_c_string(&buf, &y)) < 0)
|
||||
return -1;
|
||||
|
||||
@@ -409,7 +411,7 @@ hostkey_method_ssh_dss_sig_verify(LIBSSH2_SESSION * session,
|
||||
|
||||
sig += 15;
|
||||
sig_len -= 15;
|
||||
|
||||
|
||||
return _libssh2_dsa_sha1_verify(dsactx, sig, m, m_len);
|
||||
}
|
||||
|
||||
@@ -508,7 +510,7 @@ hostkey_method_ssh_ecdsa_init(LIBSSH2_SESSION * session,
|
||||
unsigned char *type_str, *domain, *public_key;
|
||||
int key_len;
|
||||
libssh2_curve_type type;
|
||||
struct string_buf buf = { .len = 0, .offset = 0 };
|
||||
struct string_buf buf;
|
||||
|
||||
if(abstract != NULL && *abstract) {
|
||||
hostkey_method_ssh_ecdsa_dtor(session, abstract);
|
||||
@@ -521,13 +523,14 @@ hostkey_method_ssh_ecdsa_init(LIBSSH2_SESSION * session,
|
||||
return -1;
|
||||
}
|
||||
|
||||
buf.offset = 0;
|
||||
buf.data = (unsigned char*)hostkey_data;
|
||||
buf.dataptr = buf.data;
|
||||
buf.len = hostkey_data_len;
|
||||
|
||||
if(_libssh2_get_c_string(&buf, &type_str) != 19)
|
||||
return -1;
|
||||
|
||||
|
||||
if (strncmp((char*) type_str, "ecdsa-sha2-nistp256", 19) == 0 ){
|
||||
type = LIBSSH2_EC_CURVE_NISTP256;
|
||||
}else if(strncmp((char*) type_str, "ecdsa-sha2-nistp384", 19) == 0 ){
|
||||
@@ -537,10 +540,10 @@ hostkey_method_ssh_ecdsa_init(LIBSSH2_SESSION * session,
|
||||
}else{
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
if(_libssh2_get_c_string(&buf, &domain) != 8)
|
||||
return -1;
|
||||
|
||||
|
||||
if ( type == LIBSSH2_EC_CURVE_NISTP256 && strncmp((char*)domain, "nistp256", 8) != 0){
|
||||
return -1;
|
||||
}else if ( type == LIBSSH2_EC_CURVE_NISTP384 && strncmp((char*)domain, "nistp384", 8) != 0){
|
||||
@@ -548,7 +551,7 @@ hostkey_method_ssh_ecdsa_init(LIBSSH2_SESSION * session,
|
||||
}else if ( type == LIBSSH2_EC_CURVE_NISTP521 && strncmp((char*)domain, "nistp521", 8) != 0){
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
/* public key */
|
||||
if((key_len = _libssh2_get_c_string(&buf, &public_key)) <= 0)
|
||||
return -1;
|
||||
@@ -636,7 +639,7 @@ hostkey_method_ssh_ecdsa_sig_verify(LIBSSH2_SESSION * session,
|
||||
{
|
||||
unsigned char *r, *s, *name;
|
||||
unsigned int r_len, s_len, len;
|
||||
struct string_buf buf = { .len = 0, .offset = 0 };
|
||||
struct string_buf buf;
|
||||
libssh2_ecdsa_ctx *ctx = (libssh2_ecdsa_ctx *) (*abstract);
|
||||
|
||||
(void) session;
|
||||
@@ -645,19 +648,20 @@ hostkey_method_ssh_ecdsa_sig_verify(LIBSSH2_SESSION * session,
|
||||
return -1;
|
||||
|
||||
/* keyname_len(4) + keyname(19){"ecdsa-sha2-nistp256"} + signature_len(4) */
|
||||
buf.offset = 0;
|
||||
buf.data = (unsigned char*)sig;
|
||||
buf.dataptr = buf.data;
|
||||
buf.len = sig_len;
|
||||
|
||||
if(_libssh2_get_c_string(&buf, &name) != 19)
|
||||
return -1;
|
||||
|
||||
|
||||
if(_libssh2_get_u32(&buf, &len) != 0 || len < 8)
|
||||
return -1;
|
||||
|
||||
|
||||
if((r_len = _libssh2_get_c_string(&buf, &r)) <= 0)
|
||||
return -1;
|
||||
|
||||
|
||||
if((s_len = _libssh2_get_c_string(&buf, &s)) <= 0)
|
||||
return -1;
|
||||
|
||||
@@ -815,7 +819,7 @@ hostkey_method_ssh_ed25519_init(LIBSSH2_SESSION * session,
|
||||
|
||||
s += 11;
|
||||
|
||||
//public key
|
||||
/* public key */
|
||||
key_len = _libssh2_ntohu32(s);
|
||||
s += 4;
|
||||
|
||||
|
||||
62
src/kex.c
62
src/kex.c
@@ -1,5 +1,5 @@
|
||||
/* Copyright (c) 2004-2007, Sara Golemon <sarag@libssh2.org>
|
||||
* Copyright (c) 2010, Daniel Stenberg <daniel@haxx.se>
|
||||
* Copyright (c) 2010-2019, Daniel Stenberg <daniel@haxx.se>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms,
|
||||
@@ -1667,32 +1667,33 @@ kex_method_diffie_hellman_group_exchange_sha1_key_exchange
|
||||
if(key_state->state == libssh2_NB_state_sent1) {
|
||||
unsigned int p_len, g_len;
|
||||
unsigned char *p, *g;
|
||||
struct string_buf buf = { .len = 0, .offset = 0 };
|
||||
|
||||
struct string_buf buf;
|
||||
|
||||
if(key_state->data_len < 9) {
|
||||
ret = _libssh2_error(session, LIBSSH2_ERROR_PROTO,
|
||||
"Unexpected key length");
|
||||
goto dh_gex_clean_exit;
|
||||
}
|
||||
|
||||
buf.offset = 0;
|
||||
buf.data = key_state->data;
|
||||
buf.dataptr = buf.data;
|
||||
buf.len = key_state->data_len;
|
||||
|
||||
|
||||
buf.dataptr++; /* increment to big num */
|
||||
|
||||
|
||||
if((p_len = _libssh2_get_bignum_bytes(&buf, &p)) <= 0) {
|
||||
ret = _libssh2_error(session, LIBSSH2_ERROR_PROTO,
|
||||
"Unexpected value");
|
||||
goto dh_gex_clean_exit;
|
||||
}
|
||||
|
||||
|
||||
if((g_len = _libssh2_get_bignum_bytes(&buf, &g)) <= 0) {
|
||||
ret = _libssh2_error(session, LIBSSH2_ERROR_PROTO,
|
||||
"Unexpected value");
|
||||
goto dh_gex_clean_exit;
|
||||
}
|
||||
|
||||
|
||||
_libssh2_bn_from_bin(key_state->p, p_len, p);
|
||||
_libssh2_bn_from_bin(key_state->g, g_len, g);
|
||||
|
||||
@@ -1789,32 +1790,33 @@ kex_method_diffie_hellman_group_exchange_sha256_key_exchange
|
||||
if(key_state->state == libssh2_NB_state_sent1) {
|
||||
unsigned char *p, *g;
|
||||
unsigned long p_len, g_len;
|
||||
struct string_buf buf = { .len = 0, .offset = 0 };
|
||||
|
||||
struct string_buf buf;
|
||||
|
||||
if(key_state->data_len < 9) {
|
||||
ret = _libssh2_error(session, LIBSSH2_ERROR_PROTO,
|
||||
"Unexpected key length");
|
||||
goto dh_gex_clean_exit;
|
||||
}
|
||||
|
||||
buf.offset = 0;
|
||||
buf.data = key_state->data;
|
||||
buf.dataptr = buf.data;
|
||||
buf.len = key_state->data_len;
|
||||
|
||||
|
||||
buf.dataptr++; /* increment to big num */
|
||||
|
||||
|
||||
if((p_len = _libssh2_get_bignum_bytes(&buf, &p)) <= 0) {
|
||||
ret = _libssh2_error(session, LIBSSH2_ERROR_PROTO,
|
||||
"Unexpected value");
|
||||
goto dh_gex_clean_exit;
|
||||
}
|
||||
|
||||
|
||||
if((g_len = _libssh2_get_bignum_bytes(&buf, &g)) <= 0) {
|
||||
ret = _libssh2_error(session, LIBSSH2_ERROR_PROTO,
|
||||
"Unexpected value");
|
||||
goto dh_gex_clean_exit;
|
||||
}
|
||||
|
||||
|
||||
_libssh2_bn_from_bin(key_state->p, p_len, p);
|
||||
_libssh2_bn_from_bin(key_state->g, g_len, g);
|
||||
|
||||
@@ -2485,7 +2487,7 @@ kex_method_ecdh_key_exchange
|
||||
goto ecdh_clean_exit;
|
||||
}
|
||||
|
||||
rc = _libssh2_ecdsa_create_key(session, &key_state->private_key,
|
||||
rc = _libssh2_ecdsa_create_key(session, &key_state->private_key,
|
||||
&key_state->public_key_oct, &key_state->public_key_oct_len, type);
|
||||
|
||||
if(rc != 0) {
|
||||
@@ -2602,14 +2604,15 @@ static int curve25519_sha256(LIBSSH2_SESSION *session, unsigned char *data,
|
||||
/* parse INIT reply data */
|
||||
unsigned char *server_public_key, *server_host_key;
|
||||
unsigned int server_public_key_len;
|
||||
struct string_buf buf = { .len = 0, .offset = 0 };
|
||||
struct string_buf buf;
|
||||
|
||||
if(data_len < 5) {
|
||||
ret = _libssh2_error(session, LIBSSH2_ERROR_PROTO,
|
||||
"Unexpected key length");
|
||||
goto clean_exit;
|
||||
}
|
||||
|
||||
|
||||
buf.offset = 0;
|
||||
buf.data = data;
|
||||
buf.len = data_len;
|
||||
buf.dataptr = buf.data;
|
||||
@@ -2620,7 +2623,7 @@ static int curve25519_sha256(LIBSSH2_SESSION *session, unsigned char *data,
|
||||
"Unexpected key length");
|
||||
goto clean_exit;
|
||||
}
|
||||
|
||||
|
||||
session->server_hostkey = LIBSSH2_ALLOC(session, session->server_hostkey_len);
|
||||
if (!session->server_hostkey) {
|
||||
ret = _libssh2_error(session, LIBSSH2_ERROR_ALLOC,
|
||||
@@ -2721,7 +2724,7 @@ static int curve25519_sha256(LIBSSH2_SESSION *session, unsigned char *data,
|
||||
}
|
||||
|
||||
/* server public key Q_S */
|
||||
if((server_public_key_len =
|
||||
if((server_public_key_len =
|
||||
_libssh2_get_c_string(&buf, &server_public_key)) <= 0) {
|
||||
ret = _libssh2_error(session, LIBSSH2_ERROR_PROTO,
|
||||
"Unexpected key length");
|
||||
@@ -2743,7 +2746,7 @@ static int curve25519_sha256(LIBSSH2_SESSION *session, unsigned char *data,
|
||||
|
||||
}
|
||||
|
||||
// Compute the shared secret K
|
||||
/* Compute the shared secret K */
|
||||
rc = _libssh2_curve25519_gen_k(&exchange_state->k, private_key, server_public_key);
|
||||
if( rc != 0) {
|
||||
ret = _libssh2_error(session, LIBSSH2_ERROR_KEX_FAILURE,
|
||||
@@ -2753,7 +2756,7 @@ static int curve25519_sha256(LIBSSH2_SESSION *session, unsigned char *data,
|
||||
|
||||
exchange_state->k_value_len = _libssh2_bn_bytes(exchange_state->k) + 5;
|
||||
if(_libssh2_bn_bits(exchange_state->k) % 8) {
|
||||
// don't need leading 00
|
||||
/* don't need leading 00 */
|
||||
exchange_state->k_value_len--;
|
||||
}
|
||||
exchange_state->k_value =
|
||||
@@ -2772,7 +2775,7 @@ static int curve25519_sha256(LIBSSH2_SESSION *session, unsigned char *data,
|
||||
_libssh2_bn_to_bin(exchange_state->k, exchange_state->k_value + 5);
|
||||
}
|
||||
|
||||
// verify hash
|
||||
/*/ verify hash */
|
||||
LIBSSH2_KEX_METHOD_EC_SHA_HASH_CREATE_VERIFY(256);
|
||||
|
||||
if( rc != 0) {
|
||||
@@ -2809,11 +2812,14 @@ static int curve25519_sha256(LIBSSH2_SESSION *session, unsigned char *data,
|
||||
goto clean_exit;
|
||||
}
|
||||
|
||||
// The first key exchange has been performed, switch to active crypt/comp/mac mode
|
||||
/* The first key exchange has been performed, switch to active
|
||||
crypt/comp/mac mode */
|
||||
|
||||
session->state |= LIBSSH2_STATE_NEWKEYS;
|
||||
_libssh2_debug(session, LIBSSH2_TRACE_KEX, "Received NEWKEYS message");
|
||||
|
||||
// This will actually end up being just packet_type(1) for this packet type anyway
|
||||
/* This will actually end up being just packet_type(1) for this packet
|
||||
type anyway */
|
||||
LIBSSH2_FREE(session, exchange_state->tmp);
|
||||
|
||||
if(!session->session_id) {
|
||||
@@ -2831,13 +2837,13 @@ static int curve25519_sha256(LIBSSH2_SESSION *session, unsigned char *data,
|
||||
_libssh2_debug(session, LIBSSH2_TRACE_KEX, "session_id calculated");
|
||||
}
|
||||
|
||||
// Cleanup any existing cipher
|
||||
/* Cleanup any existing cipher */
|
||||
if(session->local.crypt->dtor) {
|
||||
session->local.crypt->dtor(session,
|
||||
&session->local.crypt_abstract);
|
||||
}
|
||||
|
||||
// Calculate IV/Secret/Key for each direction
|
||||
/* Calculate IV/Secret/Key for each direction */
|
||||
if(session->local.crypt->init) {
|
||||
unsigned char *iv = NULL, *secret = NULL;
|
||||
int free_iv = 0, free_secret = 0;
|
||||
@@ -2882,7 +2888,7 @@ static int curve25519_sha256(LIBSSH2_SESSION *session, unsigned char *data,
|
||||
"Client to Server IV and Key calculated");
|
||||
|
||||
if(session->remote.crypt->dtor) {
|
||||
// Cleanup any existing cipher
|
||||
/* Cleanup any existing cipher */
|
||||
session->remote.crypt->dtor(session,
|
||||
&session->remote.crypt_abstract);
|
||||
}
|
||||
@@ -2984,9 +2990,9 @@ static int curve25519_sha256(LIBSSH2_SESSION *session, unsigned char *data,
|
||||
_libssh2_debug(session, LIBSSH2_TRACE_KEX,
|
||||
"Server to Client HMAC Key calculated");
|
||||
|
||||
// Initialize compression for each direction
|
||||
/* Initialize compression for each direction */
|
||||
|
||||
// Cleanup any existing compression
|
||||
/* Cleanup any existing compression */
|
||||
if(session->local.comp && session->local.comp->dtor) {
|
||||
session->local.comp->dtor(session, 1,
|
||||
&session->local.comp_abstract);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2009-2014 by Daniel Stenberg
|
||||
* Copyright (c) 2009-2019 by Daniel Stenberg
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms,
|
||||
@@ -1048,6 +1048,7 @@ knownhost_writeline(LIBSSH2_KNOWNHOSTS *hosts,
|
||||
break;
|
||||
}
|
||||
/* otherwise fallback to default and error */
|
||||
/* FALL-THROUGH */
|
||||
default:
|
||||
return _libssh2_error(hosts->session,
|
||||
LIBSSH2_ERROR_METHOD_NOT_SUPPORTED,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* Copyright (c) 2004-2007 Sara Golemon <sarag@libssh2.org>
|
||||
* Copyright (c) 2009-2014 by Daniel Stenberg
|
||||
* Copyright (c) 2009-2019 by Daniel Stenberg
|
||||
* Copyright (c) 2010 Simon Josefsson
|
||||
* All rights reserved.
|
||||
*
|
||||
@@ -785,7 +785,7 @@ int _libssh2_get_bignum_bytes(struct string_buf *buf, unsigned char **outbuf)
|
||||
bn_len = data_len;
|
||||
bnptr = buf->dataptr;
|
||||
|
||||
// trim leading zeros
|
||||
/* trim leading zeros */
|
||||
while(bn_len > 0 && *bnptr == 0x00) {
|
||||
bn_len--;
|
||||
bnptr++;
|
||||
|
||||
@@ -871,8 +871,7 @@ gen_publickey_from_rsa_evp(LIBSSH2_SESSION *session,
|
||||
"Unable to allocate memory for private key data");
|
||||
}
|
||||
|
||||
int
|
||||
_libssh2_rsa_new_additional_parameters(RSA *rsa)
|
||||
static int _libssh2_rsa_new_additional_parameters(RSA *rsa)
|
||||
{
|
||||
BN_CTX *ctx = NULL;
|
||||
BIGNUM *aux = NULL;
|
||||
@@ -940,7 +939,7 @@ out:
|
||||
return rc;
|
||||
}
|
||||
|
||||
int
|
||||
static int
|
||||
gen_publickey_from_rsa_openssh_priv_data(LIBSSH2_SESSION *session,
|
||||
struct string_buf *decrypted,
|
||||
unsigned char **method,
|
||||
@@ -959,7 +958,7 @@ gen_publickey_from_rsa_openssh_priv_data(LIBSSH2_SESSION *session,
|
||||
LIBSSH2_TRACE_AUTH,
|
||||
"Computing RSA keys from private key data");
|
||||
|
||||
// public key data
|
||||
/* public key data */
|
||||
if((nlen = _libssh2_get_bignum_bytes(decrypted, &n)) <= 0) {
|
||||
_libssh2_error(session, LIBSSH2_ERROR_PROTO,
|
||||
"RSA no n");
|
||||
@@ -972,7 +971,7 @@ gen_publickey_from_rsa_openssh_priv_data(LIBSSH2_SESSION *session,
|
||||
return -1;
|
||||
}
|
||||
|
||||
// private key data
|
||||
/* private key data */
|
||||
if((dlen = _libssh2_get_bignum_bytes(decrypted, &d)) <= 0) {
|
||||
_libssh2_error(session, LIBSSH2_ERROR_PROTO,
|
||||
"RSA no d");
|
||||
@@ -1043,7 +1042,7 @@ fail:
|
||||
"Unable to allocate memory for private key data");
|
||||
}
|
||||
|
||||
int
|
||||
static int
|
||||
_libssh2_rsa_new_openssh_private(libssh2_rsa_ctx ** rsa,
|
||||
LIBSSH2_SESSION * session,
|
||||
const char *filename,
|
||||
@@ -1257,7 +1256,7 @@ gen_publickey_from_dsa_evp(LIBSSH2_SESSION *session,
|
||||
"Unable to allocate memory for private key data");
|
||||
}
|
||||
|
||||
int
|
||||
static int
|
||||
gen_publickey_from_dsa_openssh_priv_data(LIBSSH2_SESSION *session,
|
||||
struct string_buf *decrypted,
|
||||
unsigned char **method,
|
||||
@@ -1342,7 +1341,7 @@ fail:
|
||||
"Unable to allocate memory for private key data");
|
||||
}
|
||||
|
||||
int
|
||||
static int
|
||||
_libssh2_dsa_new_openssh_private(libssh2_dsa_ctx ** dsa,
|
||||
LIBSSH2_SESSION * session,
|
||||
const char *filename,
|
||||
@@ -1557,7 +1556,7 @@ cleanExit:
|
||||
return rc;
|
||||
}
|
||||
|
||||
int
|
||||
static int
|
||||
gen_publickey_from_ed25519_openssh_priv_data(LIBSSH2_SESSION *session,
|
||||
struct string_buf *decrypted,
|
||||
unsigned char **method,
|
||||
@@ -2304,7 +2303,7 @@ clean_exit:
|
||||
return -1;
|
||||
}
|
||||
|
||||
int
|
||||
static int
|
||||
gen_publickey_from_ecdsa_openssh_priv_data(LIBSSH2_SESSION *session,
|
||||
libssh2_curve_type curve_type,
|
||||
struct string_buf *decrypted,
|
||||
@@ -2388,7 +2387,7 @@ fail:
|
||||
|
||||
}
|
||||
|
||||
int
|
||||
static int
|
||||
_libssh2_ecdsa_new_openssh_private(libssh2_ecdsa_ctx ** ec_ctx,
|
||||
LIBSSH2_SESSION * session,
|
||||
const char *filename,
|
||||
@@ -2751,7 +2750,7 @@ _libssh2_ed25519_verify(libssh2_ed25519_ctx *ctx, const uint8_t *s,
|
||||
|
||||
#endif /* LIBSSH2_ED25519 */
|
||||
|
||||
int
|
||||
static int
|
||||
_libssh2_pub_priv_openssh_keyfile(LIBSSH2_SESSION *session,
|
||||
unsigned char **method,
|
||||
size_t *method_len,
|
||||
@@ -2936,7 +2935,7 @@ _libssh2_pub_priv_keyfile(LIBSSH2_SESSION *session,
|
||||
return st;
|
||||
}
|
||||
|
||||
int
|
||||
static int
|
||||
_libssh2_pub_priv_openssh_keyfilememory(LIBSSH2_SESSION *session,
|
||||
void **key_ctx,
|
||||
const char *key_type,
|
||||
|
||||
@@ -81,8 +81,11 @@
|
||||
#if OPENSSL_VERSION_NUMBER >= 0x10101000L && \
|
||||
!defined(LIBRESSL_VERSION_NUMBER)
|
||||
# define LIBSSH2_ED25519 1
|
||||
#else
|
||||
# define LIBSSH2_ED25519 0
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef OPENSSL_NO_MD5
|
||||
# define LIBSSH2_MD5 0
|
||||
#else
|
||||
@@ -300,7 +303,7 @@ extern void _libssh2_openssl_crypto_exit(void);
|
||||
|
||||
#define _libssh2_dsa_free(dsactx) DSA_free(dsactx)
|
||||
|
||||
#if LIBSSH2_ECDSA
|
||||
#ifdef LIBSSH2_ECDSA
|
||||
#define libssh2_ecdsa_ctx EC_KEY
|
||||
#define _libssh2_ecdsa_free(ecdsactx) EC_KEY_free(ecdsactx)
|
||||
#define _libssh2_ec_key EC_KEY
|
||||
@@ -308,14 +311,14 @@ extern void _libssh2_openssl_crypto_exit(void);
|
||||
typedef enum {
|
||||
LIBSSH2_EC_CURVE_NISTP256 = NID_X9_62_prime256v1,
|
||||
LIBSSH2_EC_CURVE_NISTP384 = NID_secp384r1,
|
||||
LIBSSH2_EC_CURVE_NISTP521 = NID_secp521r1,
|
||||
LIBSSH2_EC_CURVE_NISTP521 = NID_secp521r1
|
||||
}
|
||||
libssh2_curve_type;
|
||||
#else
|
||||
#define _libssh2_ec_key void
|
||||
#endif /* LIBSSH2_ECDSA */
|
||||
|
||||
#if LIBSSH2_ED25519
|
||||
#ifdef LIBSSH2_ED25519
|
||||
|
||||
typedef struct {
|
||||
EVP_PKEY *public_key;
|
||||
|
||||
@@ -359,7 +359,7 @@ _libssh2_pem_parse_memory(LIBSSH2_SESSION * session,
|
||||
#define OPENSSL_HEADER_BEGIN "-----BEGIN OPENSSH PRIVATE KEY-----"
|
||||
#define OPENSSL_HEADER_END "-----END OPENSSH PRIVATE KEY-----"
|
||||
|
||||
int
|
||||
static int
|
||||
_libssh2_openssh_pem_parse_data(LIBSSH2_SESSION * session,
|
||||
const unsigned char *passphrase,
|
||||
const char *b64data, size_t b64datalen,
|
||||
@@ -575,7 +575,7 @@ _libssh2_openssh_pem_parse_data(LIBSSH2_SESSION * session,
|
||||
goto out;
|
||||
}
|
||||
|
||||
while (len_decrypted <= decrypted.len - blocksize) {
|
||||
while ((size_t)len_decrypted <= decrypted.len - blocksize) {
|
||||
if (method->crypt(session, decrypted.data + len_decrypted, blocksize,
|
||||
&abstract)) {
|
||||
ret = LIBSSH2_ERROR_DECRYPT;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Copyright (c) 2009-2010 by Daniel Stenberg
|
||||
/* Copyright (c) 2009-2019 by Daniel Stenberg
|
||||
* Copyright (c) 2004-2008, Sara Golemon <sarag@libssh2.org>
|
||||
* All rights reserved.
|
||||
*
|
||||
@@ -776,8 +776,9 @@ libssh2_scp_recv(LIBSSH2_SESSION *session, const char *path, struct stat * sb)
|
||||
LIBSSH2_CHANNEL *ptr;
|
||||
|
||||
/* scp_recv uses libssh2_struct_stat, so pass one if the caller gave us a struct to populate... */
|
||||
libssh2_struct_stat sb_intl = {0};
|
||||
libssh2_struct_stat sb_intl;
|
||||
libssh2_struct_stat *sb_ptr;
|
||||
memset(&sb_intl, 0, sizeof(sb_intl));
|
||||
sb_ptr = sb ? &sb_intl : NULL;
|
||||
|
||||
BLOCK_ADJUST_ERRNO(ptr, session, scp_recv(session, path, sb_ptr));
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* Copyright (c) 2004-2008, Sara Golemon <sarag@libssh2.org>
|
||||
* Copyright (c) 2007 Eli Fant <elifantu@mail.ru>
|
||||
* Copyright (c) 2009-2014 by Daniel Stenberg
|
||||
* Copyright (c) 2009-2019 by Daniel Stenberg
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms,
|
||||
@@ -1416,7 +1416,7 @@ static ssize_t sftp_read(LIBSSH2_SFTP_HANDLE * handle, char *buffer,
|
||||
"read request id %d sent (offset: %d, size: %d)",
|
||||
request_id, (int)chunk->offset, (int)chunk->len);
|
||||
}
|
||||
|
||||
/* FALL-THROUGH */
|
||||
case libssh2_NB_state_sent:
|
||||
|
||||
sftp->read_state = libssh2_NB_state_idle;
|
||||
@@ -1456,6 +1456,7 @@ static ssize_t sftp_read(LIBSSH2_SFTP_HANDLE * handle, char *buffer,
|
||||
/* move on to the next chunk with data to send */
|
||||
chunk = _libssh2_list_next(&chunk->node);
|
||||
}
|
||||
/* FALL-THROUGH */
|
||||
|
||||
case libssh2_NB_state_sent2:
|
||||
|
||||
|
||||
Reference in New Issue
Block a user