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
diff --git a/cryptfs.cpp b/cryptfs.cpp
index ebc4c4a..1d21124 100644
--- a/cryptfs.cpp
+++ b/cryptfs.cpp
@@ -846,7 +846,10 @@
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;