mirror of
https://github.com/nodejs/node.git
synced 2025-04-29 06:19:07 +00:00

Some checks are pending
Coverage Linux (without intl) / coverage-linux-without-intl (push) Waiting to run
Coverage Linux / coverage-linux (push) Waiting to run
Coverage Windows / coverage-windows (push) Waiting to run
Test and upload documentation to artifacts / build-docs (push) Waiting to run
Linters / lint-addon-docs (push) Waiting to run
Linters / lint-cpp (push) Waiting to run
Linters / format-cpp (push) Waiting to run
Linters / lint-js-and-md (push) Waiting to run
Linters / lint-py (push) Waiting to run
Linters / lint-yaml (push) Waiting to run
Linters / lint-sh (push) Waiting to run
Linters / lint-codeowners (push) Waiting to run
Linters / lint-pr-url (push) Waiting to run
Linters / lint-readme (push) Waiting to run
Notify on Push / Notify on Force Push on `main` (push) Waiting to run
Notify on Push / Notify on Push on `main` that lacks metadata (push) Waiting to run
Scorecard supply-chain security / Scorecard analysis (push) Waiting to run
Fixes: https://github.com/nodejs/node/issues/48412 PR-URL: https://github.com/nodejs/node/pull/52100 Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
30 lines
809 B
JavaScript
30 lines
809 B
JavaScript
'use strict';
|
|
require('../common');
|
|
|
|
// This test ensures that zlib throws a RangeError if the final buffer needs to
|
|
// be larger than kMaxLength and concatenation fails.
|
|
// https://github.com/nodejs/node/pull/1811
|
|
|
|
const assert = require('assert');
|
|
|
|
// Change kMaxLength for zlib to trigger the error without having to allocate
|
|
// large Buffers.
|
|
const buffer = require('buffer');
|
|
const oldkMaxLength = buffer.kMaxLength;
|
|
buffer.kMaxLength = 64;
|
|
const zlib = require('zlib');
|
|
buffer.kMaxLength = oldkMaxLength;
|
|
|
|
// "a".repeat(128), compressed using zstd.
|
|
const encoded = Buffer.from('KLUv/SCARQAAEGFhAQA7BVg=', 'base64');
|
|
|
|
// Async
|
|
zlib.zstdDecompress(encoded, function(err) {
|
|
assert.ok(err instanceof RangeError);
|
|
});
|
|
|
|
// Sync
|
|
assert.throws(function() {
|
|
zlib.zstdDecompressSync(encoded);
|
|
}, RangeError);
|