GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — src: expose `BROTLI_DECODER_ERROR_FORMAT_BLOCK_SWITCH` · nodejs/node@b5f4152

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • src
    • node_zlib.cc
  • test/parallel
    • test-zlib-invalid-input.js
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎src/node_zlib.cc‎

Copy file name to clipboardExpand all lines: src/node_zlib.cc
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2150,6 +2150,7 @@ void DefineZlibConstants(Local<Object> target) {
21502150
NODE_DEFINE_CONSTANT(target, BROTLI_DECODER_ERROR_FORMAT_PADDING_1);
21512151
NODE_DEFINE_CONSTANT(target, BROTLI_DECODER_ERROR_FORMAT_PADDING_2);
21522152
NODE_DEFINE_CONSTANT(target, BROTLI_DECODER_ERROR_FORMAT_DISTANCE);
2153+
NODE_DEFINE_CONSTANT(target, BROTLI_DECODER_ERROR_FORMAT_BLOCK_SWITCH);
21532154
NODE_DEFINE_CONSTANT(target, BROTLI_DECODER_ERROR_DICTIONARY_NOT_SET);
21542155
NODE_DEFINE_CONSTANT(target, BROTLI_DECODER_ERROR_INVALID_ARGUMENTS);
21552156
NODE_DEFINE_CONSTANT(target, BROTLI_DECODER_ERROR_ALLOC_CONTEXT_MODES);
Collapse file

‎test/parallel/test-zlib-invalid-input.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-zlib-invalid-input.js
+27Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,33 @@ Object.defineProperty(spoofedLength, 'byteLength', { get: () => 5000 });
8989
deflate.close();
9090
}
9191

92+
{
93+
// A block switch is invalid when the stream declares only one block type.
94+
const invalidBlockSwitch = Buffer.from(
95+
'200010414141fcffff07002228f00b60f7f41f000000',
96+
'hex',
97+
);
98+
const expectedError = {
99+
code: 'ERR__ERROR_FORMAT_BLOCK_SWITCH',
100+
errno: zlib.constants.BROTLI_DECODER_ERROR_FORMAT_BLOCK_SWITCH,
101+
};
102+
103+
assert.strictEqual(expectedError.errno, -17);
104+
assert.throws(
105+
() => zlib.brotliDecompressSync(invalidBlockSwitch),
106+
expectedError,
107+
);
108+
109+
const brotli = zlib.createBrotliDecompress();
110+
brotli.resume();
111+
brotli.on('error', common.expectsError(expectedError));
112+
brotli.on('end', common.mustNotCall());
113+
for (let i = 0; i < invalidBlockSwitch.length; i++) {
114+
brotli.write(invalidBlockSwitch.subarray(i, i + 1));
115+
}
116+
brotli.end();
117+
}
118+
92119
unzips.forEach(common.mustCall((uz, i) => {
93120
uz.on('error', common.mustCall());
94121
uz.on('end', common.mustNotCall());

0 commit comments

Comments
0 (0)
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.