Skip to content

writeUIntBE() method does not throw range error for 48bit #30420

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
arpadpall21 opened this issue Nov 12, 2019 · 0 comments
Closed

writeUIntBE() method does not throw range error for 48bit #30420

arpadpall21 opened this issue Nov 12, 2019 · 0 comments

Comments

@arpadpall21
Copy link

  • Version 13.1.0:
  • Platform 64-bit Windows 10:
  • Subsystem buffer:

The writeUIntBE() method does not throw a Range Error if we pass a higher than allowed 48bit unsigned integer value

var buf = Buffer.alloc(6);

buf.writeUIntBE(281474976710655, 0, 6);             // largest possible 48bit Unsigned Integer 
console.log( buf.readUIntBE(0, 6) );                // -> 281474976710655     // written value returned 
console.log( buf );                                 // -> <Buffer ff ff ff ff ff ff>

buf.writeUIntBE(281474976710656, 0, 6);             // no [ERR_OUT_OF_RANGE] thrown
console.log( buf.readUIntBE(0, 6) );                // -> 0                   // unexpected value returned  
    console.log( buf );                             // -> <Buffer 00 00 00 00 00 00>

buf.writeUIntBE(3000000000000000, 0, 6);            // no [ERR_OUT_OF_RANGE] thrown
console.log( buf.readUIntBE(0, 6) );                // -> 185250232893440     // unexpected value returned
    console.log( buf );                             // -> <Buffer a8 7b ee 53 80 00>
mscdex added a commit to mscdex/io.js that referenced this issue Nov 13, 2019
@Trott Trott closed this as completed in c14c476 Nov 30, 2019
addaleax pushed a commit that referenced this issue Nov 30, 2019
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>
targos pushed a commit that referenced this issue Dec 5, 2019
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>
MylesBorins pushed a commit that referenced this issue Dec 17, 2019
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>
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant