]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
cryptsetup: check the existence of salt by salt_size > 0
authorYu Watanabe <watanabe.yu+github@gmail.com>
Thu, 16 Feb 2023 23:24:54 +0000 (08:24 +0900)
committerLennart Poettering <lennart@poettering.net>
Fri, 17 Feb 2023 08:46:25 +0000 (09:46 +0100)
Follow-up for 504d0acf61c8472bc93c2a927e858074873b2eaf.

The function may be called with non-NULL salt and salt_size == 0.

src/cryptsetup/cryptsetup-tokens/luks2-tpm2.c

index c4377230cad732c950c94d83f36cdb60eb11e240..307488726935ac28b6f5c9ae64c079675e6cb330 100644 (file)
@@ -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) {