compressiongzipdeflate

Valid gzip file contains a large block of NULL bytes - why?


I have a tar.gz file which contains large blocks of NULL bytes (>1kb). The archive seems to be valid (checked via gzip -t <file-name>) and extraction works properly without issues.

The NULL byte blocks are somewhat in the middle of the file. Therefore, I don't think this is related to padding.

Is this expected? What would cause gzip to write this many NULL bytes?


Solution

  • A very long sequence of the same byte repeated can result in the output being a sequence of zero bytes. Though there will be about 1/1000th as many zero bytes in the compressed output as there are repeated bytes in the input.