From 13e258dc858753456626477a5727267196bba6eb Mon Sep 17 00:00:00 2001 From: Philipp Maier Date: Thu, 8 Apr 2021 17:48:49 +0200 Subject: [PATCH] pySim-shell: be sure that startup script file exists When a startup script file is specified that does not exists pySim-shell skips the script and starts normally. This is dangerous because if pySim-shell is called by a shellscript with a nonexisting script file the shellscript may hang forever because there is no script that exists pySim-shell again Change-Id: I4ff2226c8852727aa23357aa54d1e2d480bfaf2d Related: OS#4963 --- pySim-shell.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pySim-shell.py b/pySim-shell.py index f1060de4..3059f3ff 100755 --- a/pySim-shell.py +++ b/pySim-shell.py @@ -450,6 +450,12 @@ if __name__ == '__main__': rs.mf.add_file(DF_TELECOM()) rs.mf.add_file(DF_GSM()) + # If a script file is specified, be sure that it actually exists + if opts.script: + if not os.access(opts.script, os.R_OK): + print("Invalid script file!") + sys.exit(2) + app = PysimApp(card, rs, opts.script) rs.select('MF', app)