]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
repart: fix free area calculation
authorYu Watanabe <watanabe.yu+github@gmail.com>
Mon, 3 Jul 2023 06:14:14 +0000 (15:14 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Wed, 5 Jul 2023 01:40:56 +0000 (10:40 +0900)
Like fdisk_get_last_lba(), fdisk_partition_get_end() return the last
sector in the partition.

Fixes #28225.

src/partition/repart.c

index a65a1aa962aaafbed829eb43a935491ebb4c90a6..fc33a3eb625834dcc42b04390b2eddbb4d7381bb 100644 (file)
@@ -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;