projects
/
gpg-migrate.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
bb35aba
)
Check for short packets in PGPPacket.from_bytes
author
W. Trevor King
<wking@tremily.us>
Thu, 19 Dec 2013 04:44:30 +0000
(20:44 -0800)
committer
W. Trevor King
<wking@tremily.us>
Thu, 19 Dec 2013 04:44:30 +0000
(20:44 -0800)
When the data is longer than expected, the packet may just be part of
a stream.
gpg-migrate.py
patch
|
blob
|
history
diff --git
a/gpg-migrate.py
b/gpg-migrate.py
index 905f8b64aacb63bf7189069d1d23dabd3c6d4625..00e672c8a5fce7d0bc92743e3c281861508d330d 100755
(executable)
--- a/
gpg-migrate.py
+++ b/
gpg-migrate.py
@@
-48,6
+48,9
@@
class PGPPacket (dict):
offset += length_bytes
self['length'] = _struct.unpack(length_format, length_data)[0]
packet = data[offset:offset + self['length']]
+ if len(packet) < self['length']:
+ raise ValueError('packet too short ({} < {})'.format(
+ len(packet), self['length']))
offset += self['length']
return offset