laforge has uploaded this change for review. ( 
https://gerrit.osmocom.org/c/pysim/+/35282?usp=email )


Change subject: bertlv_parse_len: Fix input data is smaller than num length 
octets
......................................................................

bertlv_parse_len: Fix input data is smaller than num length octets

This can happen if there's a file with invalid encoding on the card,
such as a tag followed by all-ff.  Let's gracefully ignore it and
return zero bytes as response.

Change-Id: Ic44557368a6034dbf4bb021ab23a57927c22def0
---
M pySim/utils.py
1 file changed, 15 insertions(+), 0 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/pysim refs/changes/82/35282/1

diff --git a/pySim/utils.py b/pySim/utils.py
index 44800fb..23b26f9 100644
--- a/pySim/utils.py
+++ b/pySim/utils.py
@@ -314,6 +314,8 @@
     else:
         num_len_oct = binary[0] & 0x7f
         length = 0
+        if len(binary) < num_len_oct + 1:
+            return (0, b'')
         for i in range(1, 1+num_len_oct):
             length <<= 8
             length |= binary[i]

--
To view, visit https://gerrit.osmocom.org/c/pysim/+/35282?usp=email
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: Ic44557368a6034dbf4bb021ab23a57927c22def0
Gerrit-Change-Number: 35282
Gerrit-PatchSet: 1
Gerrit-Owner: laforge <lafo...@osmocom.org>
Gerrit-MessageType: newchange

Reply via email to