From ba083200aa61b458746ef3ac899fa6abb74361d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Pierre=20Andr=C3=A9?= Date: Thu, 3 Jun 2010 10:06:08 +0200 Subject: [PATCH] Fixed close() after a fragmented truncate of a compressed file --- libntfs-3g/attrib.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/libntfs-3g/attrib.c b/libntfs-3g/attrib.c index 3f007820..3a78c0b9 100644 --- a/libntfs-3g/attrib.c +++ b/libntfs-3g/attrib.c @@ -2135,10 +2135,16 @@ int ntfs_attr_pclose(ntfs_attr *na) * length. */ compressed_part = 0; - if ((rl->lcn >= 0) && (rl[1].lcn == (LCN)LCN_HOLE)) - compressed_part - = na->compression_block_clusters - rl[1].length; - else + if (rl->lcn >= 0) { + runlist_element *xrl; + + xrl = rl; + do { + xrl++; + } while (xrl->lcn >= 0); + compressed_part = (-xrl->length) + & (na->compression_block_clusters - 1); + } else if (rl->lcn == (LCN)LCN_HOLE) { if (rl->length < na->compression_block_clusters) compressed_part