mirror of
https://gitlab.com/cryptsetup/cryptsetup.git
synced 2025-12-16 13:20:11 +01:00
Check for bad device-mapper name early
There is no need to unlock keyslot if the provided name has wrong format. Let's check for length and '/' in name early. Note that other commands could accept path to the device as libdevmapper translate it to the name (status /dev/mapper/xxx). Add early check only to activate commands. It still can fail later because of mangled characters. Fixes: #893
This commit is contained in:
@@ -323,6 +323,9 @@ static int action_open_plain(void)
|
||||
pmode = cipher_mode;
|
||||
}
|
||||
|
||||
if ((r = tools_check_newname(activated_name)))
|
||||
goto out;
|
||||
|
||||
if (ARG_SET(OPT_DEVICE_SIZE_ID))
|
||||
params.size = ARG_UINT64(OPT_DEVICE_SIZE_ID) / SECTOR_SIZE;
|
||||
else if (ARG_SET(OPT_SIZE_ID))
|
||||
@@ -407,6 +410,9 @@ static int action_open_loopaes(void)
|
||||
goto out;
|
||||
}
|
||||
|
||||
if ((r = tools_check_newname(activated_name)))
|
||||
goto out;
|
||||
|
||||
set_activation_flags(&activate_flags);
|
||||
|
||||
r = crypt_activate_by_keyfile_device_offset(cd, activated_name, CRYPT_ANY_SLOT,
|
||||
@@ -511,6 +517,8 @@ static int action_open_tcrypt(void)
|
||||
int r;
|
||||
|
||||
activated_name = ARG_SET(OPT_TEST_PASSPHRASE_ID) ? NULL : action_argv[1];
|
||||
if ((r = tools_check_newname(activated_name)))
|
||||
goto out;
|
||||
|
||||
r = crypt_init_data_device(&cd, ARG_STR(OPT_HEADER_ID) ?: action_argv[0], action_argv[0]);
|
||||
if (r < 0)
|
||||
@@ -542,6 +550,8 @@ static int action_open_bitlk(void)
|
||||
size_t passwordLen;
|
||||
|
||||
activated_name = ARG_SET(OPT_TEST_PASSPHRASE_ID) ? NULL : action_argv[1];
|
||||
if ((r = tools_check_newname(activated_name)))
|
||||
goto out;
|
||||
|
||||
if ((r = crypt_init(&cd, action_argv[0])))
|
||||
goto out;
|
||||
@@ -825,6 +835,8 @@ static int action_open_fvault2(void)
|
||||
size_t passwordLen;
|
||||
|
||||
activated_name = ARG_SET(OPT_TEST_PASSPHRASE_ID) ? NULL : action_argv[1];
|
||||
if ((r = tools_check_newname(activated_name)))
|
||||
goto out;
|
||||
|
||||
if ((r = crypt_init(&cd, action_argv[0])))
|
||||
goto out;
|
||||
@@ -1950,6 +1962,9 @@ static int action_open_luks(void)
|
||||
}
|
||||
}
|
||||
|
||||
if ((r = tools_check_newname(activated_name)))
|
||||
goto out;
|
||||
|
||||
set_activation_flags(&activate_flags);
|
||||
|
||||
if (ARG_SET(OPT_EXTERNAL_TOKENS_PATH_ID)) {
|
||||
|
||||
Reference in New Issue
Block a user