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

Revert "Make a noble effort at setting OS_CODE correctly." #12404

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 14 additions & 30 deletions deps/zlib/zutil.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,38 +100,28 @@ extern z_const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
#endif

#ifdef AMIGA
# define OS_CODE 1
# define OS_CODE 0x01
#endif

#if defined(VAXC) || defined(VMS)
# define OS_CODE 2
# define OS_CODE 0x02
# define F_OPEN(name, mode) \
fopen((name), (mode), "mbc=60", "ctx=stm", "rfm=fix", "mrs=512")
#endif

#ifdef __370__
# if __TARGET_LIB__ < 0x20000000
# define OS_CODE 4
# elif __TARGET_LIB__ < 0x40000000
# define OS_CODE 11
# else
# define OS_CODE 8
# endif
#endif

#if defined(ATARI) || defined(atarist)
# define OS_CODE 5
# define OS_CODE 0x05
#endif

#ifdef OS2
# define OS_CODE 6
# define OS_CODE 0x06
# if defined(M_I86) && !defined(Z_SOLO)
# include <malloc.h>
# endif
#endif

#if defined(MACOS) || defined(TARGET_OS_MAC)
# define OS_CODE 7
# define OS_CODE 0x07
# ifndef Z_SOLO
# if defined(__MWERKS__) && __dest_os != __be_os && __dest_os != __win32_os
# include <unix.h> /* for fdopen */
Expand All @@ -143,24 +133,18 @@ extern z_const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
# endif
#endif

#ifdef __acorn
# define OS_CODE 13
#ifdef TOPS20
# define OS_CODE 0x0a
#endif

#if defined(WIN32) && !defined(__CYGWIN__)
# define OS_CODE 10
#endif

#ifdef _BEOS_
# define OS_CODE 16
#endif

#ifdef __TOS_OS400__
# define OS_CODE 18
#ifdef WIN32
# ifndef __CYGWIN__ /* Cygwin is Unix, not Win32 */
# define OS_CODE 0x0b
# endif
#endif

#ifdef __APPLE__
# define OS_CODE 19
#ifdef __50SERIES /* Prime/PRIMOS */
# define OS_CODE 0x0f
#endif

#if defined(_BEOS_) || defined(RISCOS)
Expand Down Expand Up @@ -195,7 +179,7 @@ extern z_const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
/* common defaults */

#ifndef OS_CODE
# define OS_CODE 3 /* assume Unix */
# define OS_CODE 0x03 /* assume Unix */
#endif

#ifndef F_OPEN
Expand Down
22 changes: 22 additions & 0 deletions test/parallel/test-zlib-oscode.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
'use strict';

const common = require('../common');

// Assert that the zlib output on MacOS and Linux is identical to what it was
// before the zlib 1.2.11 update. The change was in an unused 'OS code' in the
// header, so is not dependent on the size or content of the data encrypted.
// The test doesn't apply to non-MacOS/Linux platforms, they already had unique
// OS codes prior to the zlib update.

if (process.platform !== 'linux' && process.platform !== 'darwin')
return common.skip('test applies only to Mac and Linux');

const assert = require('assert');
const zlib = require('zlib');

const expected = '1f8b0800000000000003ab00008316dc8c01000000';
const options = {strategy: zlib.Z_DEFAULT_STRATEGY};

zlib.gzip('x', options, common.mustCall(function(err, compressed) {
assert.strictEqual(compressed.toString('hex'), expected);
}));