Skip to content

Commit f0d4392

Browse files
mscdextargos
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 053c179 commit f0d4392

3 files changed

Lines changed: 3 additions & 3 deletions

File tree

‎lib/internal/buffer.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -736,7 +736,7 @@ function writeUInt8(value, offset = 0) {
736736

737737
functionwriteUIntBE(value,offset,byteLength){
738738
if(byteLength===6)
739-
returnwriteU_Int48BE(this,value,offset,0,0xffffffffffffff);
739+
returnwriteU_Int48BE(this,value,offset,0,0xffffffffffff);
740740
if(byteLength===5)
741741
returnwriteU_Int40BE(this,value,offset,0,0xffffffffff);
742742
if(byteLength===3)

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

Lines 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(leti=1;i<6;i++){
216+
for(leti=1;i<=6;i++){
217217
['writeIntBE','writeIntLE'].forEach((fn)=>{
218218
constmin=-(2**(i*8-1));
219219
constmax=2**(i*8-1)-1;

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

Lines 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(leti=1;i<6;i++){
173+
for(leti=1;i<=6;i++){
174174
constrange=i<5 ? `= ${val-1}` : ` 2 ** ${i*8}`;
175175
constreceived=i>4 ?
176176
String(val).replace(/(\d)(?=(\d\d\d)+(?!\d))/g,'$1_') :

0 commit comments

Comments
 (0)