Lars Schneider
Lars Schneider

Reputation: 5692

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?

Upvotes: 2

Views: 188

Answers (1)

Mark Adler
Mark Adler

Reputation: 112502

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.

Upvotes: 2

Related Questions