From 921f70d3bbfd32c31a2a512c4e93423255df4c75 Mon Sep 17 00:00:00 2001 From: Arnaud Ferraris Date: Tue, 8 Jan 2019 14:05:38 +0100 Subject: [PATCH] [partition] Fix size and last sector computation Due to a computation error when calculating the total drive space and each partition's last sector, the last partition's last sector was out of boundaries, leading to an error creating this partition. This patch fixes the computation algorithm to get rid of this error. Signed-off-by: Arnaud Ferraris --- src/modules/partition/core/PartitionLayout.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/modules/partition/core/PartitionLayout.cpp b/src/modules/partition/core/PartitionLayout.cpp index 866a9d920..77ef4bb81 100644 --- a/src/modules/partition/core/PartitionLayout.cpp +++ b/src/modules/partition/core/PartitionLayout.cpp @@ -159,7 +159,7 @@ PartitionLayout::execute( Device *dev, qint64 firstSector, { QList< Partition* > partList; qint64 size, minSize, end; - qint64 totalSize = lastSector - firstSector; + qint64 totalSize = lastSector - firstSector + 1; qint64 availableSize = totalSize; // TODO: Refine partition sizes to make sure there is room for every partition @@ -176,7 +176,7 @@ PartitionLayout::execute( Device *dev, qint64 firstSector, size = minSize; if ( size > availableSize ) size = availableSize; - end = firstSector + size; + end = firstSector + size - 1; if ( luksPassphrase.isEmpty() ) {