aboutsummaryrefslogtreecommitdiffstats
path: root/pySim
diff options
context:
space:
mode:
authorHarald Welte <laforge@osmocom.org>2020-05-12 21:12:44 +0200
committerPhilipp Maier <pmaier@sysmocom.de>2020-05-13 11:44:13 +0200
commit7f1d3c496f2202f942ecd306c6fd43650f18f348 (patch)
treeb2a6bba0b89ada1ef1b7218a406d538f068ce446 /pySim
parentff84c238390606d92eefc0f5342079178c5f8de6 (diff)
Treat MCC and MNC as strings, not integers
A MNC of 02 and 002 are *not* equal. The former is a two-digit MNC and the latter is a three-digit MNC. Hence, we shouldn't treat MNCs as integer values as we have no clue how many leading zeroes (if any) the user entered. Change-Id: I9d1d07a64888c76703c3e430bbdd822080c05819 Closes: OS#4523
Diffstat (limited to 'pySim')
-rw-r--r--pySim/utils.py4
1 files changed, 3 insertions, 1 deletions
diff --git a/pySim/utils.py b/pySim/utils.py
index a1689ca..43616a9 100644
--- a/pySim/utils.py
+++ b/pySim/utils.py
@@ -102,7 +102,9 @@ def enc_iccid(iccid):
def enc_plmn(mcc, mnc):
"""Converts integer MCC/MNC into 3 bytes for EF"""
- return swap_nibbles(lpad('%d' % int(mcc), 3) + lpad('%d' % int(mnc), 3))
+ if len(mnc) == 2:
+ mnc = "F%s" % mnc
+ return swap_nibbles("%s%s" % (mcc, mnc))
def dec_spn(ef):
byte1 = int(ef[0:2])