diff options
author | Vadim Yanitskiy <axilirator@gmail.com> | 2020-05-10 02:32:46 +0700 |
---|---|---|
committer | laforge <laforge@osmocom.org> | 2020-05-28 09:59:51 +0000 |
commit | eb06b45d0edd7843551e78da468a4d907f906993 (patch) | |
tree | c3f3c650a3a320bd5dc15f7ee7415b996b3e20be | |
parent | d58c632277d64cad63e8e426be69ec1a4347f8ef (diff) |
utils: fix list comprehension in h2s(): ignore upper case padding
By definition, h2s() is supposed to skip padding in the given
hexstring, so it was working fine for 'ff', but not for 'FF'.
Change-Id: I2c5d72a0f7f2796115116737f9f7b5299021f6a3
Signed-off-by: Vadim Yanitskiy <axilirator@gmail.com>
-rw-r--r-- | pySim/utils.py | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/pySim/utils.py b/pySim/utils.py index 2de6856..20eb5a8 100644 --- a/pySim/utils.py +++ b/pySim/utils.py @@ -35,7 +35,8 @@ def i2h(s): return ''.join(['%02x'%(x) for x in s]) def h2s(s): - return ''.join([chr((int(x,16)<<4)+int(y,16)) for x,y in zip(s[0::2], s[1::2]) if not (x == 'f' and y == 'f') ]) + return ''.join([chr((int(x,16)<<4)+int(y,16)) for x,y in zip(s[0::2], s[1::2]) + if int(x + y, 16) != 0xff]) def s2h(s): return b2h(s) |