Skip to content

Commit 571433a

Browse files
committed
Allow null-terminated octal file size byte (POSIX tarball variant)
1 parent 4d7385e commit 571433a

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
repos:
33
- repo: https://github.com/psf/black
4-
rev: 21.6b0
4+
rev: 23.3.0
55
hooks:
66
- id: black
77
language_version: python3.8

src/range_streams/codecs/tar/stream.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,10 @@ def read_file_size(self, start_pos_offset: int = 0) -> int:
184184
else:
185185
self.add(file_size_rng)
186186
file_size_b = self.active_range_response.read()
187-
file_size = int(file_size_b, 8) # convert octal number from bitstring
187+
try:
188+
file_size = int(file_size_b, 8) # convert octal number from bitstring
189+
except ValueError:
190+
file_size = int(file_size_b.rstrip(b"\x00"), 8) # may be null-terminated
188191
return file_size
189192

190193
def add_file_ranges(self):

0 commit comments

Comments
 (0)