php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #80944 gzencode() sets a strange OS byte on Windows
Submitted: 2021-04-08 23:53 UTC Modified: 2021-04-09 11:14 UTC
From: christoph at burschka dot de Assigned: cmb (profile)
Status: Not a bug Package: Zlib related
PHP Version: 8.0.3 OS: Windows
Private report: No CVE-ID: None
 [2021-04-08 23:53 UTC] christoph at burschka dot de
Description:
------------
The tenth byte of a gzip file identifies (in theory) the OS or file system on which the file was compressed.

Running the test script on Linux produces a file where the byte is 0x03.
On Windows, we get a somewhat strange value of 0x0A. (Meanwhile, the GnuWin utility on Windows set this byte to 0x0B for NT, while the gzip utility in Git Bash for Windows uses 0x03 as if it was Linux.)

The standards document (RFC-1952) says that 0x0A is "TOPS-20", and sure enough - running the `file` utility on the resulting file shows: "test1.gz: gzip compressed data, from TOPS/20".

I'm not sure if I can call this a bug, since it doesn't really matter in practice what gets written there (for example writing the same value on all platforms would be understandable), but it seems odd that we *do* get a platform-specific value, and it is for a different, long-dead platform.

Test script:
---------------
<?php

file_put_contents('test1.gz', gzencode('Hello world'));

?>


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2021-04-09 11:14 UTC] cmb@php.net
-Status: Open +Status: Not a bug -Assigned To: +Assigned To: cmb
 [2021-04-09 11:14 UTC] cmb@php.net
I agree that this is a bug, but the maintainer of zlib thinks
otherwise[1].  If you like feel free to bring that up with them.

Anyhow, not a bug on the PHP side.

[1] <https://github.com/madler/zlib/commit/ce12c5cd00628bf8f680c98123a369974d32df15#r31590394>
 
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Wed Sep 22 12:03:38 2021 UTC