mirror of
https://github.com/borgbackup/borg.git
synced 2025-02-12 09:30:27 +00:00
repository: Fixed a potential infinite loop in recover_segment
This commit is contained in:
parent
88ff981eee
commit
c1e1d6e9dd
1 changed files with 9 additions and 1 deletions
|
@ -258,6 +258,8 @@ def report_progress(msg, error=False):
|
||||||
current_index = None
|
current_index = None
|
||||||
if transaction_id is None:
|
if transaction_id is None:
|
||||||
transaction_id = self.get_index_transaction_id()
|
transaction_id = self.get_index_transaction_id()
|
||||||
|
if transaction_id is None:
|
||||||
|
transaction_id = self.io.get_latest_segment()
|
||||||
segments_transaction_id = self.io.get_segments_transaction_id()
|
segments_transaction_id = self.io.get_segments_transaction_id()
|
||||||
self.get_index(None)
|
self.get_index(None)
|
||||||
for segment, filename in self.io.segment_iterator():
|
for segment, filename in self.io.segment_iterator():
|
||||||
|
@ -417,6 +419,12 @@ def segment_iterator(self, reverse=False):
|
||||||
for filename in filenames:
|
for filename in filenames:
|
||||||
yield int(filename), os.path.join(dirpath, filename)
|
yield int(filename), os.path.join(dirpath, filename)
|
||||||
|
|
||||||
|
|
||||||
|
def get_latest_segment(self):
|
||||||
|
for segment, filename in self.segment_iterator(reverse=True):
|
||||||
|
return segment
|
||||||
|
return None
|
||||||
|
|
||||||
def get_segments_transaction_id(self):
|
def get_segments_transaction_id(self):
|
||||||
"""Verify that the transaction id is consistent with the index transaction id
|
"""Verify that the transaction id is consistent with the index transaction id
|
||||||
"""
|
"""
|
||||||
|
@ -518,7 +526,7 @@ def recover_segment(self, segment, filename):
|
||||||
fd.write(MAGIC)
|
fd.write(MAGIC)
|
||||||
while len(data) >= self.header_fmt.size:
|
while len(data) >= self.header_fmt.size:
|
||||||
crc, size, tag = self.header_fmt.unpack(data[:self.header_fmt.size])
|
crc, size, tag = self.header_fmt.unpack(data[:self.header_fmt.size])
|
||||||
if size > len(data):
|
if size < self.header_fmt.size or size > len(data):
|
||||||
data = data[1:]
|
data = data[1:]
|
||||||
continue
|
continue
|
||||||
if crc32(data[4:size]) & 0xffffffff != crc:
|
if crc32(data[4:size]) & 0xffffffff != crc:
|
||||||
|
|
Loading…
Reference in a new issue