diff options
author | cjihrig <cjihrig@gmail.com> | 2018-06-05 09:12:19 -0400 |
---|---|---|
committer | cjihrig <cjihrig@gmail.com> | 2018-06-07 09:24:37 -0400 |
commit | 5012587b1aa228943435fb709887ae2bf17ec283 (patch) | |
tree | 5613138d0fe881e8c03046d98d81df3bc3760b91 /test | |
parent | c9d9bf1cb06a9f490669b107a28eb9c628aeeb23 (diff) | |
download | android-node-v8-5012587b1aa228943435fb709887ae2bf17ec283.tar.gz android-node-v8-5012587b1aa228943435fb709887ae2bf17ec283.tar.bz2 android-node-v8-5012587b1aa228943435fb709887ae2bf17ec283.zip |
fs: fix promises reads with pos > 4GB
PR-URL: https://github.com/nodejs/node/pull/21148
Fixes: https://github.com/nodejs/node/issues/21121
Refs: https://github.com/nodejs/node/pull/21003
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Reviewed-By: Ujjwal Sharma <usharma1998@gmail.com>
Diffstat (limited to 'test')
-rw-r--r-- | test/parallel/test-fs-promises-file-handle-read.js | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/test/parallel/test-fs-promises-file-handle-read.js b/test/parallel/test-fs-promises-file-handle-read.js index a397b0e260..621e63c075 100644 --- a/test/parallel/test-fs-promises-file-handle-read.js +++ b/test/parallel/test-fs-promises-file-handle-read.js @@ -8,6 +8,7 @@ const common = require('../common'); const fs = require('fs'); const { open } = fs.promises; const path = require('path'); +const fixtures = require('../common/fixtures'); const tmpdir = require('../common/tmpdir'); const assert = require('assert'); const tmpDir = tmpdir.path; @@ -40,6 +41,19 @@ async function validateEmptyRead() { assert.deepStrictEqual(buffer.length, readAsyncHandle.bytesRead); } +async function validateLargeRead() { + // Reading beyond file length (3 in this case) should return no data. + // This is a test for a bug where reads > uint32 would return data + // from the current position in the file. + const filePath = fixtures.path('x.txt'); + const fileHandle = await open(filePath, 'r'); + const pos = 0xffffffff + 1; // max-uint32 + 1 + const readHandle = await fileHandle.read(Buffer.alloc(1), 0, 1, pos); + + assert.strictEqual(readHandle.bytesRead, 0); +} + validateRead() .then(validateEmptyRead) + .then(validateLargeRead) .then(common.mustCall()); |