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

buf.readUInt32BE() reports a "write" error on out-of-bounds, instead of a "read" error #29097

Closed
sam-github opened this issue Aug 12, 2019 · 0 comments

Comments

@sam-github
Copy link
Contributor

  • Version: 12.x
  • Platform: any?
  • Subsystem: Buffer

See below. It seems like the error should mention reading, not writing?

It could be that internally, a write is done, or even that this is no big deal and should be closed with "as expected/good enough" -- though in a large system it might be less obvious what is wrong than in the repl snippet below.

> Buffer.from([2,3,4]).readUInt32BE()
Thrown:
RangeError [ERR_BUFFER_OUT_OF_BOUNDS]: Attempt to write outside buffer bounds
    at boundsError (internal/buffer.js:70:11)
    at Buffer.readUInt32BE (internal/buffer.js:295:5)
@Trott Trott closed this as completed in a352a71 Aug 14, 2019
targos pushed a commit that referenced this issue Aug 19, 2019
This commit changes the default message used by
ERR_BUFFER_OUT_OF_BOUNDS. Previously, the default
message implied that the problematic was always a
write, which is not accurate.

PR-URL: #29098
Fixes: #29097
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Sam Roberts <vieuxtech@gmail.com>
Reviewed-By: Jiawen Geng <technicalcute@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Yongsheng Zhang <zyszys98@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
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