summaryrefslogtreecommitdiffstats
path: root/disk-utils
diff options
context:
space:
mode:
authorKarel Zak2019-01-10 12:17:19 +0100
committerKarel Zak2019-01-10 12:17:19 +0100
commite6effcac61152880451da25142cf93931834ffa9 (patch)
treebb0ee9aaaefeeb2a4d24b09be32d49d1915e71f8 /disk-utils
parentfdisk: support CTRL+C on change-partition-type dialog (diff)
downloadkernel-qcow2-util-linux-e6effcac61152880451da25142cf93931834ffa9.tar.gz
kernel-qcow2-util-linux-e6effcac61152880451da25142cf93931834ffa9.tar.xz
kernel-qcow2-util-linux-e6effcac61152880451da25142cf93931834ffa9.zip
fdisk: make partition types uses more robust
* report failed partition type parsing * make sure partition types code (from user reply) for MBR is hex Reported-by: Jonny Grant <jg@jguk.org> Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'disk-utils')
-rw-r--r--disk-utils/fdisk.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/disk-utils/fdisk.c b/disk-utils/fdisk.c
index 89fec2629..3e8ebf4a3 100644
--- a/disk-utils/fdisk.c
+++ b/disk-utils/fdisk.c
@@ -493,8 +493,13 @@ static struct fdisk_parttype *ask_partition_type(struct fdisk_context *cxt, int
if (buf[1] == '\0' && toupper(*buf) == 'L')
list_partition_types(cxt);
- else if (*buf)
- return fdisk_label_parse_parttype(lb, buf);
+ else if (*buf) {
+ struct fdisk_parttype *t = fdisk_label_parse_parttype(lb, buf);
+
+ if (!t)
+ fdisk_info(cxt, _("Failed to parse '%s' partition type."), buf);
+ return t;
+ }
} while (1);
return NULL;
@@ -621,7 +626,7 @@ void change_partition_type(struct fdisk_context *cxt)
break;
} while (!t);
- if (canceled == 0 && fdisk_set_partition_type(cxt, i, t) == 0)
+ if (canceled == 0 && t && fdisk_set_partition_type(cxt, i, t) == 0)
fdisk_info(cxt,
_("Changed type of partition '%s' to '%s'."),
old, t ? fdisk_parttype_get_name(t) : _("Unknown"));