1
0
mirror of https://git.libssh.org/projects/libssh.git synced 2025-12-12 15:41:16 +03:00

libgcrypt: Do not leak memory with invalid key lengths

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
This commit is contained in:
Jakub Jelen
2019-12-16 17:09:54 +01:00
committed by Andreas Schneider
parent dd54ffb2f1
commit 7e692ee1b6

View File

@@ -359,6 +359,10 @@ static int aes_set_key(struct ssh_cipher_struct *cipher, void *key, void *IV) {
return -1; return -1;
} }
break; break;
default:
SSH_LOG(SSH_LOG_WARNING, "Unksupported key length %u.", cipher->keysize);
SAFE_FREE(cipher->key);
return -1;
} }
if (gcry_cipher_setkey(cipher->key[0], key, cipher->keysize / 8)) { if (gcry_cipher_setkey(cipher->key[0], key, cipher->keysize / 8)) {
gcry_cipher_close(cipher->key[0]); gcry_cipher_close(cipher->key[0]);