summaryrefslogtreecommitdiff
path: root/ubifs-utils/mkfs.ubifs/crypto.c
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2019-11-10 13:37:20 +0100
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2019-11-10 15:29:59 +0100
commit64255d88391b8a531f0d358e22bdf12c0c79cd5d (patch)
tree9a72b802fbbdb1498ba047be108f0d9edc9ea6c2 /ubifs-utils/mkfs.ubifs/crypto.c
parent19333aa3648663893d190d9ce8c7e45724c1a3bd (diff)
mkfs.ubifs: don't leak temporary buffers
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'ubifs-utils/mkfs.ubifs/crypto.c')
-rw-r--r--ubifs-utils/mkfs.ubifs/crypto.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/ubifs-utils/mkfs.ubifs/crypto.c b/ubifs-utils/mkfs.ubifs/crypto.c
index d31bd2a..19c445e 100644
--- a/ubifs-utils/mkfs.ubifs/crypto.c
+++ b/ubifs-utils/mkfs.ubifs/crypto.c
@@ -118,23 +118,26 @@ static ssize_t gen_essiv_salt(const void *iv, size_t iv_len, const void *key, si
cipher = EVP_aes_256_ecb();
if (!cipher) {
errmsg("OpenSSL: Cipher AES-256-ECB is not supported");
- return -1;
+ goto fail;
}
if (do_hash(EVP_sha256(), key, key_len, sha256) != 0) {
errmsg("sha256 failed");
- return -1;
+ goto fail;
}
ret = do_encrypt(cipher, iv, iv_len, sha256, EVP_MD_size(EVP_sha256()), NULL, 0, salt);
if (ret != iv_len) {
errmsg("Unable to compute ESSIV salt, return value %zi instead of %zi", ret, iv_len);
- return -1;
+ goto fail;
}
free(sha256);
return ret;
+fail:
+ free(sha256);
+ return -1;
}
static ssize_t encrypt_block(const void *plaintext, size_t size,