From a6ec7d343b08328caf5681d7d0d0fc3ef3e253ef Mon Sep 17 00:00:00 2001 From: szaka Date: Mon, 5 May 2008 15:36:58 +0000 Subject: [PATCH] fix: multi-block allocation could allocate or free used blocks in certain rare circumstances. Because FUSE write(2) size was restricted to 4 KB until recently and the most widely used NTFS block size is also 4 KB thus allocations were typically single block size therefore the bug wasn't visible and couldn't be easily reproduced. However MFT allocations are multi-block size and they could lead to data corruption typically in close to full disk utilization. --- libntfs-3g/lcnalloc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libntfs-3g/lcnalloc.c b/libntfs-3g/lcnalloc.c index 81d80cd5..88fb4730 100644 --- a/libntfs-3g/lcnalloc.c +++ b/libntfs-3g/lcnalloc.c @@ -278,7 +278,7 @@ runlist *ntfs_cluster_alloc(ntfs_volume *vol, VCN start_vcn, s64 count, bmp_pos &= ~7; writeback = 0; - while (1) { + while (lcn < buf_size) { byte = buf + (lcn >> 3); bit = 1 << (lcn & 7); if (has_guess) {