fscrypt-crypt-util: fix maximum IV size
authorEric Biggers <ebiggers@google.com>
Sun, 15 Nov 2020 03:15:36 +0000 (19:15 -0800)
committerEryu Guan <guaneryu@gmail.com>
Sun, 15 Nov 2020 06:53:06 +0000 (14:53 +0800)
commit609bb3562241f9fc877aff7309d62af6cb10795d
treea622a617aec086c074afe9598cf79c0d06992dd9
parent0743230c36029be5f686e278cbd154ae263b44b6
fscrypt-crypt-util: fix maximum IV size

In commit 65cd8e8a8e81 ("fscrypt-crypt-util: fix IV incrementing for
--iv-ino-lblk-32") I mistakenly decreased the size of fscrypt_iv to 24
bytes, which is the most that is explicitly needed by any of the IV
generation methods.  However, Adiantum encryption takes a 32-byte IV, so
the buffer still needs to be 32 bytes, with any extra bytes zeroed.

So restore the size to 32 bytes.

This fixes a buffer overread that caused generic/550 and generic/584 to
sometimes fail, depending on the build of the fscrypt-crypt-util binary.
(Most of the time it still worked by chance.)

Fixes: 65cd8e8a8e81 ("fscrypt-crypt-util: fix IV incrementing for --iv-ino-lblk-32")
Signed-off-by: Eric Biggers <ebiggers@google.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
src/fscrypt-crypt-util.c