mirror of
https://gitlab.com/cryptsetup/cryptsetup.git
synced 2025-12-06 00:10:04 +01:00
bitlk: Show better error when trying to open an NTFS device
Both BitLocker version 1 and NTFS have the same bootcode eb 52 90 so when trying to open an NTFS device user will get error message saying that BitLocker version 1 is not supported. This patch switches to check the superblock first to inform user that the device is not a BITLK device.
This commit is contained in:
@@ -501,18 +501,6 @@ int BITLK_read_sb(struct crypt_device *cd, struct bitlk_metadata *params)
|
|||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (memcmp(sig.boot_code, BITLK_BOOTCODE_V1, sizeof(sig.boot_code)) == 0) {
|
|
||||||
log_err(cd, _("BITLK version 1 is currently not supported."));
|
|
||||||
r = -ENOTSUP;
|
|
||||||
goto out;
|
|
||||||
} else if (memcmp(sig.boot_code, BITLK_BOOTCODE_V2, sizeof(sig.boot_code)) == 0)
|
|
||||||
;
|
|
||||||
else {
|
|
||||||
log_err(cd, _("Invalid or unknown boot signature for BITLK device."));
|
|
||||||
r = -EINVAL;
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (memcmp(sig.signature, BITLK_SIGNATURE, sizeof(sig.signature)) == 0) {
|
if (memcmp(sig.signature, BITLK_SIGNATURE, sizeof(sig.signature)) == 0) {
|
||||||
params->togo = false;
|
params->togo = false;
|
||||||
fve_offset = BITLK_HEADER_METADATA_OFFSET;
|
fve_offset = BITLK_HEADER_METADATA_OFFSET;
|
||||||
@@ -525,6 +513,18 @@ int BITLK_read_sb(struct crypt_device *cd, struct bitlk_metadata *params)
|
|||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (memcmp(sig.boot_code, BITLK_BOOTCODE_V1, sizeof(sig.boot_code)) == 0) {
|
||||||
|
log_err(cd, _("BITLK version 1 is currently not supported."));
|
||||||
|
r = -ENOTSUP;
|
||||||
|
goto out;
|
||||||
|
} else if (memcmp(sig.boot_code, BITLK_BOOTCODE_V2, sizeof(sig.boot_code)) == 0)
|
||||||
|
;
|
||||||
|
else {
|
||||||
|
log_err(cd, _("Invalid or unknown boot signature for BITLK device."));
|
||||||
|
r = -EINVAL;
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
params->sector_size = le16_to_cpu(sig.sector_size);
|
params->sector_size = le16_to_cpu(sig.sector_size);
|
||||||
if (params->sector_size == 0) {
|
if (params->sector_size == 0) {
|
||||||
log_dbg(cd, "Got sector size 0, assuming 512.");
|
log_dbg(cd, "Got sector size 0, assuming 512.");
|
||||||
|
|||||||
Reference in New Issue
Block a user