diff options
| author | Thomas Weißschuh <thomas@t-8ch.de> | 2023-11-14 17:53:29 +0100 |
|---|---|---|
| committer | Thomas Weißschuh <thomas@t-8ch.de> | 2023-11-14 21:55:36 +0100 |
| commit | 78fd7300140c5e2f4e210aa1163468ef83b9c2fe (patch) | |
| tree | 08009dadd520e8b704692be208f7a99e5b10908e /disk-utils/cfdisk.c | |
| parent | 5ee1a36cdd02dd09aba9a3e40c52efdc04c60f14 (diff) | |
| download | util-linux-78fd7300140c5e2f4e210aa1163468ef83b9c2fe.tar.gz | |
cfdisk: properly handle out-of-order partitions during resize
Fixes #2580
Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
Diffstat (limited to 'disk-utils/cfdisk.c')
| -rw-r--r-- | disk-utils/cfdisk.c | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/disk-utils/cfdisk.c b/disk-utils/cfdisk.c index 9cf0346425..11b7faef75 100644 --- a/disk-utils/cfdisk.c +++ b/disk-utils/cfdisk.c @@ -2458,18 +2458,17 @@ static int main_menu_action(struct cfdisk *cf, int key) } case 'r': /* resize */ { - struct fdisk_partition *npa, *next; uint64_t size, max_size, secs; + struct fdisk_partition *npa; if (fdisk_partition_is_freespace(pa) || !fdisk_partition_has_start(pa)) return -EINVAL; - size = fdisk_partition_get_size(pa); - - /* is the next freespace? */ - next = fdisk_table_get_partition(cf->table, cf->lines_idx + 1); - if (next && fdisk_partition_is_freespace(next)) - size += fdisk_partition_get_size(next); + rc = fdisk_partition_get_max_size(cf->cxt, + fdisk_partition_get_partno(pa), + &size); + if (rc) + return rc; size *= fdisk_get_sector_size(cf->cxt); max_size = size; |
