diff --git a/attic/archive.py b/attic/archive.py index c4287b5aa..850970e78 100644 --- a/attic/archive.py +++ b/attic/archive.py @@ -509,6 +509,11 @@ class ArchiveChecker: for chunk_id, _ in self.chunks.iteritems(): cdata = self.repository.get(chunk_id) data = self.key.decrypt(chunk_id, cdata) + # Some basic sanity checks of the payload before feeding it into msgpack + if len(data) < 2 or ((data[0] & 0xf0) != 0x80) or ((data[1] & 0xe0) != 0xa0): + continue + if not b'cmdline' in data or not b'\xa7version\x01' in data: + continue try: archive = msgpack.unpackb(data) except: diff --git a/attic/testsuite/archiver.py b/attic/testsuite/archiver.py index b81567425..be0d991f0 100644 --- a/attic/testsuite/archiver.py +++ b/attic/testsuite/archiver.py @@ -383,7 +383,9 @@ class ArchiverCheckTestCase(ArchiverTestCaseBase): repository.delete(Manifest.MANIFEST_ID) repository.commit() self.attic('check', self.repository_location, exit_code=1) - self.attic('check', '--repair', self.repository_location, exit_code=0) + output = self.attic('check', '--repair', self.repository_location, exit_code=0) + self.assert_in('archive1', output) + self.assert_in('archive2', output) self.attic('check', self.repository_location, exit_code=0) def test_extra_chunks(self):