aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Maydell <peter.maydell@linaro.org>2017-02-27 15:33:21 +0000
committerPeter Maydell <peter.maydell@linaro.org>2017-02-27 15:33:21 +0000
commit8f2d7c341184a95d05476ea3c45dbae2b9ddbe51 (patch)
tree67fd2ff194962236b766e7d4d942f47213f5903d
parent3b1d8169844fafee184366b0e0d7080534758b4d (diff)
parent32c813e6c2a857b93b897901b7e20281397528a3 (diff)
Merge remote-tracking branch 'remotes/berrange/tags/pull-qcrypto-2017-02-27-1' into staging
Merge qcrypto 2017/02/27 v1 # gpg: Signature made Mon 27 Feb 2017 13:37:34 GMT # gpg: using RSA key 0xBE86EBB415104FDF # gpg: Good signature from "Daniel P. Berrange <dan@berrange.com>" # gpg: aka "Daniel P. Berrange <berrange@redhat.com>" # Primary key fingerprint: DAF3 A6FD B26B 6291 2D0E 8E3F BE86 EBB4 1510 4FDF * remotes/berrange/tags/pull-qcrypto-2017-02-27-1: crypto: assert cipher algorithm is always valid crypto: fix leak in ivgen essiv init Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
-rw-r--r--crypto/cipher.c8
-rw-r--r--crypto/ivgen-essiv.c1
2 files changed, 3 insertions, 6 deletions
diff --git a/crypto/cipher.c b/crypto/cipher.c
index 9ecaff702b..5a9648942f 100644
--- a/crypto/cipher.c
+++ b/crypto/cipher.c
@@ -63,18 +63,14 @@ static bool mode_need_iv[QCRYPTO_CIPHER_MODE__MAX] = {
size_t qcrypto_cipher_get_block_len(QCryptoCipherAlgorithm alg)
{
- if (alg >= G_N_ELEMENTS(alg_key_len)) {
- return 0;
- }
+ assert(alg < G_N_ELEMENTS(alg_key_len));
return alg_block_len[alg];
}
size_t qcrypto_cipher_get_key_len(QCryptoCipherAlgorithm alg)
{
- if (alg >= G_N_ELEMENTS(alg_key_len)) {
- return 0;
- }
+ assert(alg < G_N_ELEMENTS(alg_key_len));
return alg_key_len[alg];
}
diff --git a/crypto/ivgen-essiv.c b/crypto/ivgen-essiv.c
index 634de63338..cba20bde6c 100644
--- a/crypto/ivgen-essiv.c
+++ b/crypto/ivgen-essiv.c
@@ -48,6 +48,7 @@ static int qcrypto_ivgen_essiv_init(QCryptoIVGen *ivgen,
&salt, &nhash,
errp) < 0) {
g_free(essiv);
+ g_free(salt);
return -1;
}