Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 63eb4fe

Browse filesBrowse files
mscdexaddaleax
authored andcommitted
buffer: fix 6-byte writeUIntBE() range check
Fixes: #30420 PR-URL: #30459 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: David Carlier <devnexen@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent f37450f commit 63eb4fe
Copy full SHA for 63eb4fe

File tree

Expand file treeCollapse file tree

3 files changed

+3
-3
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

3 files changed

+3
-3
lines changed
Open diff view settings
Collapse file

‎lib/internal/buffer.js‎

Copy file name to clipboardExpand all lines: lib/internal/buffer.js
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -736,7 +736,7 @@ function writeUInt8(value, offset = 0) {
736736

737737
function writeUIntBE(value, offset, byteLength) {
738738
if (byteLength === 6)
739-
return writeU_Int48BE(this, value, offset, 0, 0xffffffffffffff);
739+
return writeU_Int48BE(this, value, offset, 0, 0xffffffffffff);
740740
if (byteLength === 5)
741741
return writeU_Int40BE(this, value, offset, 0, 0xffffffffff);
742742
if (byteLength === 3)
Collapse file

‎test/parallel/test-buffer-writeint.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-buffer-writeint.js
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ const errorOutOfBounds = common.expectsError({
213213
});
214214

215215
// Test 1 to 6 bytes.
216-
for (let i = 1; i < 6; i++) {
216+
for (let i = 1; i <= 6; i++) {
217217
['writeIntBE', 'writeIntLE'].forEach((fn) => {
218218
const min = -(2 ** (i * 8 - 1));
219219
const max = 2 ** (i * 8 - 1) - 1;
Collapse file

‎test/parallel/test-buffer-writeuint.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-buffer-writeuint.js
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ const assert = require('assert');
170170
});
171171

172172
// Test 1 to 6 bytes.
173-
for (let i = 1; i < 6; i++) {
173+
for (let i = 1; i <= 6; i++) {
174174
const range = i < 5 ? `= ${val - 1}` : ` 2 ** ${i * 8}`;
175175
const received = i > 4 ?
176176
String(val).replace(/(\d)(?=(\d\d\d)+(?!\d))/g, '$1_') :

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.