cryptfs: Don't hardcode ascii buffer size

We're removing hardcoded buffer sizes in anticipation of allowing
different keysizes.  In this case, our buffer was sufficiently
large for all current cases.  But if we ever changed the
crypt_mnt_ftr struct to allow larger keys, this code will adjust
with the change.

Bug: 73079191
Test: Flashed an encrypted sailfish and it booted.
Change-Id: I261e729a77b351e287fbb55327564fe512a23d47
This commit is contained in:
Greg Kaiser 2018-02-09 16:11:38 -08:00
parent f45a70c416
commit 1452b27d4e

View file

@ -846,7 +846,10 @@ static int load_crypto_mapping_table(struct crypt_mnt_ftr *crypt_ftr,
struct dm_ioctl *io;
struct dm_target_spec *tgt;
char *crypt_params;
char master_key_ascii[129]; /* Large enough to hold 512 bit key and null */
// We can't assume the key is only KEY_LEN_BYTES. But we do know its limit
// due to the crypt_mnt_ftr struct. We need two ASCII characters to represent
// each byte, and need space for the '\0' terminator.
char master_key_ascii[sizeof(crypt_ftr->master_key) * 2 + 1];
size_t buff_offset;
int i;