pySim-shell: Reject any non-decimal PIN values

Don't even send any non-decimal PIN values to the card, but reject
them when parsing the command arguments.

Change-Id: Icec1698851471af7f76f20201dcdcfcd48ddf365
This commit is contained in:
Harald Welte
2023-11-01 23:48:28 +01:00
parent 977c5925a1
commit 1c849f8bc2
2 changed files with 15 additions and 8 deletions

View File

@@ -1487,3 +1487,10 @@ def is_hexstr(instr: str) -> str:
if len(instr) & 1:
raise ValueError('Input has un-even number of hex digits')
return instr
def is_decimal(instr: str) -> str:
"""Method that can be used as 'type' in argparse.add_argument() to validate the value consists of
an even sequence of decimal digits only."""
if not instr.isdecimal():
raise ValueError('Input must decimal')
return instr