]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
homed: use crypt_token_max() where appropriate
authorLennart Poettering <lennart@poettering.net>
Fri, 8 Oct 2021 14:58:42 +0000 (16:58 +0200)
committerLennart Poettering <lennart@poettering.net>
Fri, 8 Oct 2021 21:50:04 +0000 (23:50 +0200)
Let's use the new crypt_token_max() API in systemd-homework too, to cut
iteration of tokens short.

We already use it in cryptenroll/cryptsetup, so let's use it here too.

src/home/homework-luks.c

index 8af9223d57ab680135b65383f24c6c5668599f89..b71621871665a09fc0cfd0bc3960cc0d945b2b98 100644 (file)
@@ -698,7 +698,7 @@ static int luks_validate_home_record(
         assert(cd);
         assert(h);
 
-        for (int token = 0;; token++) {
+        for (int token = 0; token < sym_crypt_token_max(CRYPT_LUKS2); token++) {
                 _cleanup_(json_variant_unrefp) JsonVariant *v = NULL, *rr = NULL;
                 _cleanup_(EVP_CIPHER_CTX_freep) EVP_CIPHER_CTX *context = NULL;
                 _cleanup_(user_record_unrefp) UserRecord *lhr = NULL;
@@ -894,7 +894,7 @@ int home_store_header_identity_luks(
 
         _cleanup_(user_record_unrefp) UserRecord *header_home = NULL;
         _cleanup_free_ char *text = NULL;
-        int token = 0, r;
+        int r;
 
         assert(h);
 
@@ -924,7 +924,7 @@ int home_store_header_identity_luks(
         if (r < 0)
                 return r;
 
-        for (;; token++) {
+        for (int token = 0; token < sym_crypt_token_max(CRYPT_LUKS2); token++) {
                 crypt_token_info state;
                 const char *type;