Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
fs: fix reads with pos > 4GB #21003
This fixes an issue in node 10 where all file reads with position > 4GB returns the data stored at position 0 in the file.
I would appreciate a quick review/release on this as this can have pretty serious consequences obvs (I just corrupted some local databases because of it).
A test case is available here: https://gist.github.com/mafintosh/1f9adf37bbc7ea05f1d2da6ab2d0f7a1
I'm happy to add it but not sure if we expect the tests to run on file systems that all support sparse files. Otherwise it would be a very slow test case.
Shouldn't it be possible to test this without large/sparse files by testing whether the large position argument reads from the current position or doesn't read anything? For example:
'use strict'; const fs = require('fs'); const assert = require('assert'); const fd = fs.openSync(__filename, 'r'); const nRead = fs.readSync(fd, Buffer.alloc(1), 0, 1, 900719925474099); assert.strictEqual(nRead, 0);
I think the test will need to be isolated (a separate