From 82342a0e94ed6d591b9855db590719764e9cb460 Mon Sep 17 00:00:00 2001 From: kpcyrd Date: Tue, 30 Mar 2021 16:12:52 +0200 Subject: Add range check to generic_select --- archinstall/lib/user_interaction.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'archinstall') diff --git a/archinstall/lib/user_interaction.py b/archinstall/lib/user_interaction.py index defc2cfc..b3e0b665 100644 --- a/archinstall/lib/user_interaction.py +++ b/archinstall/lib/user_interaction.py @@ -170,7 +170,10 @@ def generic_select(options, input_text="Select one of the above by index or abso if len(selected_option.strip()) <= 0: return None elif selected_option.isdigit(): - selected_option = options[int(selected_option)] + selected_option = int(selected_option) + if selected_option >= len(options): + raise RequirementError(f'Selected option "{selected_option}" is out of range') + selected_option = options[selected_option] elif selected_option in options: pass # We gave a correct absolute value else: -- cgit v1.2.3-70-g09d2 From 40dbb5791c4be60d671d0a4abd2e9ba70e11b896 Mon Sep 17 00:00:00 2001 From: kpcyrd Date: Tue, 30 Mar 2021 16:24:48 +0200 Subject: Add range check to disk selection --- archinstall/lib/user_interaction.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'archinstall') diff --git a/archinstall/lib/user_interaction.py b/archinstall/lib/user_interaction.py index b3e0b665..80db7be1 100644 --- a/archinstall/lib/user_interaction.py +++ b/archinstall/lib/user_interaction.py @@ -198,7 +198,10 @@ def select_disk(dict_o_disks): print(f"{index}: {drive} ({dict_o_disks[drive]['size'], dict_o_disks[drive].device, dict_o_disks[drive]['label']})") drive = input('Select one of the above disks (by number or full path): ') if drive.isdigit(): - drive = dict_o_disks[drives[int(drive)]] + drive = int(drive) + if drive >= len(drives): + raise DiskError(f'Selected option "{drive}" is out of range') + drive = dict_o_disks[drives[drive]] elif drive in dict_o_disks: drive = dict_o_disks[drive] else: -- cgit v1.2.3-70-g09d2