Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

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

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 <[email protected]>
Reviewed-By: David Carlier <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Ruben Bridgewater <[email protected]>
Reviewed-By: James M Snell <[email protected]>
targos pushed a commit that referenced this issue Dec 5, 2019
Fixes: #30420

PR-URL: #30459
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: David Carlier <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Ruben Bridgewater <[email protected]>
Reviewed-By: James M Snell <[email protected]>
MylesBorins pushed a commit that referenced this issue Dec 17, 2019
Fixes: #30420

PR-URL: #30459
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: David Carlier <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Ruben Bridgewater <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant