mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-05 08:43:55 -06:00
crypto: afalg: fix a NULL pointer dereference
Test-crypto-hash calls qcrypto_hash_bytesv/digest/base64 with errp=NULL, this will cause a NULL pointer dereference if afalg_driver doesn't support requested algos: ret = qcrypto_hash_afalg_driver.hash_bytesv(alg, iov, niov, result, resultlen, errp); if (ret == 0) { return ret; } error_free(*errp); // <--- here Because the error message is thrown away immediately, we should just pass NULL to hash_bytesv(). There is also the same problem in afalg-backend cipher & hmac, let's fix them together. Reviewed-by: Eric Blake <eblake@redhat.com> Reported-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Longpeng <longpeng2@huawei.com> Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
This commit is contained in:
parent
b417a7624c
commit
f1710638ed
3 changed files with 8 additions and 16 deletions
|
@ -90,11 +90,10 @@ QCryptoHmac *qcrypto_hmac_new(QCryptoHashAlgorithm alg,
|
|||
{
|
||||
QCryptoHmac *hmac;
|
||||
void *ctx = NULL;
|
||||
Error *err2 = NULL;
|
||||
QCryptoHmacDriver *drv = NULL;
|
||||
|
||||
#ifdef CONFIG_AF_ALG
|
||||
ctx = qcrypto_afalg_hmac_ctx_new(alg, key, nkey, &err2);
|
||||
ctx = qcrypto_afalg_hmac_ctx_new(alg, key, nkey, NULL);
|
||||
if (ctx) {
|
||||
drv = &qcrypto_hmac_afalg_driver;
|
||||
}
|
||||
|
@ -107,7 +106,6 @@ QCryptoHmac *qcrypto_hmac_new(QCryptoHashAlgorithm alg,
|
|||
}
|
||||
|
||||
drv = &qcrypto_hmac_lib_driver;
|
||||
error_free(err2);
|
||||
}
|
||||
|
||||
hmac = g_new0(QCryptoHmac, 1);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue