aboutsummaryrefslogtreecommitdiffstats
path: root/pySim-shell.py
diff options
context:
space:
mode:
authorHarald Welte <laforge@osmocom.org>2023-11-01 23:40:07 +0100
committerHarald Welte <laforge@osmocom.org>2023-11-03 00:43:17 +0100
commit4e59d89a5dec1df4700bf732c1802cf6bfcec38b (patch)
tree5ae3ccc0c3e45882687e57172381e7ef1baacc71 /pySim-shell.py
parentf9ea63ea51ef4a7bdf6a7ef531a3da9d2d53468e (diff)
pySim-shell: Validate that argument to 'apdu' command is proper hexstr
Let's not even send anything to the card if it's not an even number of hexadecimal digits Change-Id: I58465244101cc1a976e5a17af2aceea1cf9f9b54
Diffstat (limited to 'pySim-shell.py')
-rwxr-xr-xpySim-shell.py4
1 files changed, 2 insertions, 2 deletions
diff --git a/pySim-shell.py b/pySim-shell.py
index c2bb15c..d9c9f8c 100755
--- a/pySim-shell.py
+++ b/pySim-shell.py
@@ -53,7 +53,7 @@ from pySim.transport import init_reader, ApduTracer, argparse_add_reader_args, P
from pySim.cards import card_detect, SimCardBase, UiccCardBase
from pySim.utils import h2b, b2h, i2h, swap_nibbles, rpad, JsonEncoder, bertlv_parse_one, sw_match
from pySim.utils import sanitize_pin_adm, tabulate_str_list, boxed_heading_str, Hexstr, dec_iccid
-from pySim.utils import is_hexstr_or_decimal
+from pySim.utils import is_hexstr_or_decimal, is_hexstr
from pySim.card_handler import CardHandler, CardHandlerAuto
from pySim.filesystem import CardDF, CardADF, CardModel, CardApplication
@@ -322,7 +322,7 @@ Online manual available at https://downloads.osmocom.org/docs/pysim/master/html/
self.equip(card, rs)
apdu_cmd_parser = argparse.ArgumentParser()
- apdu_cmd_parser.add_argument('APDU', type=str, help='APDU as hex string')
+ apdu_cmd_parser.add_argument('APDU', type=is_hexstr, help='APDU as hex string')
apdu_cmd_parser.add_argument('--expect-sw', help='expect a specified status word', type=str, default=None)
@cmd2.with_argparser(apdu_cmd_parser)