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

Inaccurate boundary validation in Buffer.prototype.writeUIntBE/LE(value,offset,byteLength) #3497

Closed
kotarondo opened this issue Oct 23, 2015 · 2 comments
Labels
buffer Issues and PRs related to the buffer subsystem.

Comments

@kotarondo
Copy link

The expression
new Buffer(1).writeUIntBE(0x100,0,1)
should throw an out-of-bounds error, but it does not.

In the source code, value validation is coded as follows:
checkInt(this, value, offset, byteLength, Math.pow(2, 8 * byteLength), 0);

Here, max value should be Math.pow(2, 8 * byteLength) - 1 ?

@Fishrock123 Fishrock123 added the buffer Issues and PRs related to the buffer subsystem. label Oct 23, 2015
@Fishrock123
Copy link
Contributor

cc @trevnorris

@trevnorris
Copy link
Contributor

yup. you're correct.

trevnorris added a commit to trevnorris/node that referenced this issue Oct 26, 2015
trevnorris added a commit that referenced this issue Oct 26, 2015
Fixes: #3497
PR-URL: #3500
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
trevnorris added a commit that referenced this issue Oct 28, 2015
Fixes: #3497
PR-URL: #3500
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
trevnorris added a commit that referenced this issue Oct 29, 2015
Fixes: #3497
PR-URL: #3500
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
buffer Issues and PRs related to the buffer subsystem.
Projects
None yet
Development

No branches or pull requests

3 participants