<p>dexter has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.osmocom.org/c/pysim/+/23378">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">filesystem: be more strict in method add_file()<br><br>The file identifier of a file is strictly defined as a two digit<br>hexadecimal number. Do not allow adding child files that violate this<br>constraint.<br><br>Since the human readable name also plays a major role in identifying<br>the type of the file (ADF, EF or DF) ensure that when adding files it<br>is ensured that the file actually has a name and that the name starts<br>with "DF.", "EF." or "ADF.".<br><br>Change-Id: I096907285b742e611d221b03ba067ea2522e7e52<br>Related: OS#4963<br>---<br>M pySim/filesystem.py<br>1 file changed, 7 insertions(+), 1 deletion(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.osmocom.org:29418/pysim refs/changes/78/23378/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/pySim/filesystem.py b/pySim/filesystem.py</span><br><span>index fa1e02c..1957dbf 100644</span><br><span>--- a/pySim/filesystem.py</span><br><span>+++ b/pySim/filesystem.py</span><br><span>@@ -31,7 +31,7 @@</span><br><span> from cmd2 import CommandSet, with_default_category, with_argparser</span><br><span> import argparse</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-from pySim.utils import sw_match, h2b, b2h</span><br><span style="color: hsl(120, 100%, 40%);">+from pySim.utils import sw_match, h2b, b2h, is_hex</span><br><span> from pySim.exceptions import *</span><br><span> </span><br><span> class CardFile(object):</span><br><span>@@ -145,6 +145,12 @@</span><br><span>         """Add a child (DF/EF) to this DF"""</span><br><span>         if not isinstance(child, CardFile):</span><br><span>             raise TypeError("Expected a File instance")</span><br><span style="color: hsl(120, 100%, 40%);">+        if not is_hex(child.fid, minlen = 4, maxlen = 8):</span><br><span style="color: hsl(120, 100%, 40%);">+            raise ValueError("File name %s is not a valid fid" % (child.fid))</span><br><span style="color: hsl(120, 100%, 40%);">+        if child.name is None:</span><br><span style="color: hsl(120, 100%, 40%);">+            raise ValueError("File fid %s has no human readable name" % (child.fid))</span><br><span style="color: hsl(120, 100%, 40%);">+        if child.name[0:3] != "DF." and child.name[0:3] != "EF." and child.name[0:4] != "ADF.":</span><br><span style="color: hsl(120, 100%, 40%);">+            raise ValueError("File name %s does not start with \"DF.\", \"EF.\" or \"ADF.\"" % (child.name))</span><br><span>         if child.name in CardFile.RESERVED_NAMES:</span><br><span>             raise ValueError("File name %s is a reserved name" % (child.name))</span><br><span>         if child.fid in CardFile.RESERVED_FIDS:</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.osmocom.org/c/pysim/+/23378">change 23378</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://gerrit.osmocom.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.osmocom.org/c/pysim/+/23378"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: pysim </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-Change-Id: I096907285b742e611d221b03ba067ea2522e7e52 </div>
<div style="display:none"> Gerrit-Change-Number: 23378 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: dexter <pmaier@sysmocom.de> </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>