gpg/decode/parse_subpackets: parse subpacket length according to RFC

This commit is contained in:
Nicolas Pouillard
2016-09-05 17:04:06 +02:00
parent 73bdf417e4
commit adcbe6e7b2

View File

@@ -25,10 +25,17 @@ def parse_subpackets(s):
while True:
try:
subpacket_len = s.readfmt('B')
first = s.readfmt('B')
except EOFError:
break
if first < 192:
subpacket_len = first
elif first < 255:
subpacket_len = ((first - 192) << 8) + s.readfmt('B') + 192
else: # first == 255
subpacket_len = s.readfmt('>L')
subpackets.append(s.read(subpacket_len))
return subpackets