Change in pysim[master]: utils: do not crash when all bytes of EF.IMSI are 0xFF
laforge has posted comments on this change. ( https://gerrit.osmocom.org/c/pysim/+/18208 ) Change subject: utils: do not crash when all bytes of EF.IMSI are 0xFF .. Patch Set 5: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/c/pysim/+/18208 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: pysim Gerrit-Branch: master Gerrit-Change-Id: I93874a1d7e0b87d39e4b06a5c504643cfabb451c Gerrit-Change-Number: 18208 Gerrit-PatchSet: 5 Gerrit-Owner: dexter Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: laforge Gerrit-Comment-Date: Fri, 22 May 2020 13:11:39 + Gerrit-HasComments: No Gerrit-Has-Labels: Yes Gerrit-MessageType: comment
Change in pysim[master]: utils: do not crash when all bytes of EF.IMSI are 0xFF
laforge has submitted this change. ( https://gerrit.osmocom.org/c/pysim/+/18208 ) Change subject: utils: do not crash when all bytes of EF.IMSI are 0xFF .. utils: do not crash when all bytes of EF.IMSI are 0xFF In case try to decode the contents of an uninitalized EF.IMSI, the function dec_imsi() would crash because it truncates all 0xFF from the swapped version of the EF.IMSI contents and then accesses the first element of the buffer. This always works for EF.IMSI contents that contain valid IMSI data, but if all bytes are set to 0xFF, then no data is left in the buffer after truncating, so lets check if we even have bytes left before we move on with the decoding. Change-Id: I93874a1d7e0b87d39e4b06a5c504643cfabb451c --- M pySim/utils.py 1 file changed, 2 insertions(+), 0 deletions(-) Approvals: Jenkins Builder: Verified laforge: Looks good to me, approved diff --git a/pySim/utils.py b/pySim/utils.py index b5203dc..2de6856 100644 --- a/pySim/utils.py +++ b/pySim/utils.py @@ -85,6 +85,8 @@ l = int(ef[0:2], 16) * 2# Length of the IMSI string l = l - 1 # Encoded length byte includes oe nibble swapped = swap_nibbles(ef[2:]).rstrip('f') + if len(swapped) < 1: + return None oe = (int(swapped[0])>>3) & 1 # Odd (1) / Even (0) if not oe: # if even, only half of last byte was used -- To view, visit https://gerrit.osmocom.org/c/pysim/+/18208 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: pysim Gerrit-Branch: master Gerrit-Change-Id: I93874a1d7e0b87d39e4b06a5c504643cfabb451c Gerrit-Change-Number: 18208 Gerrit-PatchSet: 5 Gerrit-Owner: dexter Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: laforge Gerrit-MessageType: merged
Change in pysim[master]: utils: do not crash when all bytes of EF.IMSI are 0xFF
laforge has uploaded a new patch set (#4) to the change originally created by dexter. ( https://gerrit.osmocom.org/c/pysim/+/18208 ) Change subject: utils: do not crash when all bytes of EF.IMSI are 0xFF .. utils: do not crash when all bytes of EF.IMSI are 0xFF In case try to decode the contents of an uninitalized EF.IMSI, the function dec_imsi() would crash because it truncates all 0xFF from the swapped version of the EF.IMSI contents and then accesses the first element of the buffer. This always works for EF.IMSI contents that contain valid IMSI data, but if all bytes are set to 0xFF, then no data is left in the buffer after truncating, so lets check if we even have bytes left before we move on with the decoding. Change-Id: I93874a1d7e0b87d39e4b06a5c504643cfabb451c --- M pySim/utils.py 1 file changed, 2 insertions(+), 0 deletions(-) git pull ssh://gerrit.osmocom.org:29418/pysim refs/changes/08/18208/4 -- To view, visit https://gerrit.osmocom.org/c/pysim/+/18208 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: pysim Gerrit-Branch: master Gerrit-Change-Id: I93874a1d7e0b87d39e4b06a5c504643cfabb451c Gerrit-Change-Number: 18208 Gerrit-PatchSet: 4 Gerrit-Owner: dexter Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: laforge Gerrit-MessageType: newpatchset
Change in pysim[master]: utils: do not crash when all bytes of EF.IMSI are 0xFF
laforge has posted comments on this change. ( https://gerrit.osmocom.org/c/pysim/+/18208 ) Change subject: utils: do not crash when all bytes of EF.IMSI are 0xFF .. Patch Set 3: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/c/pysim/+/18208 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: pysim Gerrit-Branch: master Gerrit-Change-Id: I93874a1d7e0b87d39e4b06a5c504643cfabb451c Gerrit-Change-Number: 18208 Gerrit-PatchSet: 3 Gerrit-Owner: dexter Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: laforge Gerrit-Comment-Date: Sat, 16 May 2020 20:20:46 + Gerrit-HasComments: No Gerrit-Has-Labels: Yes Gerrit-MessageType: comment
Change in pysim[master]: utils: do not crash when all bytes of EF.IMSI are 0xFF
laforge has posted comments on this change. ( https://gerrit.osmocom.org/c/pysim/+/18208 ) Change subject: utils: do not crash when all bytes of EF.IMSI are 0xFF .. Patch Set 3: Code-Review+1 (1 comment) https://gerrit.osmocom.org/c/pysim/+/18208/3//COMMIT_MSG Commit Message: https://gerrit.osmocom.org/c/pysim/+/18208/3//COMMIT_MSG@12 PS3, Line 12: worls works -- To view, visit https://gerrit.osmocom.org/c/pysim/+/18208 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: pysim Gerrit-Branch: master Gerrit-Change-Id: I93874a1d7e0b87d39e4b06a5c504643cfabb451c Gerrit-Change-Number: 18208 Gerrit-PatchSet: 3 Gerrit-Owner: dexter Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: laforge Gerrit-Comment-Date: Tue, 12 May 2020 18:06:56 + Gerrit-HasComments: Yes Gerrit-Has-Labels: Yes Gerrit-MessageType: comment
Change in pysim[master]: utils: do not crash when all bytes of EF.IMSI are 0xFF
dexter has uploaded this change for review. ( https://gerrit.osmocom.org/c/pysim/+/18208 ) Change subject: utils: do not crash when all bytes of EF.IMSI are 0xFF .. utils: do not crash when all bytes of EF.IMSI are 0xFF In case try to decode the contents of an uninitalized EF.IMSI, the function dec_imsi() would crash because it truncates all 0xFF from the swapped version of the EF.IMSI contents and then accesses the first element of the buffer. This always worls for EF.IMSI contents that contain valid IMSI data, but if all bytes are set to 0xFF, then no data is left in the buffer after truncating, so lets check if we even have bytes left before we move on with the decoding. Change-Id: I93874a1d7e0b87d39e4b06a5c504643cfabb451c --- M pySim/utils.py 1 file changed, 2 insertions(+), 0 deletions(-) git pull ssh://gerrit.osmocom.org:29418/pysim refs/changes/08/18208/1 diff --git a/pySim/utils.py b/pySim/utils.py index aab5d02..e5b0a74 100644 --- a/pySim/utils.py +++ b/pySim/utils.py @@ -81,6 +81,8 @@ l = int(ef[0:2], 16) * 2# Length of the IMSI string l = l - 1 # Encoded length byte includes oe nibble swapped = swap_nibbles(ef[2:]).rstrip('f') + if len(swapped) < 1: + return None oe = (int(swapped[0])>>3) & 1 # Odd (1) / Even (0) if not oe: # if even, only half of last byte was used -- To view, visit https://gerrit.osmocom.org/c/pysim/+/18208 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: pysim Gerrit-Branch: master Gerrit-Change-Id: I93874a1d7e0b87d39e4b06a5c504643cfabb451c Gerrit-Change-Number: 18208 Gerrit-PatchSet: 1 Gerrit-Owner: dexter Gerrit-MessageType: newchange