From: Yu Watanabe Date: Thu, 16 Feb 2023 23:24:54 +0000 (+0900) Subject: cryptsetup: check the existence of salt by salt_size > 0 X-Git-Tag: v254-rc1~1256 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=8c2264abb9c16bc2933f95be299f15ee66c21181;p=thirdparty%2Fsystemd.git cryptsetup: check the existence of salt by salt_size > 0 Follow-up for 504d0acf61c8472bc93c2a927e858074873b2eaf. The function may be called with non-NULL salt and salt_size == 0. --- diff --git a/src/cryptsetup/cryptsetup-tokens/luks2-tpm2.c b/src/cryptsetup/cryptsetup-tokens/luks2-tpm2.c index c4377230cad..30748872693 100644 --- a/src/cryptsetup/cryptsetup-tokens/luks2-tpm2.c +++ b/src/cryptsetup/cryptsetup-tokens/luks2-tpm2.c @@ -56,7 +56,7 @@ int acquire_luks2_key( return -ENOANO; /* If we're using a PIN, and the luks header has a salt, it better have a pin too */ - if ((flags & TPM2_FLAGS_USE_PIN) && salt && !pin) + if ((flags & TPM2_FLAGS_USE_PIN) && salt_size > 0 && !pin) return -ENOANO; if (pin && salt_size > 0) {