mirror of
https://github.com/borgbackup/borg.git
synced 2026-06-12 18:30:18 -04:00
Make the manifest rebuild code more robust
Try to make sure we've actually found msgpack data before feeding it into msgpack.
This commit is contained in:
parent
3982c34e6c
commit
7be0ad609d
2 changed files with 8 additions and 1 deletions
|
|
@ -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:
|
||||
|
|
|
|||
|
|
@ -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):
|
||||
|
|
|
|||
Loading…
Reference in a new issue