diff options
author | David Oberhollenzer <david.oberhollenzer@sigma-star.at> | 2019-11-10 13:37:20 +0100 |
---|---|---|
committer | David Oberhollenzer <david.oberhollenzer@sigma-star.at> | 2019-11-10 15:29:59 +0100 |
commit | 64255d88391b8a531f0d358e22bdf12c0c79cd5d (patch) | |
tree | 9a72b802fbbdb1498ba047be108f0d9edc9ea6c2 /ubifs-utils/mkfs.ubifs/fscrypt.c | |
parent | 19333aa3648663893d190d9ce8c7e45724c1a3bd (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/fscrypt.c')
-rw-r--r-- | ubifs-utils/mkfs.ubifs/fscrypt.c | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/ubifs-utils/mkfs.ubifs/fscrypt.c b/ubifs-utils/mkfs.ubifs/fscrypt.c index 118c11c..b75bdf7 100644 --- a/ubifs-utils/mkfs.ubifs/fscrypt.c +++ b/ubifs-utils/mkfs.ubifs/fscrypt.c @@ -106,13 +106,19 @@ int encrypt_path(void **outbuf, void *data, unsigned int data_len, memcpy(inbuf, data, data_len); crypt_key = calc_fscrypt_subkey(fctx); - if (!crypt_key) + if (!crypt_key) { + free(inbuf); + free(*outbuf); return err_msg("could not compute subkey"); + } ret = fscrypt_cipher->encrypt_fname(inbuf, cryptlen, crypt_key, *outbuf); - if (ret < 0) + if (ret < 0) { + free(inbuf); + free(*outbuf); return err_msg("could not encrypt filename"); + } free(crypt_key); free(inbuf); @@ -133,13 +139,19 @@ int encrypt_data_node(struct fscrypt_context *fctx, unsigned int block_no, memcpy(inbuf, &dn->data, length); crypt_key = calc_fscrypt_subkey(fctx); - if (!crypt_key) + if (!crypt_key) { + free(inbuf); + free(outbuf); return err_msg("could not compute subkey"); + } ret = fscrypt_cipher->encrypt_block(inbuf, pad_len, crypt_key, block_no, outbuf); if (ret != pad_len) { + free(inbuf); + free(outbuf); + free(crypt_key); return err_msg("encrypt_block returned %zi " "instead of %zi", ret, pad_len); } |