diff options
author | Philipp Maier <pmaier@sysmocom.de> | 2021-03-09 21:49:01 +0100 |
---|---|---|
committer | Philipp Maier <pmaier@sysmocom.de> | 2021-03-22 22:29:49 +0100 |
commit | 3aec87197848646f751c8825dabda6084e5ad88e (patch) | |
tree | 5a5c6c1523e8a86c71bfd69dbd9874a853964e9f | |
parent | d51d8b55753724b6f97650a92709f1e6ecf027d6 (diff) |
filesystem: be more strict in method add_file()
The file identifier of a file is strictly defined as a two digit
hexadecimal number. Do not allow adding child files that violate this
constraint.
Change-Id: I096907285b742e611d221b03ba067ea2522e7e52
Related: OS#4963
-rw-r--r-- | pySim/filesystem.py | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/pySim/filesystem.py b/pySim/filesystem.py index d468808..f6dddb6 100644 --- a/pySim/filesystem.py +++ b/pySim/filesystem.py @@ -31,7 +31,7 @@ import cmd2 from cmd2 import CommandSet, with_default_category, with_argparser import argparse -from pySim.utils import sw_match, h2b, b2h +from pySim.utils import sw_match, h2b, b2h, is_hex from pySim.exceptions import * class CardFile(object): @@ -144,6 +144,8 @@ class CardDF(CardFile): """Add a child (DF/EF) to this DF""" if not isinstance(child, CardFile): raise TypeError("Expected a File instance") + if not is_hex(child.fid, minlen = 4, maxlen = 4): + raise ValueError("File name %s is not a valid fid" % (child.fid)) if child.name in CardFile.RESERVED_NAMES: raise ValueError("File name %s is a reserved name" % (child.name)) if child.fid in CardFile.RESERVED_FIDS: |