dexter has uploaded this change for review. ( 
https://gerrit.osmocom.org/c/pysim/+/30635 )


Change subject: cards: check length of mnc more restrictively
......................................................................

cards: check length of mnc more restrictively

Since we now ensure that mnc always has a valid length lets make the
check in cards.py more strict.

Related: OS#5830
Change-Id: Iee8f25416e0cc3be96dff025affb1dc11d919fcd
---
M pySim/cards.py
1 file changed, 4 insertions(+), 3 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/pysim refs/changes/35/30635/1

diff --git a/pySim/cards.py b/pySim/cards.py
index 55965d7..9dfb1c2 100644
--- a/pySim/cards.py
+++ b/pySim/cards.py
@@ -205,10 +205,11 @@

         # perform updates
         if mnc and abstract_data['extensions']:
+            # Note: Since we derive the length of the MNC by the string length
+            # of the mnc parameter, the caller must ensure that mnc has the
+            # correct length and is padded with zeros (if necessary).
             mnclen = len(str(mnc))
-            if mnclen == 1:
-                mnclen = 2
-            if mnclen > 3:
+            if mnclen > 3 or mnclen < 2:
                 raise RuntimeError('invalid length of mnc "{}"'.format(mnc))
             abstract_data['extensions']['mnc_len'] = mnclen
         if opmode:

--
To view, visit https://gerrit.osmocom.org/c/pysim/+/30635
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: Iee8f25416e0cc3be96dff025affb1dc11d919fcd
Gerrit-Change-Number: 30635
Gerrit-PatchSet: 1
Gerrit-Owner: dexter <[email protected]>
Gerrit-MessageType: newchange

Reply via email to