maennchen / ZipStream-PHP

:floppy_disk: PHP ZIP Streaming Library

Home Page:https://maennchen.dev/ZipStream-PHP/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Wrong general purpose bit for zero header?

pieterdt opened this issue · comments

Description of the problem

While trying to solve a problem that has been reported in the past (osx extraction issues with the default archive utility), I was going through the file format spec and the code.

While it doesn't seem to have much impact on my problem, I do wonder the following:

In the spec about the general purpose bit flag it is mentioned that bit 3 is the bit to indicate that crc32, compressed and uncompressed sizes are going to be set to 0.

Bit 3: If this bit is set, the fields crc-32, compressed
size and uncompressed size are set to zero in the
local header. The correct values are put in the
data descriptor immediately following the compressed
data. (Note: PKZIP version 2.04g for DOS only
recognizes this bit for method 8 compression, newer
versions of PKZIP recognize this bit for any
compression method.)

However, in the code this bit seems to be set on bit 4:

const BIT_ZERO_HEADER = 0x0008;

Am I reading this wrong?

Informations

  • ZipStream-PHP version: 2.0.1
  • PHP version: 7.4

First Google result for the cited spec is this, so I'll take this as a reference: https://github.com/pocoproject/poco/blob/master/Zip/doc/ZIP%20Spec.txt

As you can see a few paragraphs above the cited text, counting of bits starts at 0, so "bit 3" is 2^3 or 0x08.

I have no deeper knowledge of the ZIP spec, but this looks correct to me.

my bad, didn't even consider that counting would start at 0.

Thanks!