This is merely a historical archive of years 2008-2021, before the migration to mailman3.
A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.
dexter gerrit-no-reply at lists.osmocom.orgdexter has uploaded this change for review. ( https://gerrit.osmocom.org/c/pysim/+/23378 )
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
constraint.
Since the human readable name also plays a major role in identifying
the type of the file (ADF, EF or DF) ensure that when adding files it
is ensured that the file actually has a name and that the name starts
with "DF.", "EF." or "ADF.".
Change-Id: I096907285b742e611d221b03ba067ea2522e7e52
Related: OS#4963
---
M pySim/filesystem.py
1 file changed, 7 insertions(+), 1 deletion(-)
git pull ssh://gerrit.osmocom.org:29418/pysim refs/changes/78/23378/1
diff --git a/pySim/filesystem.py b/pySim/filesystem.py
index fa1e02c..1957dbf 100644
--- a/pySim/filesystem.py
+++ b/pySim/filesystem.py
@@ -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):
@@ -145,6 +145,12 @@
"""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 = 8):
+ raise ValueError("File name %s is not a valid fid" % (child.fid))
+ if child.name is None:
+ raise ValueError("File fid %s has no human readable name" % (child.fid))
+ if child.name[0:3] != "DF." and child.name[0:3] != "EF." and child.name[0:4] != "ADF.":
+ raise ValueError("File name %s does not start with \"DF.\", \"EF.\" or \"ADF.\"" % (child.name))
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:
--
To view, visit https://gerrit.osmocom.org/c/pysim/+/23378
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: I096907285b742e611d221b03ba067ea2522e7e52
Gerrit-Change-Number: 23378
Gerrit-PatchSet: 1
Gerrit-Owner: dexter <pmaier at sysmocom.de>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20210316/809ded33/attachment.htm>