Fix off by one sector error in GParted internal block copy (#742920)

GParted's internal block copy has an off by one sector bug when the
source is before the destination; and the copy is performed backwards
from high block to low block.  It is as though the source and
destination partitions were both one sector earlier on the disk.

In ASCII art it it looks like this:

Initial layout:      x<--SRC--><--DST-->
Actually wrote:               x<--SRC--
Should have written:           <--SRC-->

Affects moving partitions too.

This bug has existed since commit:

    bd9e16f22f
    Thread the internal copy algorithm (#685740)

Effectively the last sector of the partition is missed and one sector
before the start of the partition is corrupted.  Most of the time file
systems don't get around to using the very last sector so didn't notice.

Bug 742920 - GParted internal copy is overstepping partition boundaries
This commit is contained in:
Phillip Susi 2015-01-14 16:47:10 +00:00 committed by Mike Fleetwood
parent c97a462e7c
commit 8a952cd4a9
1 changed files with 2 additions and 2 deletions

View File

@ -105,9 +105,9 @@ void copy_blocks::copy_thread()
{
blocksize -= 2*blocksize;
done -= 2*done;
offset_src += ( (length / src_sector_size) - 1 );
offset_src += length / src_sector_size;
/* Handle situation where src sector size is smaller than dst sector size and an additional partial dst sector is required. */
offset_dst += ( ((length + (dst_sector_size - 1)) / dst_sector_size) - 1 );
offset_dst += (length + (dst_sector_size - 1)) / dst_sector_size;
}
success = true;
} else success = false;