summaryrefslogtreecommitdiff
path: root/test/parallel/test-fs-read.js
diff options
context:
space:
mode:
authorMathias Buus <mathiasbuus@gmail.com>2018-05-28 19:00:42 +0200
committerMathias Buus <mathiasbuus@gmail.com>2018-05-29 13:14:19 +0200
commit1dae52634851c477c0cf39ccfd482c33f9243475 (patch)
tree260088e8d8d922f714d9c7b24bcffa4159184b91 /test/parallel/test-fs-read.js
parent9f4bf4ca43bc40f68a05c87081a9bae8736515b1 (diff)
downloadandroid-node-v8-1dae52634851c477c0cf39ccfd482c33f9243475.tar.gz
android-node-v8-1dae52634851c477c0cf39ccfd482c33f9243475.tar.bz2
android-node-v8-1dae52634851c477c0cf39ccfd482c33f9243475.zip
fs: fix reads with pos > 4GB
PR-URL: https://github.com/nodejs/node/pull/21003 Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Diffstat (limited to 'test/parallel/test-fs-read.js')
-rw-r--r--test/parallel/test-fs-read.js15
1 files changed, 15 insertions, 0 deletions
diff --git a/test/parallel/test-fs-read.js b/test/parallel/test-fs-read.js
index f69937b3be..864876537c 100644
--- a/test/parallel/test-fs-read.js
+++ b/test/parallel/test-fs-read.js
@@ -53,3 +53,18 @@ test(Buffer.allocUnsafe(expected.length),
test(new Uint8Array(expected.length),
new Uint8Array(expected.length),
Uint8Array.from(expected));
+
+{
+ // 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 fd = fs.openSync(filepath, 'r');
+ const pos = 0xffffffff + 1; // max-uint32 + 1
+ const nRead = fs.readSync(fd, Buffer.alloc(1), 0, 1, pos);
+ assert.strictEqual(nRead, 0);
+
+ fs.read(fd, Buffer.alloc(1), 0, 1, pos, common.mustCall((err, nRead) => {
+ assert.ifError(err);
+ assert.strictEqual(nRead, 0);
+ }));
+}