From 55e7326350dd0002ee3058caa49399e2df0ce2ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Pierre=20Andr=C3=A9?= Date: Mon, 19 Jul 2021 09:23:23 +0200 Subject: [PATCH] Avoided endless recursions when allocating the main bitmap Allocating clusters to the main bitmap may imply updating the bitmap itself within a cluster not yet allocated. This can turn into endless recursions and has to be rejected. Currently the bitmap is assumed to be fully allocated. --- libntfs-3g/attrib.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/libntfs-3g/attrib.c b/libntfs-3g/attrib.c index 3cb696e1..1c748544 100644 --- a/libntfs-3g/attrib.c +++ b/libntfs-3g/attrib.c @@ -1256,6 +1256,17 @@ static int ntfs_attr_fill_hole(ntfs_attr *na, s64 count, s64 *ofs, LCN lcn_seek_from = -1; VCN cur_vcn, from_vcn; + if (na->ni->mft_no == FILE_Bitmap) { + /* + * Filling a hole in the main bitmap implies allocating + * clusters, which is likely to imply updating the + * bitmap in a cluster being allocated. + * Not supported now, could lead to endless recursions. + */ + ntfs_log_error("Corrupt $BitMap not fully allocated\n"); + errno = EIO; + goto err_out; + } to_write = min(count, ((*rl)->length << vol->cluster_size_bits) - *ofs); cur_vcn = (*rl)->vcn;