Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Hvornum <anton@hvornum.se>2021-03-30 14:57:40 +0000
committerGitHub <noreply@github.com>2021-03-30 14:57:40 +0000
commit2c90f02b6b26cc489e90f7536fe8931a4b2b9195 (patch)
tree8f8162649bd4a6efd120cde2705f0cc2e5a71008
parentbb5caf70b7c3daae863778738775823a51b0b92b (diff)
parent40dbb5791c4be60d671d0a4abd2e9ba70e11b896 (diff)
Merge pull request #132 from kpcyrd/range-check
Add range check to generic_select
-rw-r--r--archinstall/lib/user_interaction.py10
1 files changed, 8 insertions, 2 deletions
diff --git a/archinstall/lib/user_interaction.py b/archinstall/lib/user_interaction.py
index defc2cfc..80db7be1 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:
@@ -195,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: