SSH-01-003: Add cipher NULL checks to ssh_packet_get_current_crypto()
Fixes T183 Signed-off-by: Andreas Schneider <asn@cryptomilk.org> Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Этот коммит содержится в:
родитель
c8a621c606
Коммит
e60fc79542
28
src/packet.c
28
src/packet.c
@ -939,18 +939,38 @@ struct ssh_crypto_struct *
|
||||
ssh_packet_get_current_crypto(ssh_session session,
|
||||
enum ssh_crypto_direction_e direction)
|
||||
{
|
||||
struct ssh_crypto_struct *crypto = NULL;
|
||||
|
||||
if (session == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (session->current_crypto != NULL &&
|
||||
session->current_crypto->used & direction) {
|
||||
return session->current_crypto;
|
||||
crypto = session->current_crypto;
|
||||
} else if (session->next_crypto != NULL &&
|
||||
session->next_crypto->used & direction) {
|
||||
crypto = session->next_crypto;
|
||||
} else {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (session->next_crypto != NULL &&
|
||||
session->next_crypto->used & direction) {
|
||||
return session->next_crypto;
|
||||
switch (direction) {
|
||||
case SSH_DIRECTION_IN:
|
||||
if (crypto->in_cipher != NULL) {
|
||||
return crypto;
|
||||
}
|
||||
break;
|
||||
case SSH_DIRECTION_OUT:
|
||||
if (crypto->out_cipher != NULL) {
|
||||
return crypto;
|
||||
}
|
||||
break;
|
||||
case SSH_DIRECTION_BOTH:
|
||||
if (crypto->in_cipher != NULL &&
|
||||
crypto->out_cipher != NULL) {
|
||||
return crypto;
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user