-
Notifications
You must be signed in to change notification settings - Fork 29.9k
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
buffer: inconsistencies in readIntBE() and readIntLE() #10515
Comments
/cc @nodejs/buffer |
If a value is required, but not provided, we should throw. |
The behaviour of signed int reads should be consistent with the other read functions, what do the unsigned variants do? I just tried, and they seem to have an offset that defaults to zero, which is what would I would expect if I was to guess (but not what is documented). |
Also, can you check whether when used with offsets larger than the buffer size, they are allowing reads of arbitrary memory? That could be the source of what looks "unpredictable", and could have security implications. |
@sam-github I might be misunderstanding you or expressing myself in an unclear way, but I agree that The problematic part is the way |
Agreed. I wish for a test for byteLength of zero, with and without noAssert, and that shows that that the readInt variants behave the same with or without noAssert. Ideally, they should throw, but if they do something else right now, that's worth writing a test for.... so that when we fix it we can doc it, change the test, and mark it semver-major. |
Looks like this issue is open and known, just need someone to write the patch + test? |
#11146 seems really close. Head over there and help push it over the finish line? |
The 'byteLength' argument should be required and of type 'number'. It should have a value between 1 and 6. This is a fix for issue: nodejs#10515
The documentation for
readIntLE()
andreadIntBE()
both indicate that the second argument (byteLength
) is required. However, both functions will seem to operate without abyteLength
provided. Unfortunately,byteLength
will default to0
in that case, which results in unpredictable behavior:Perhaps we should do one of the following?:
byteLength
default to1
rather than0
byteLength
is not providedbyteLength
, then you will get a result but there are no guarantees even about the return value typeThe text was updated successfully, but these errors were encountered: