diff options
author | Phillip Susi <psusi@ubuntu.com> | 2018-05-10 12:31:36 -0400 |
---|---|---|
committer | Phillip Susi <psusi@ubuntu.com> | 2018-06-05 10:34:37 -0400 |
commit | 9e196cc2902255c328a90584e44666b79e4344c3 (patch) | |
tree | 10cfbb03560196d5187edc720c3b5200823f8cb7 /parted/ui.c | |
parent | ddb9cce8a2ec87cdd9853bdca25c852c7aee8bdf (diff) | |
download | parted-9e196cc2902255c328a90584e44666b79e4344c3.tar.gz |
Fix set and disk_set to not crash when no flags are supported
Loop labels and file images support no flags. set and disk_set
would prompt for a flag and accept any string since the list of
flags was empty, then fail to look up an actual flag value, then
throw an exception with a null string for the name of the flag,
which would bug.
Diffstat (limited to 'parted/ui.c')
-rw-r--r-- | parted/ui.c | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/parted/ui.c b/parted/ui.c index 752860b..4f42b7c 100644 --- a/parted/ui.c +++ b/parted/ui.c @@ -1150,7 +1150,14 @@ command_line_get_disk_flag (const char* prompt, const PedDisk* disk, opts = str_list_append_unique (opts, _(walk_name)); } } - + if (opts == NULL) + { + ped_exception_throw (PED_EXCEPTION_ERROR, + PED_EXCEPTION_OK, + _("No flags supported")); + + return 0; + } flag_name = command_line_get_word (prompt, NULL, opts, 1); str_list_destroy (opts); @@ -1179,7 +1186,14 @@ command_line_get_part_flag (const char* prompt, const PedPartition* part, opts = str_list_append_unique (opts, _(walk_name)); } } - + if (opts == NULL) + { + ped_exception_throw (PED_EXCEPTION_ERROR, + PED_EXCEPTION_OK, + _("No flags supported")); + + return 0; + } flag_name = command_line_get_word (prompt, NULL, opts, 1); str_list_destroy (opts); |