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.
edge.strict_endians^2
Jean-Pierre André 2021-07-19 09:23:23 +02:00
parent 61134117c1
commit 55e7326350
1 changed files with 11 additions and 0 deletions

View File

@ -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;