From a96a5f5808845cc03babd957a78cd16a16478b7a Mon Sep 17 00:00:00 2001 From: cielavenir Date: Thu, 13 Aug 2020 01:53:55 +0900 Subject: [PATCH 1/3] fixed reading packed stream crc, fixing 7z reading written by apache commons compress --- py7zlib.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/py7zlib.py b/py7zlib.py index 00e84cf..e1a4631 100644 --- a/py7zlib.py +++ b/py7zlib.py @@ -270,7 +270,7 @@ def __init__(self, file): id = file.read(1) if id == PROPERTY_CRC: - self.crcs = [self._read64Bit(file) for x in xrange(self.numstreams)] + digests = UnpackDigests(file, self.numstreams) id = file.read(1) if id != PROPERTY_END: From cc3c75312193844fa5cc62395c4ac49d8c16aa19 Mon Sep 17 00:00:00 2001 From: cielavenir Date: Thu, 13 Aug 2020 01:54:58 +0900 Subject: [PATCH 2/3] substreamsinfo crc might not be provided --- py7zlib.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/py7zlib.py b/py7zlib.py index e1a4631..6b79b3c 100644 --- a/py7zlib.py +++ b/py7zlib.py @@ -1068,7 +1068,7 @@ def list(self, verbose=True, file=sys.stdout): for f in self.files: extra = (f.compressed and '%10d ' % (f.compressed)) or ' ' - file.write('%10d%s%.8x %s\n' % (f.size, extra, f.digest, f.filename)) + file.write('%10d%s%.8x %s\n' % (f.size, extra, f.digest or 0, f.filename)) if __name__ == '__main__': f = Archive7z(open('test.7z', 'rb')) From 9ef6072e0643d41efcb291b18f8912a248adedad Mon Sep 17 00:00:00 2001 From: cielavenir Date: Fri, 14 Aug 2020 00:14:30 +0900 Subject: [PATCH 3/3] Fix _read64Bit when leading byte is 0xff --- py7zlib.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/py7zlib.py b/py7zlib.py index 6b79b3c..da4c192 100644 --- a/py7zlib.py +++ b/py7zlib.py @@ -232,9 +232,13 @@ def _read64Bit(self, file): value = (bytes and reduce(lambda x, y: x << 8 | y, bytes)) or 0 highpart = b & (mask - 1) return value + (highpart << (i * 8)) - mask >>= 1 + bytes = array('B', file.read(8)) + bytes.reverse() + value = (bytes and reduce(lambda x, y: x << 8 | y, bytes)) or 0 + return value + def _readBoolean(self, file, count, checkall=0): if checkall: alldefined = file.read(1)