Change in pysim[master]: cards: check length of mnc more restrictively
laforge has submitted this change. ( https://gerrit.osmocom.org/c/pysim/+/30635 ) Change subject: cards: check length of mnc more restrictively ...................................................................... cards: check length of mnc more restrictively Since we now ensure that mnc always has a valid length lets make the check in cards.py more strict. Related: OS#5830 Change-Id: Iee8f25416e0cc3be96dff025affb1dc11d919fcd --- M pySim/cards.py 1 file changed, 5 insertions(+), 4 deletions(-) Approvals: Jenkins Builder: Verified laforge: Looks good to me, approved diff --git a/pySim/cards.py b/pySim/cards.py index 55965d7..4eff38c 100644 --- a/pySim/cards.py +++ b/pySim/cards.py @@ -205,11 +205,12 @@ # perform updates if mnc and abstract_data['extensions']: + # Note: Since we derive the length of the MNC by the string length + # of the mnc parameter, the caller must ensure that mnc has the + # correct length and is padded with zeros (if necessary). mnclen = len(str(mnc)) - if mnclen == 1: - mnclen = 2 - if mnclen > 3: - raise RuntimeError('invalid length of mnc "{}"'.format(mnc)) + if mnclen > 3 or mnclen < 2: + raise RuntimeError('invalid length of mnc "{}", expecting 2 or 3 digits'.format(mnc)) abstract_data['extensions']['mnc_len'] = mnclen if opmode: opmode_num = int(opmode, 16) -- To view, visit https://gerrit.osmocom.org/c/pysim/+/30635 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: pysim Gerrit-Branch: master Gerrit-Change-Id: Iee8f25416e0cc3be96dff025affb1dc11d919fcd Gerrit-Change-Number: 30635 Gerrit-PatchSet: 2 Gerrit-Owner: dexter <pmaier@sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: daniel <dwillmann@sysmocom.de> Gerrit-Reviewer: laforge <laforge@osmocom.org> Gerrit-CC: msuraev <msuraev@sysmocom.de> Gerrit-MessageType: merged
participants (1)
-
laforge