From 5be0b9f62a7eabddbac3119a12b98cc1b4c233d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Pierre=20Andr=C3=A9?= Date: Thu, 25 May 2017 10:52:54 +0200 Subject: [PATCH] Fixed the computation of highest_vcn when applying a runlist fixup When a file is partially truncated, the highest_vcn has to be recomputed before the file size is adjusted. As a consequence the unmapped run inserted at the end of runlist to match the file size should not be taken into account when determining the higest_vcn. --- ntfsprogs/playlog.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ntfsprogs/playlog.c b/ntfsprogs/playlog.c index 07b03c46..14d24564 100644 --- a/ntfsprogs/playlog.c +++ b/ntfsprogs/playlog.c @@ -806,7 +806,9 @@ static int adjust_high_vcn(ntfs_volume *vol, ATTR_RECORD *attr) rl = ntfs_mapping_pairs_decompress(vol, attr, (runlist_element*)NULL); if (rl) { xrl = rl; - while (xrl->length) + if (xrl->length) + xrl++; + while ((xrl->length) && (xrl->lcn != LCN_RL_NOT_MAPPED)) xrl++; high_vcn = xrl->vcn - 1; attr->highest_vcn = cpu_to_sle64(high_vcn);