1
0
mirror of https://git.libssh.org/projects/libssh.git synced 2025-12-06 13:20:57 +03:00

Add missing return value check

This issue was detected by covscan

Signed-off-by: Norbert Pocs <npocs@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
This commit is contained in:
Norbert Pocs
2023-05-02 16:46:29 +02:00
committed by Andreas Schneider
parent 4b5ccd4995
commit 9f8d46a45a
2 changed files with 37 additions and 16 deletions

View File

@@ -445,11 +445,18 @@ SSH_PACKET_CALLBACK(ssh_packet_userauth_gssapi_token_server){
hexa = ssh_get_hexa(output_token.value, output_token.length); hexa = ssh_get_hexa(output_token.value, output_token.length);
SSH_LOG(SSH_LOG_PACKET, "GSSAPI: sending token %s",hexa); SSH_LOG(SSH_LOG_PACKET, "GSSAPI: sending token %s",hexa);
SAFE_FREE(hexa); SAFE_FREE(hexa);
ssh_buffer_pack(session->out_buffer, rc = ssh_buffer_pack(session->out_buffer,
"bdP", "bdP",
SSH2_MSG_USERAUTH_GSSAPI_TOKEN, SSH2_MSG_USERAUTH_GSSAPI_TOKEN,
output_token.length, output_token.length,
(size_t)output_token.length, output_token.value); (size_t)output_token.length, output_token.value);
if (rc != SSH_OK) {
ssh_set_error_oom(session);
ssh_auth_reply_default(session, 0);
ssh_gssapi_free(session);
session->gssapi = NULL;
return SSH_PACKET_USED;
}
ssh_packet_send(session); ssh_packet_send(session);
} }
@@ -859,6 +866,7 @@ static gss_OID ssh_gssapi_oid_from_string(ssh_string oid_s)
} }
SSH_PACKET_CALLBACK(ssh_packet_userauth_gssapi_response){ SSH_PACKET_CALLBACK(ssh_packet_userauth_gssapi_response){
int rc;
ssh_string oid_s; ssh_string oid_s;
gss_uint32 maj_stat, min_stat; gss_uint32 maj_stat, min_stat;
gss_buffer_desc input_token = GSS_C_EMPTY_BUFFER; gss_buffer_desc input_token = GSS_C_EMPTY_BUFFER;
@@ -910,11 +918,15 @@ SSH_PACKET_CALLBACK(ssh_packet_userauth_gssapi_response){
hexa = ssh_get_hexa(output_token.value, output_token.length); hexa = ssh_get_hexa(output_token.value, output_token.length);
SSH_LOG(SSH_LOG_PACKET, "GSSAPI: sending token %s", hexa); SSH_LOG(SSH_LOG_PACKET, "GSSAPI: sending token %s", hexa);
SAFE_FREE(hexa); SAFE_FREE(hexa);
ssh_buffer_pack(session->out_buffer, rc = ssh_buffer_pack(session->out_buffer,
"bdP", "bdP",
SSH2_MSG_USERAUTH_GSSAPI_TOKEN, SSH2_MSG_USERAUTH_GSSAPI_TOKEN,
output_token.length, output_token.length,
(size_t)output_token.length, output_token.value); (size_t)output_token.length, output_token.value);
if (rc != SSH_OK) {
ssh_set_error_oom(session);
goto error;
}
ssh_packet_send(session); ssh_packet_send(session);
session->auth.state = SSH_AUTH_STATE_GSSAPI_TOKEN; session->auth.state = SSH_AUTH_STATE_GSSAPI_TOKEN;
} }
@@ -977,6 +989,7 @@ static int ssh_gssapi_send_mic(ssh_session session)
} }
SSH_PACKET_CALLBACK(ssh_packet_userauth_gssapi_token_client){ SSH_PACKET_CALLBACK(ssh_packet_userauth_gssapi_token_client){
int rc;
ssh_string token; ssh_string token;
char *hexa; char *hexa;
OM_uint32 maj_stat, min_stat; OM_uint32 maj_stat, min_stat;
@@ -1029,11 +1042,15 @@ SSH_PACKET_CALLBACK(ssh_packet_userauth_gssapi_token_client){
hexa = ssh_get_hexa(output_token.value, output_token.length); hexa = ssh_get_hexa(output_token.value, output_token.length);
SSH_LOG(SSH_LOG_PACKET, "GSSAPI: sending token %s",hexa); SSH_LOG(SSH_LOG_PACKET, "GSSAPI: sending token %s",hexa);
SAFE_FREE(hexa); SAFE_FREE(hexa);
ssh_buffer_pack(session->out_buffer, rc = ssh_buffer_pack(session->out_buffer,
"bdP", "bdP",
SSH2_MSG_USERAUTH_GSSAPI_TOKEN, SSH2_MSG_USERAUTH_GSSAPI_TOKEN,
output_token.length, output_token.length,
(size_t)output_token.length, output_token.value); (size_t)output_token.length, output_token.value);
if (rc != SSH_OK) {
ssh_set_error_oom(session);
goto error;
}
ssh_packet_send(session); ssh_packet_send(session);
} }

View File

@@ -630,7 +630,11 @@ ssh_string ssh_pki_openssh_privkey_export(const ssh_key privkey,
goto error; goto error;
} }
ssh_buffer_pack(kdf_buf, "Sd", salt, rounds); rc = ssh_buffer_pack(kdf_buf, "Sd", salt, rounds);
if (rc != SSH_OK) {
SSH_BUFFER_FREE(kdf_buf);
goto error;
}
kdf_options = ssh_string_new(ssh_buffer_get_len(kdf_buf)); kdf_options = ssh_string_new(ssh_buffer_get_len(kdf_buf));
if (kdf_options == NULL){ if (kdf_options == NULL){
SSH_BUFFER_FREE(kdf_buf); SSH_BUFFER_FREE(kdf_buf);