From d2eb1f8145dee61c6bddfdcc5dac3591fa03f744 Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Mon, 3 Jul 2023 15:14:14 +0900 Subject: [PATCH] repart: fix free area calculation Like fdisk_get_last_lba(), fdisk_partition_get_end() return the last sector in the partition. Fixes #28225. --- src/partition/repart.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/partition/repart.c b/src/partition/repart.c index a65a1aa962..fc33a3eb62 100644 --- a/src/partition/repart.c +++ b/src/partition/repart.c @@ -1922,6 +1922,8 @@ static int determine_current_padding( return log_error_errno(SYNTHETIC_ERRNO(EIO), "Partition has no end!"); offset = fdisk_partition_get_end(p); + assert(offset < UINT64_MAX); + offset++; /* The end is one sector before the next partition or padding. */ assert(offset < UINT64_MAX / secsz); offset *= secsz;