Commit b0e25268 authored by Ondrej Kozina's avatar Ondrej Kozina Committed by Milan Broz

Allow higher keyslot numbers with LUKS2 format in reencryption.

parent 919e1c3f
......@@ -1182,6 +1182,7 @@ static int initialize_context(struct reenc_ctx *rc, const char *device)
rc->log_fd = -1;
/* FIXME: replace MAX_KEYSLOT with crypt_keyslot_max(CRYPT_LUKS2) */
if (crypt_keyslot_max(CRYPT_LUKS2) > MAX_SLOT) {
log_dbg("Internal error");
return -EINVAL;
......@@ -1198,6 +1199,12 @@ static int initialize_context(struct reenc_ctx *rc, const char *device)
return -EINVAL;
}
if (opt_key_slot != CRYPT_ANY_SLOT &&
opt_key_slot >= crypt_keyslot_max(rc->type)) {
log_err(_("Key slot is invalid.\n"));
return -EINVAL;
}
/* Prepare device names */
if (snprintf(rc->log_file, PATH_MAX,
"LUKS-%s.log", rc->device_uuid) < 0)
......@@ -1437,7 +1444,7 @@ int main(int argc, const char **argv)
poptGetInvocationName(popt_context));
if (opt_key_slot != CRYPT_ANY_SLOT &&
(opt_key_slot < 0 || opt_key_slot >= crypt_keyslot_max(CRYPT_LUKS1)))
(opt_key_slot < 0 || opt_key_slot >= crypt_keyslot_max(CRYPT_LUKS2)))
usage(popt_context, EXIT_FAILURE, _("Key slot is invalid."),
poptGetInvocationName(popt_context));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment