From 894b7dd36e56ce7b52cfef9a105ef3eed07dc307 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Pierre=20Andr=C3=A9?= Date: Tue, 26 Jan 2021 10:06:18 +0100 Subject: [PATCH] Checked the locations of MFT and MFTMirr at startup On startup make sure the lcns of the MFT and the MFTMirr are not null and they are different, so that the mounting is denied gracefully if they are. --- libntfs-3g/bootsect.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/libntfs-3g/bootsect.c b/libntfs-3g/bootsect.c index e9eb0b15..483473e6 100644 --- a/libntfs-3g/bootsect.c +++ b/libntfs-3g/bootsect.c @@ -154,6 +154,12 @@ BOOL ntfs_boot_sector_is_ntfs(NTFS_BOOT_SECTOR *b) } } + /* MFT and MFTMirr may not overlap the boot sector or be the same */ + if (!b->mft_lcn || !b->mftmirr_lcn || (b->mft_lcn == b->mftmirr_lcn)) { + ntfs_log_error("Invalid location of MFT or MFTMirr.\n"); + goto not_ntfs; + } + if (b->end_of_sector_marker != const_cpu_to_le16(0xaa55)) ntfs_log_debug("Warning: Bootsector has invalid end of sector " "marker.\n");