Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Different 10th byte gzip header between zlib and pako on Mac OS 13 #280

Open
ciphrd opened this issue Sep 9, 2023 · 1 comment
Open

Comments

@ciphrd
Copy link

ciphrd commented Sep 9, 2023

Overview

The 10th byte of the gzip header is different between pako and zlib on Mac OS 13.5.1 (M2 chip)—untested on other OSs. Looking at the RFC 1952 / 2.3.1, pako seems to follow the spec by producing 0x03 as the 10th byte, while zlib produces 0x13. It seems weird as 0x13 doesn't refer to anything in the RFC spec, so Pako seems to follow the spec nicely here.

         OS (Operating System)
            This identifies the type of file system on which compression
            took place.  This may be useful in determining end-of-line
            convention for text files.  The currently defined values are
            as follows:

                 0 - FAT filesystem (MS-DOS, OS/2, NT/Win32)
                 1 - Amiga
                 2 - VMS (or OpenVMS)
                 3 - Unix
                 4 - VM/CMS
                 5 - Atari TOS
                 6 - HPFS filesystem (OS/2, NT)
                 7 - Macintosh
                 8 - Z-System
                 9 - CP/M
                10 - TOPS-20
                11 - NTFS filesystem (NT)
                12 - QDOS
                13 - Acorn RISCOS
               255 - unknown

I realise this isn't a Pako-related issue per-say, however I'm really curious as to why zlib would set the 10th byte to 0x13, so if eventually I get an answer to that or if anyone has it it'd be interesting to have it for posterity.

Minimal reproducing example

  • node -v: 18.17.1
  • pako: 2.1.0
  • OS: Mac OS 13.5.1 (22G90); M2 chip
const pako = require("pako")
const zlib = require("node:zlib")

const input = Buffer.from(`random`)

const zlibZip = zlib.gzipSync(input) // 1f8b08000000000000132b4acc4bc9cf0500d5da3b1606000000
const pakoZip = pako.gzip(input)     // 1f8b08000000000000032b4acc4bc9cf0500d5da3b1606000000
                                     //                   ↑
@ciphrd ciphrd changed the title Different 10th byte gzip header between zlib and pako; resulting in ERR_CONTENT_DECODING_FAILED when serving over http Different 10th byte gzip header between zlib and pako Sep 9, 2023
@ciphrd
Copy link
Author

ciphrd commented Sep 9, 2023

Linking this issue on the zlib repo which is related: madler/zlib#320

@ciphrd ciphrd changed the title Different 10th byte gzip header between zlib and pako Different 10th byte gzip header between zlib and pako on Mac OS 13 Sep 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant