Change in pysim[master]: filesystem: be more strict in method add_file()

dexter gerrit-no-reply at
Mon Mar 22 21:31:38 UTC 2021

dexter has submitted this change. ( )

Change subject: filesystem: be more strict in method add_file()

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

Change-Id: I096907285b742e611d221b03ba067ea2522e7e52
Related: OS#4963
M pySim/
1 file changed, 3 insertions(+), 1 deletion(-)

  Jenkins Builder: Verified
  laforge: Looks good to me, approved

diff --git a/pySim/ b/pySim/
index d468808..f6dddb6 100644
--- a/pySim/
+++ b/pySim/
@@ -31,7 +31,7 @@
 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 @@
         """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 in CardFile.RESERVED_NAMES:
             raise ValueError("File name %s is a reserved name" % (
         if child.fid in CardFile.RESERVED_FIDS:

To view, visit
To unsubscribe, or for help writing mail filters, visit

Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: I096907285b742e611d221b03ba067ea2522e7e52
Gerrit-Change-Number: 23378
Gerrit-PatchSet: 6
Gerrit-Owner: dexter <pmaier at>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: dexter <pmaier at>
Gerrit-Reviewer: laforge <laforge at>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the gerrit-log mailing list