From 8c1a1c5cc50a2f51a7cc0ea80c01d0018885569e Mon Sep 17 00:00:00 2001 From: Philipp Maier Date: Fri, 16 Aug 2024 13:29:10 +0200 Subject: [PATCH] pySim-shell: prevent opening/closing logical channel 0 The basic logical channel 0 is always present. It cannot be created or closed. Let's restrict the value range of chan_nr, so that only valid lchan numbers can be passed. Related: OS#6531 Change-Id: I4eebd9f15fadd18e1caeb033fda36c59446fcab8 --- pySim-shell.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pySim-shell.py b/pySim-shell.py index cc36485e..0ba8a25f 100755 --- a/pySim-shell.py +++ b/pySim-shell.py @@ -965,7 +965,7 @@ class Iso7816Commands(CommandSet): open_chan_parser = argparse.ArgumentParser() open_chan_parser.add_argument( - 'chan_nr', type=int, default=0, help='Channel Number') + 'chan_nr', type=int, default=1, choices=range(1,16), help='Channel Number') @cmd2.with_argparser(open_chan_parser) def do_open_channel(self, opts): @@ -977,7 +977,7 @@ class Iso7816Commands(CommandSet): close_chan_parser = argparse.ArgumentParser() close_chan_parser.add_argument( - 'chan_nr', type=int, default=0, help='Channel Number') + 'chan_nr', type=int, default=1, choices=range(1,16), help='Channel Number') @cmd2.with_argparser(close_chan_parser) def do_close_channel(self, opts): @@ -989,7 +989,7 @@ class Iso7816Commands(CommandSet): switch_chan_parser = argparse.ArgumentParser() switch_chan_parser.add_argument( - 'chan_nr', type=int, default=0, help='Channel Number') + 'chan_nr', type=int, default=0, choices=range(0,16), help='Channel Number') @cmd2.with_argparser(switch_chan_parser) def do_switch_channel(self, opts):