1 From 9e196cc2902255c328a90584e44666b79e4344c3 Mon Sep 17 00:00:00 2001
2 From: Phillip Susi <psusi@ubuntu.com>
3 Date: Thu, 10 May 2018 12:31:36 -0400
4 Subject: [PATCH 85/92] Fix set and disk_set to not crash when no flags are
7 Loop labels and file images support no flags. set and disk_set
8 would prompt for a flag and accept any string since the list of
9 flags was empty, then fail to look up an actual flag value, then
10 throw an exception with a null string for the name of the flag,
13 parted/ui.c | 18 ++++++++++++++++--
14 tests/t3310-flags.sh | 13 +++++++++++++
15 3 files changed, 31 insertions(+), 2 deletions(-)
17 diff --git a/parted/ui.c b/parted/ui.c
18 index 752860b..4f42b7c 100644
21 @@ -1132,7 +1132,14 @@ command_line_get_disk_flag (const char*
22 opts = str_list_append_unique (opts, _(walk_name));
28 + ped_exception_throw (PED_EXCEPTION_ERROR,
30 + _("No flags supported"));
34 flag_name = command_line_get_word (prompt, NULL, opts, 1);
35 str_list_destroy (opts);
37 @@ -1161,7 +1168,14 @@ command_line_get_part_flag (const char*
38 opts = str_list_append_unique (opts, _(walk_name));
44 + ped_exception_throw (PED_EXCEPTION_ERROR,
46 + _("No flags supported"));
50 flag_name = command_line_get_word (prompt, NULL, opts, 1);
51 str_list_destroy (opts);
53 diff --git a/tests/t3310-flags.sh b/tests/t3310-flags.sh
54 index 2da72d0..0997748 100644
55 --- a/tests/t3310-flags.sh
56 +++ b/tests/t3310-flags.sh
57 @@ -114,4 +114,17 @@ for table_type in aix amiga atari bsd dvh gpt mac msdos pc98 sun loop; do
61 +# loop filesystems support no flags. Make sure this doesn't crash
63 +if [ $ss == 512 ]; then
64 + # only test on 512 byte ss since mke2fs assumes this on a file
65 + truncate -s 5m img || framework_failure
66 + mke2fs img || framework_failure
67 + echo Error: No flags supported > out.exp
68 + parted -s img set 1 foo on > out 2>&1
69 + compare out.exp out || fail=1
70 + parted -s img disk_set foo on > out 2>&1
71 + compare out.exp out || fail=1