<p>dexter <strong>submitted</strong> this change.</p><p><a href="https://gerrit.osmocom.org/c/pysim/+/23378">View Change</a></p><div style="white-space:pre-wrap">Approvals:
  Jenkins Builder: Verified
  laforge: Looks good to me, approved

</div><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>Change-Id: I096907285b742e611d221b03ba067ea2522e7e52<br>Related: OS#4963<br>---<br>M pySim/filesystem.py<br>1 file changed, 3 insertions(+), 1 deletion(-)<br><br></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 d468808..f6dddb6 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>@@ -144,6 +144,8 @@</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 = 4):</span><br><span style="color: hsl(120, 100%, 40%);">+            raise ValueError("File name %s is not a valid fid" % (child.fid))</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: 6 </div>
<div style="display:none"> Gerrit-Owner: dexter <pmaier@sysmocom.de> </div>
<div style="display:none"> Gerrit-Reviewer: Jenkins Builder </div>
<div style="display:none"> Gerrit-Reviewer: dexter <pmaier@sysmocom.de> </div>
<div style="display:none"> Gerrit-Reviewer: laforge <laforge@osmocom.org> </div>
<div style="display:none"> Gerrit-MessageType: merged </div>