aboutsummaryrefslogtreecommitdiffstats
path: root/pySim-shell.py
diff options
context:
space:
mode:
authorPhilipp Maier <pmaier@sysmocom.de>2021-04-01 17:13:03 +0200
committerHarald Welte <laforge@osmocom.org>2021-04-02 16:32:53 +0200
commitb152a9e0edec37518ce372ca5f5a61e440070d75 (patch)
treee526d9a8c290c5bbf14d8a789ce32b7272c22d19 /pySim-shell.py
parent46f09af11d81e4bce9b3d677cab91e310f92cdd2 (diff)
pySim-shell: prevent inconsitancy when walking through the FS tree
When using the method walk() to walk through the filesystem tree, then the action() callback must not change the currently selected file. Unfortunately this can easily happen and result in unpredictable behavior. Lets add a check + an exeception for this to make debugging easier. Change-Id: I6778faa87bdf5552da74659206bf7a6fc0348d0c Related: OS#4963
Diffstat (limited to 'pySim-shell.py')
-rwxr-xr-xpySim-shell.py7
1 files changed, 7 insertions, 0 deletions
diff --git a/pySim-shell.py b/pySim-shell.py
index 11953eb..2ac0b26 100755
--- a/pySim-shell.py
+++ b/pySim-shell.py
@@ -263,7 +263,14 @@ class Iso7816Commands(CommandSet):
self.walk(indent + 1, action, context)
fcp_dec = self._cmd.rs.select("..", self._cmd)
elif action:
+ df_before_action = self._cmd.rs.selected_file
action(f, context)
+ # When walking through the file system tree the action must not
+ # always restore the currently selected file to the file that
+ # was selected before executing the action() callback.
+ if df_before_action != self._cmd.rs.selected_file:
+ raise RuntimeError("inconsistant walk, %s is currently selected but expecting %s to be selected"
+ % (str(self._cmd.rs.selected_file), str(df_before_action)))
def do_tree(self, opts):
"""Display a filesystem-tree with all selectable files"""