Skip to content

Commit

Permalink
Merge pull request #11 from nhjm449/master
Browse files Browse the repository at this point in the history
Fix recent entries support
  • Loading branch information
ronys committed Dec 6, 2013
2 parents c1b76a6 + fe8fcf6 commit 1264bf5
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/pypwsafe/PWSafeV3Headers.py
Original file line number Diff line number Diff line change
Expand Up @@ -857,9 +857,15 @@ def parse(self):
"""Parse data"""
LEN = 32
left = self.data
assert len(left) % LEN == 0
assert len(left) % LEN == 2
self.recentEntries = []
count = int(unpack('=2s', left[:2])[0], 16)
log.debug("Should have %r records", count)
left = left[2:]
while len(left) >= LEN:
count -= 1
if count < 0:
log.warn("More record data than expected")
segement = left[:LEN]
left = left[LEN:]
log.debug("Working with %r", segement)
Expand All @@ -875,7 +881,8 @@ def __str__(self):
return "RecentEntriesHeader(%r)" % self.recentEntries

def serial(self):
return ','.join(self.recentEntries[:256])
packed = [pack('=16s', str(uuid.bytes)) for uuid in self.recentEntries[:256]]
return ','.join(packed)


class EmptyGroupHeader(Header):
Expand Down

0 comments on commit 1264bf5

Please sign in to comment.