Show More
@@ -178,10 +178,9 b' usingsha256 = 2' | |||
|
178 | 178 | _fm0fsize = _calcsize(_fm0fixed) |
|
179 | 179 | _fm0fnodesize = _calcsize(_fm0node) |
|
180 | 180 | |
|
181 | def _fm0readmarkers(data, off): | |
|
181 | def _fm0readmarkers(data, off, stop): | |
|
182 | 182 | # Loop on markers |
|
183 | l = len(data) | |
|
184 | while off + _fm0fsize <= l: | |
|
183 | while off < stop: | |
|
185 | 184 | # read fixed part |
|
186 | 185 | cur = data[off:off + _fm0fsize] |
|
187 | 186 | off += _fm0fsize |
@@ -317,7 +316,7 b' def _fm0decodemeta(data):' | |||
|
317 | 316 | _fm1metapair = 'BB' |
|
318 | 317 | _fm1metapairsize = _calcsize('BB') |
|
319 | 318 | |
|
320 | def _fm1purereadmarkers(data, off): | |
|
319 | def _fm1purereadmarkers(data, off, stop): | |
|
321 | 320 | # make some global constants local for performance |
|
322 | 321 | noneflag = _fm1parentnone |
|
323 | 322 | sha2flag = usingsha256 |
@@ -331,10 +330,9 b' def _fm1purereadmarkers(data, off):' | |||
|
331 | 330 | unpack = _unpack |
|
332 | 331 | |
|
333 | 332 | # Loop on markers |
|
334 | stop = len(data) - _fm1fsize | |
|
335 | 333 | ufixed = struct.Struct(_fm1fixed).unpack |
|
336 | 334 | |
|
337 |
while off < |
|
|
335 | while off < stop: | |
|
338 | 336 | # read fixed part |
|
339 | 337 | o1 = off + fsize |
|
340 | 338 | t, secs, tz, flags, numsuc, numpar, nummeta, prec = ufixed(data[off:o1]) |
@@ -428,11 +426,10 b' def _fm1encodeonemarker(marker):' | |||
|
428 | 426 | data.append(value) |
|
429 | 427 | return ''.join(data) |
|
430 | 428 | |
|
431 | def _fm1readmarkers(data, off): | |
|
429 | def _fm1readmarkers(data, off, stop): | |
|
432 | 430 | native = getattr(parsers, 'fm1readmarkers', None) |
|
433 | 431 | if not native: |
|
434 | return _fm1purereadmarkers(data, off) | |
|
435 | stop = len(data) - _fm1fsize | |
|
432 | return _fm1purereadmarkers(data, off, stop) | |
|
436 | 433 | return native(data, off, stop) |
|
437 | 434 | |
|
438 | 435 | # mapping to read/write various marker formats |
@@ -444,14 +441,17 b' def _readmarkerversion(data):' | |||
|
444 | 441 | return _unpack('>B', data[0:1])[0] |
|
445 | 442 | |
|
446 | 443 | @util.nogc |
|
447 | def _readmarkers(data): | |
|
444 | def _readmarkers(data, off=None, stop=None): | |
|
448 | 445 | """Read and enumerate markers from raw data""" |
|
449 | 446 | diskversion = _readmarkerversion(data) |
|
450 | off = 1 | |
|
447 | if not off: | |
|
448 | off = 1 # skip 1 byte version number | |
|
449 | if stop is None: | |
|
450 | stop = len(data) | |
|
451 | 451 | if diskversion not in formats: |
|
452 | 452 | msg = _('parsing obsolete marker: unknown version %r') % diskversion |
|
453 | 453 | raise error.UnknownVersion(msg, version=diskversion) |
|
454 | return diskversion, formats[diskversion][0](data, off) | |
|
454 | return diskversion, formats[diskversion][0](data, off, stop) | |
|
455 | 455 | |
|
456 | 456 | def encodeheader(version=_fm0version): |
|
457 | 457 | return _pack('>B', version) |
General Comments 0
You need to be logged in to leave comments.
Login now