From af1bc0f5ec6db13e8d3fb289bc539e9f08e20e69 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Pierre=20Andr=C3=A9?= Date: Mon, 12 Jul 2021 08:31:18 +0200 Subject: [PATCH] Hardened the check of locations of MFT and MFTMirr The MFT and MFTMirr may not be negative or overlap the boot sector. --- libntfs-3g/bootsect.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libntfs-3g/bootsect.c b/libntfs-3g/bootsect.c index 483473e6..279247d9 100644 --- a/libntfs-3g/bootsect.c +++ b/libntfs-3g/bootsect.c @@ -155,7 +155,9 @@ 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)) { + if (((s64)sle64_to_cpu(b->mft_lcn) <= 0) + || ((s64)sle64_to_cpu(b->mftmirr_lcn) <= 0) + || (b->mft_lcn == b->mftmirr_lcn)) { ntfs_log_error("Invalid location of MFT or MFTMirr.\n"); goto not_ntfs; }