From d66aac1683b7a7f4d7ba6b8f1bd895131c8b357a Mon Sep 17 00:00:00 2001 From: Milan Broz Date: Sun, 13 Mar 2011 23:51:07 +0000 Subject: [PATCH] Do not ignore errors in crypto backend (LUKS AF). git-svn-id: https://cryptsetup.googlecode.com/svn/trunk@453 36d66b0a-2a48-0410-832c-cd162a569da5 --- lib/loopaes/loopaes.c | 2 +- lib/luks1/af.c | 17 ++++++++++++----- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/lib/loopaes/loopaes.c b/lib/loopaes/loopaes.c index 3f0f055..115814e 100644 --- a/lib/loopaes/loopaes.c +++ b/lib/loopaes/loopaes.c @@ -62,7 +62,7 @@ static int hash_key(const char *src, size_t src_len, r = crypt_hash_write(hd, src, src_len); if (!r) r = crypt_hash_final(hd, dst, dst_len); -out: + crypt_hash_destroy(hd); return r; } diff --git a/lib/luks1/af.c b/lib/luks1/af.c index 461a5a1..9b99604 100644 --- a/lib/luks1/af.c +++ b/lib/luks1/af.c @@ -42,15 +42,22 @@ static int hash_buf(const char *src, char *dst, uint32_t iv, { struct crypt_hash *hd = NULL; char *iv_char = (char *)&iv; + int r; iv = htonl(iv); if (crypt_hash_init(&hd, hash_name)) - return 1; - crypt_hash_write(hd, iv_char, sizeof(uint32_t)); - crypt_hash_write(hd, src, len); - crypt_hash_final(hd, dst, len); + return -EINVAL; + + if ((r = crypt_hash_write(hd, iv_char, sizeof(uint32_t)))) + goto out; + + if ((r = crypt_hash_write(hd, src, len))) + goto out; + + r = crypt_hash_final(hd, dst, len); +out: crypt_hash_destroy(hd); - return 0; + return r; } /* diffuse: Information spreading over the whole dataset with -- 2.7.4