Review at  https://gerrit.osmocom.org/5623

utils.py: dec_imsi: Fix ValueError

It should fix the following observed error:
~/pysim$ ./pySim-read.py -p0
Reading ...
ICCID:
Traceback (most recent call last):
  File "./pySim-read.py", line 99, in <module>
    print("IMSI: %s" % (dec_imsi(res),))
  File "/home/lab434/pysim/pySim/utils.py", line 57, in dec_imsi
    l = int(ef[0:2]) * 2            # Length of the IMSI string
ValueError: invalid literal for int() with base 10: 'ff'

Change-Id: I7d3ecbf9edd190d1941816796cee60e3957d5943
---
M pySim/utils.py
1 file changed, 1 insertion(+), 1 deletion(-)


  git pull ssh://gerrit.osmocom.org:29418/pysim refs/changes/23/5623/1

diff --git a/pySim/utils.py b/pySim/utils.py
index 011bd05..84b613f 100644
--- a/pySim/utils.py
+++ b/pySim/utils.py
@@ -54,7 +54,7 @@
        """Converts an EF value to the imsi string representation"""
        if len(ef) < 4:
                return None
-       l = int(ef[0:2]) * 2                    # Length of the IMSI string
+       l = int(ef[0:2], 16) * 2                # Length of the IMSI string
        swapped = swap_nibbles(ef[2:])
        oe = (int(swapped[0])>>3) & 1   # Odd (1) / Even (0)
        if oe:

-- 
To view, visit https://gerrit.osmocom.org/5623
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I7d3ecbf9edd190d1941816796cee60e3957d5943
Gerrit-PatchSet: 1
Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Owner: Pau Espin Pedrol <[email protected]>

Reply via email to