Skip to content

Commit

Permalink
don't mark identifier chunks as skippable
Browse files Browse the repository at this point in the history
  • Loading branch information
jtolio committed Feb 10, 2013
1 parent 1c0505a commit 2190744
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions snappy.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
_UNCOMPRESSED_CHUNK = 0x01
_IDENTIFIER_CHUNK = 0xff
_RESERVED_UNSKIPPABLE = (0x02, 0x80) # chunk ranges are [inclusive, exclusive)
_RESERVED_SKIPPABLE = (0x80, 0x100)
_RESERVED_SKIPPABLE = (0x80, 0xff)

# the minimum percent of bytes compression must save to be enabled in automatic
# mode
Expand Down Expand Up @@ -198,13 +198,15 @@ def decompress(self, data):
if len(self._buf) < 4 + size:
return b"".join(uncompressed)
chunk, self._buf = self._buf[4:4 + size], self._buf[4 + size:]
if chunk_type == _IDENTIFIER_CHUNK and chunk != _STREAM_IDENTIFIER:
raise UncompressError("stream has invalid snappy identifier")
if chunk_type == _IDENTIFIER_CHUNK:
if chunk != _STREAM_IDENTIFIER:
raise UncompressError(
"stream has invalid snappy identifier")
continue
if (_RESERVED_SKIPPABLE[0] <= chunk_type and
chunk_type < _RESERVED_SKIPPABLE[1]):
continue
if chunk_type not in (_COMPRESSED_CHUNK, _UNCOMPRESSED_CHUNK):
raise UncompressError("internal error")
assert chunk_type in (_COMPRESSED_CHUNK, _UNCOMPRESSED_CHUNK)
crc, chunk = chunk[:4], chunk[4:]
if chunk_type == _COMPRESSED_CHUNK:
chunk = _uncompress(chunk)
Expand Down

0 comments on commit 2190744

Please sign in to comment.