Skip to content

Commit

Permalink
repart: fix free area calculation
Browse files Browse the repository at this point in the history
Like fdisk_get_last_lba(), fdisk_partition_get_end() return the last
sector in the partition.

Fixes #28225.
  • Loading branch information
yuwata committed Jul 5, 2023
1 parent beba8f2 commit d2eb1f8
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/partition/repart.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down

0 comments on commit d2eb1f8

Please sign in to comment.