1
0
mirror of https://github.com/libssh2/libssh2.git synced 2025-11-18 15:20:56 +03:00

checksrc: verify label indent, fix fallouts

Also update two labels to match the rest of the source.

checksrc update credit: Emanuele Torre @emanuele6

Ref: https://github.com/curl/curl/pull/11134

Closes #1042
This commit is contained in:
Viktor Szakats
2023-05-18 10:37:58 +00:00
parent bfcf796c17
commit 1c9323416c
14 changed files with 57 additions and 51 deletions

View File

@@ -75,6 +75,7 @@ my %warnings = (
'INCLUDEDUP', => 'same file is included again',
'INDENTATION' => 'wrong start column for code',
'LONGLINE' => "Line longer than $max_column",
'SPACEBEFORELABEL' => 'labels not at the start of the line',
'MULTISPACE' => 'multiple spaces used when not suitable',
'NOSPACEEQUALS' => 'equals sign without preceding space',
'NOTEQUALSZERO', => 'if/while comparison with != 0',
@@ -697,6 +698,11 @@ sub scanfile {
$line, length($1), $file, $ol, "no space before colon of switch label");
}
if($prevl !~ /\?\z/ && $l =~ /^ +([A-Za-z_][A-Za-z0-9_]*):$/ && $1 ne 'default') {
checkwarn("SPACEBEFORELABEL",
$line, length($1), $file, $ol, "no space before label");
}
# scan for use of banned functions
if($l =~ /^(.*\W)
(gmtime|localtime|

View File

@@ -584,7 +584,7 @@ agent_sign(LIBSSH2_SESSION *session, unsigned char **sig, size_t *sig_len,
}
memcpy(*sig, s, *sig_len);
error:
error:
if(method_name)
LIBSSH2_FREE(session, method_name);
@@ -727,7 +727,7 @@ agent_list_identities(LIBSSH2_AGENT *agent)
_libssh2_list_add(&agent->head, &identity->node);
}
error:
error:
LIBSSH2_FREE(agent->session, transctx->response);
transctx->response = NULL;

View File

@@ -309,7 +309,7 @@ _libssh2_channel_open(LIBSSH2_SESSION * session, const char *channel_type,
}
}
channel_error:
channel_error:
if(session->open_data) {
LIBSSH2_FREE(session, session->open_data);

View File

@@ -889,7 +889,7 @@ static int diffie_hellman_sha_algo(LIBSSH2_SESSION *session,
}
clean_exit:
clean_exit:
libssh2_dh_dtor(&exchange_state->x);
_libssh2_bn_free(exchange_state->e);
exchange_state->e = NULL;
@@ -1437,7 +1437,7 @@ kex_method_diffie_hellman_group_exchange_sha1_key_exchange(
LIBSSH2_FREE(session, key_state->data);
}
dh_gex_clean_exit:
dh_gex_clean_exit:
key_state->state = libssh2_NB_state_idle;
_libssh2_bn_free(key_state->g);
key_state->g = NULL;
@@ -1556,7 +1556,7 @@ kex_method_diffie_hellman_group_exchange_sha256_key_exchange(
LIBSSH2_FREE(session, key_state->data);
}
dh_gex_clean_exit:
dh_gex_clean_exit:
key_state->state = libssh2_NB_state_idle;
_libssh2_bn_free(key_state->g);
key_state->g = NULL;

View File

@@ -251,7 +251,7 @@ knownhost_add(LIBSSH2_KNOWNHOSTS *hosts,
*store = knownhost_to_external(entry);
return LIBSSH2_ERROR_NONE;
error:
error:
free_host(hosts->session, entry);
return rc;
}

View File

@@ -266,7 +266,7 @@ _libssh2_rsa_new_private(libssh2_rsa_ctx ** rsa,
ret = 0;
fail:
fail:
LIBSSH2_FREE(session, save_data);
return ret;
}
@@ -372,7 +372,7 @@ _libssh2_dsa_new_private(libssh2_dsa_ctx ** dsa,
ret = 0;
fail:
fail:
LIBSSH2_FREE(session, save_data);
return ret;
}
@@ -520,10 +520,10 @@ _libssh2_dsa_sha1_sign(libssh2_dsa_ctx * dsactx,
memcpy(sig + 20 + (20 - size), tmp, size);
goto out;
err:
err:
ret = -1;
out:
out:
if(sig_sexp) {
gcry_sexp_release(sig_sexp);
}

View File

@@ -824,7 +824,7 @@ gen_publickey_from_rsa_evp(LIBSSH2_SESSION *session,
*pubkeydata_len = key_len;
return 0;
__alloc_error:
__alloc_error:
if(rsa) {
RSA_free(rsa);
}
@@ -1223,7 +1223,7 @@ gen_publickey_from_dsa_evp(LIBSSH2_SESSION *session,
*pubkeydata_len = key_len;
return 0;
__alloc_error:
__alloc_error:
if(dsa) {
DSA_free(dsa);
}
@@ -1486,18 +1486,18 @@ _libssh2_curve25519_new(LIBSSH2_SESSION *session,
if(EVP_PKEY_keygen_init(pctx) != 1 ||
EVP_PKEY_keygen(pctx, &key) != 1) {
goto cleanExit;
goto clean_exit;
}
if(out_private_key) {
privLen = LIBSSH2_ED25519_KEY_LEN;
priv = LIBSSH2_ALLOC(session, privLen);
if(!priv)
goto cleanExit;
goto clean_exit;
if(EVP_PKEY_get_raw_private_key(key, priv, &privLen) != 1 ||
privLen != LIBSSH2_ED25519_KEY_LEN) {
goto cleanExit;
goto clean_exit;
}
*out_private_key = priv;
@@ -1508,11 +1508,11 @@ _libssh2_curve25519_new(LIBSSH2_SESSION *session,
pubLen = LIBSSH2_ED25519_KEY_LEN;
pub = LIBSSH2_ALLOC(session, pubLen);
if(!pub)
goto cleanExit;
goto clean_exit;
if(EVP_PKEY_get_raw_public_key(key, pub, &pubLen) != 1 ||
pubLen != LIBSSH2_ED25519_KEY_LEN) {
goto cleanExit;
goto clean_exit;
}
*out_public_key = pub;
@@ -1522,7 +1522,7 @@ _libssh2_curve25519_new(LIBSSH2_SESSION *session,
/* success */
rc = 0;
cleanExit:
clean_exit:
if(pctx)
EVP_PKEY_CTX_free(pctx);
@@ -2640,7 +2640,7 @@ gen_publickey_from_ec_evp(LIBSSH2_SESSION *session,
key = LIBSSH2_ALLOC(session, key_len);
if(!key) {
rc = -1;
goto clean_exit;
goto clean_exit;
}
/* Process key encoding. */
@@ -3311,32 +3311,32 @@ _libssh2_curve25519_gen_k(_libssh2_bn **k,
LIBSSH2_ED25519_KEY_LEN);
if(!peer_key || !server_key) {
goto cleanExit;
goto clean_exit;
}
server_key_ctx = EVP_PKEY_CTX_new(server_key, NULL);
if(!server_key_ctx) {
goto cleanExit;
goto clean_exit;
}
rc = EVP_PKEY_derive_init(server_key_ctx);
if(rc <= 0) {
goto cleanExit;
goto clean_exit;
}
rc = EVP_PKEY_derive_set_peer(server_key_ctx, peer_key);
if(rc <= 0) {
goto cleanExit;
goto clean_exit;
}
rc = EVP_PKEY_derive(server_key_ctx, NULL, &out_len);
if(rc <= 0) {
goto cleanExit;
goto clean_exit;
}
if(out_len != LIBSSH2_ED25519_KEY_LEN) {
rc = -1;
goto cleanExit;
goto clean_exit;
}
rc = EVP_PKEY_derive(server_key_ctx, out_shared_key, &out_len);
@@ -3348,7 +3348,7 @@ _libssh2_curve25519_gen_k(_libssh2_bn **k,
rc = -1;
}
cleanExit:
clean_exit:
if(server_key_ctx)
EVP_PKEY_CTX_free(server_key_ctx);
@@ -3379,7 +3379,7 @@ _libssh2_ed25519_verify(libssh2_ed25519_ctx *ctx, const uint8_t *s,
ret = EVP_DigestVerify(md_ctx, s, s_len, m, m_len);
clean_exit:
clean_exit:
EVP_MD_CTX_free(md_ctx);

View File

@@ -429,7 +429,7 @@ packet_x11_open(LIBSSH2_SESSION * session, unsigned char *data,
else
failure_code = SSH_OPEN_RESOURCE_SHORTAGE;
/* fall-trough */
x11_exit:
x11_exit:
p = x11open_state->packet;
*(p++) = SSH_MSG_CHANNEL_OPEN_FAILURE;
_libssh2_store_u32(&p, x11open_state->sender_channel);
@@ -848,7 +848,7 @@ _libssh2_packet_add(LIBSSH2_SESSION * session, unsigned char *data,
if(want_reply) {
static const unsigned char packet =
SSH_MSG_REQUEST_FAILURE;
libssh2_packet_add_jump_point5:
libssh2_packet_add_jump_point5:
session->packAdd_state = libssh2_NB_state_jump5;
rc = _libssh2_transport_send(session, &packet, 1, NULL, 0);
if(rc == LIBSSH2_ERROR_EAGAIN)
@@ -934,7 +934,7 @@ _libssh2_packet_add(LIBSSH2_SESSION * session, unsigned char *data,
session->packAdd_channelp = channelp;
/* Adjust the window based on the block we just freed */
libssh2_packet_add_jump_point1:
libssh2_packet_add_jump_point1:
session->packAdd_state = libssh2_NB_state_jump1;
rc = _libssh2_channel_receive_window_adjust(session->
packAdd_channelp,
@@ -1110,7 +1110,7 @@ _libssh2_packet_add(LIBSSH2_SESSION * session, unsigned char *data,
if(want_reply) {
unsigned char packet[5];
libssh2_packet_add_jump_point4:
libssh2_packet_add_jump_point4:
session->packAdd_state = libssh2_NB_state_jump4;
packet[0] = SSH_MSG_CHANNEL_FAILURE;
memcpy(&packet[1], data + 1, 4);
@@ -1173,7 +1173,7 @@ _libssh2_packet_add(LIBSSH2_SESSION * session, unsigned char *data,
memset(&session->packAdd_Qlstn_state, 0,
sizeof(session->packAdd_Qlstn_state));
libssh2_packet_add_jump_point2:
libssh2_packet_add_jump_point2:
session->packAdd_state = libssh2_NB_state_jump2;
rc = packet_queue_listener(session, data, datalen,
&session->packAdd_Qlstn_state);
@@ -1186,7 +1186,7 @@ _libssh2_packet_add(LIBSSH2_SESSION * session, unsigned char *data,
memset(&session->packAdd_x11open_state, 0,
sizeof(session->packAdd_x11open_state));
libssh2_packet_add_jump_point3:
libssh2_packet_add_jump_point3:
session->packAdd_state = libssh2_NB_state_jump3;
rc = packet_x11_open(session, data, datalen,
&session->packAdd_x11open_state);
@@ -1201,7 +1201,7 @@ _libssh2_packet_add(LIBSSH2_SESSION * session, unsigned char *data,
memset(&session->packAdd_authagent_state, 0,
sizeof(session->packAdd_authagent_state));
libssh2_packet_add_jump_authagent:
libssh2_packet_add_jump_authagent:
session->packAdd_state = libssh2_NB_state_jumpauthagent;
rc = packet_authagent_open(session, data, datalen,
&session->packAdd_authagent_state);

View File

@@ -293,7 +293,7 @@ _libssh2_pem_parse(LIBSSH2_SESSION * session,
}
ret = 0;
out:
out:
if(b64data) {
_libssh2_explicit_zero(b64data, b64datalen);
LIBSSH2_FREE(session, b64data);
@@ -362,7 +362,7 @@ _libssh2_pem_parse_memory(LIBSSH2_SESSION * session,
}
ret = 0;
out:
out:
if(b64data) {
_libssh2_explicit_zero(b64data, b64datalen);
LIBSSH2_FREE(session, b64data);

View File

@@ -287,7 +287,7 @@ publickey_response_success(LIBSSH2_PUBLICKEY * pkey)
data = NULL;
}
}
err_exit:
err_exit:
return -1;
}
@@ -539,7 +539,7 @@ static LIBSSH2_PUBLICKEY *publickey_init(LIBSSH2_SESSION *session)
}
/* Never reached except by direct goto */
err_exit:
err_exit:
session->pkeyInit_state = libssh2_NB_state_sent4;
if(session->pkeyInit_channel) {
rc = _libssh2_channel_close(session->pkeyInit_channel);
@@ -1201,7 +1201,7 @@ libssh2_publickey_list_fetch(LIBSSH2_PUBLICKEY * pkey, unsigned long *num_keys,
}
/* Only reached via explicit goto */
err_exit:
err_exit:
if(pkey->listFetch_data) {
LIBSSH2_FREE(session, pkey->listFetch_data);
pkey->listFetch_data = NULL;

View File

@@ -769,7 +769,7 @@ scp_recv(LIBSSH2_SESSION * session, const char *path, libssh2_struct_stat * sb)
session->scpRecv_state = libssh2_NB_state_idle;
return session->scpRecv_channel;
scp_recv_empty_channel:
scp_recv_empty_channel:
/* the code only jumps here as a result of a zero read from channel_read()
so we check EOF status to avoid getting stuck in a loop */
if(libssh2_channel_eof(session->scpRecv_channel))
@@ -778,7 +778,7 @@ scp_recv(LIBSSH2_SESSION * session, const char *path, libssh2_struct_stat * sb)
else
return session->scpRecv_channel;
/* fall-through */
scp_recv_error:
scp_recv_error:
tmp_err_code = session->err_code;
tmp_err_msg = session->err_msg;
while(libssh2_channel_free(session->scpRecv_channel) ==
@@ -1127,7 +1127,7 @@ scp_send(LIBSSH2_SESSION * session, const char *path, int mode,
session->scpSend_state = libssh2_NB_state_idle;
return session->scpSend_channel;
scp_send_empty_channel:
scp_send_empty_channel:
/* the code only jumps here as a result of a zero read from channel_read()
so we check EOF status to avoid getting stuck in a loop */
if(libssh2_channel_eof(session->scpSend_channel)) {
@@ -1137,7 +1137,7 @@ scp_send(LIBSSH2_SESSION * session, const char *path, int mode,
else
return session->scpSend_channel;
/* fall-through */
scp_send_error:
scp_send_error:
tmp_err_code = session->err_code;
tmp_err_msg = session->err_msg;
while(libssh2_channel_free(session->scpSend_channel) ==

View File

@@ -368,7 +368,7 @@ sftp_packet_read(LIBSSH2_SFTP *sftp)
sftp->partial_received = 5;
memcpy(packet, sftp->packet_header + 4, 5);
window_adjust:
window_adjust:
recv_window = libssh2_channel_window_read_ex(channel, NULL, NULL);
if(sftp->partial_len > recv_window) {
@@ -1018,7 +1018,7 @@ static LIBSSH2_SFTP *sftp_init(LIBSSH2_SESSION *session)
return sftp_handle;
sftp_init_error:
sftp_init_error:
session->sftpInit_state = libssh2_NB_state_error_closing;
return NULL;
}
@@ -1918,7 +1918,7 @@ static ssize_t sftp_readdir(LIBSSH2_SFTP_HANDLE *handle, char *buffer,
if((--handle->u.dir.names_left) == 0)
LIBSSH2_FREE(session, handle->u.dir.names_packet);
end:
end:
_libssh2_debug((session, LIBSSH2_TRACE_SFTP,
"libssh2_sftp_readdir_ex() return %d",
filename_len));

View File

@@ -725,7 +725,7 @@ int _libssh2_transport_read(LIBSSH2_SESSION * session)
if(!remainpack) {
/* we have a full packet */
libssh2_transport_read_point1:
libssh2_transport_read_point1:
rc = fullpacket(session, encrypted);
if(rc == LIBSSH2_ERROR_EAGAIN) {

View File

@@ -354,7 +354,7 @@ userauth_password(LIBSSH2_SESSION *session,
session->userauth_pswd_state = libssh2_NB_state_sent;
}
password_response:
password_response:
if((session->userauth_pswd_state == libssh2_NB_state_sent)
|| (session->userauth_pswd_state == libssh2_NB_state_sent1)
@@ -1448,7 +1448,7 @@ _libssh2_userauth_publickey(LIBSSH2_SESSION *session,
unsigned char *s;
int auth_attempts = 0;
retry_auth:
retry_auth:
auth_attempts++;
if(session->userauth_pblc_state == libssh2_NB_state_idle) {
@@ -2232,7 +2232,7 @@ userauth_keyboard_interactive(LIBSSH2_SESSION * session,
session->userauth_kybd_auth_failure = 0;
}
cleanup:
cleanup:
/*
* It's safe to clean all the data here, because unallocated pointers
* are filled by zeroes