[MERGED] pysim[master]: utils.py: dec_imsi: Fix ValueError

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

Harald Welte gerrit-no-reply at lists.osmocom.org
Tue Jan 2 07:20:57 UTC 2018


Harald Welte has submitted this change and it was merged.

Change subject: utils.py: dec_imsi: Fix ValueError
......................................................................


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(-)

Approvals:
  Harald Welte: Looks good to me, approved; Verified



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: merged
Gerrit-Change-Id: I7d3ecbf9edd190d1941816796cee60e3957d5943
Gerrit-PatchSet: 2
Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Owner: Pau Espin Pedrol <pespin at sysmocom.de>
Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org>



More information about the gerrit-log mailing list