diff options
author | Michael J. Bishop <mbtyke@gmail.com> | 2013-09-17 13:08:02 -0400 |
---|---|---|
committer | Michael J. Bishop <mbtyke@gmail.com> | 2013-09-17 13:08:02 -0400 |
commit | 8c867e3a4646dadf6922907543103ccf9a11fd75 (patch) | |
tree | ae87d513826db36774618fc9c7c7833f2893c60c /src/library_fs.js | |
parent | c72022ee3788281dd764782eb51395e322efb1bc (diff) |
Fixes in pread()
The bug occurs when pread() doesn't return 0 when asked to read an
offset beyond its buffer.
This behavior is explicitly documented at:
http://pubs.opengroup.org/onlinepubs/000095399/functions/read.html
> If the starting position is at or after the end-of-file, 0
> shall be returned
Diffstat (limited to 'src/library_fs.js')
-rw-r--r-- | src/library_fs.js | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/src/library_fs.js b/src/library_fs.js index 8bf0a83a..84a5245b 100644 --- a/src/library_fs.js +++ b/src/library_fs.js @@ -1367,7 +1367,10 @@ mergeInto(LibraryManager.library, { throw new FS.ErrnoError(ERRNO_CODES.EIO); } var contents = stream.node.contents; + if (position >= contents.length) + return 0; var size = Math.min(contents.length - position, length); + assert(size >= 0); if (contents.slice) { // normal array for (var i = 0; i < size; i++) { buffer[offset + i] = contents[position + i]; |