From 32e858a87a4184a05a1b54315c06ac94488770b1 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] Aborted mounting when cannot access standard information of MFT The standard information of the MFT must be its first attribute in the base record. If it is not accessible initially, we end up searching it in an extent before the MFT struct is ready for that. --- libntfs-3g/volume.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/libntfs-3g/volume.c b/libntfs-3g/volume.c index a6551c78..92743735 100644 --- a/libntfs-3g/volume.c +++ b/libntfs-3g/volume.c @@ -221,10 +221,11 @@ static int __ntfs_volume_release(ntfs_volume *v) return errno ? -1 : 0; } -static void ntfs_attr_setup_flag(ntfs_inode *ni) +static int ntfs_attr_setup_flag(ntfs_inode *ni) { STANDARD_INFORMATION *si; s64 lth; + int r; si = (STANDARD_INFORMATION*)ntfs_attr_readall(ni, AT_STANDARD_INFORMATION, AT_UNNAMED, 0, <h); @@ -232,7 +233,12 @@ static void ntfs_attr_setup_flag(ntfs_inode *ni) if ((u64)lth >= offsetof(STANDARD_INFORMATION, owner_id)) ni->flags = si->file_attributes; free(si); + r = 0; + } else { + ntfs_log_error("Failed to get standard information of $MFT\n"); + r = -1; } + return (r); } /** @@ -317,7 +323,8 @@ static int ntfs_mft_load(ntfs_volume *vol) mft_has_no_attr_list: - ntfs_attr_setup_flag(vol->mft_ni); + if (ntfs_attr_setup_flag(vol->mft_ni)) + goto error_exit; /* We now have a fully setup ntfs inode for $MFT in vol->mft_ni. */