-
Notifications
You must be signed in to change notification settings - Fork 7.3k
fs.readSync(0, new Buffer(0), 0, 0, 0) throws Error: Offset is out of bounds #5685
Comments
fs.readSync(0, new Buffer(1), 0, 0, 0) fails with Error: ESPIPE, invalid seek on stdin, but a real empty file works and returns 0. |
Just hit this issue as well. |
Some notes: http://pubs.opengroup.org/onlinepubs/9699919799/functions/read.html is the POSIX |
Working as intended. Please see discussion in #5888. |
Ah, ok, so the issue in the OP is still an issue, though. |
Yeah, so:
|
Why wouldn't offset <= buffer_length be sufficient?
|
That sounds right to me, but I just try not to make assertions about safety in the face of overflow without thinking very carefully :) |
@trevnorris ... any further thoughts on this one? |
@jasnell If it hasn't been fixed yet then should be easy to do. Just need to change the range checks, and return early if the operation is a noop. |
fs.readSync() reports an error under Node <= 0.12.x when reading 0 bytes from a 0-byte length buffer. See nodejs/node-v0.x-archive#5685 Fixes #2
Reading 0 bytes into a 0 sized buffer should be a no-op to make it more like read(2):
The text was updated successfully, but these errors were encountered: