-
-
Notifications
You must be signed in to change notification settings - Fork 33.1k
Closed
Closed
Copy link
Labels
confirmed-bugIssues with confirmed bugs.Issues with confirmed bugs.fsIssues and PRs related to the fs subsystem / file system.Issues and PRs related to the fs subsystem / file system.
Description
fs.ftruncate and fd.ftruncateSync both silently ignore negative offsets:
Line 840 in 2cfdf28
len = MathMax(0, len); |
This didn't always do behave like this.. looks like it was introduced in 8974df1
What steps will reproduce the bug?
var fs = require("fs");
var fd = fs.openSync("f", 'w+');
console.log(fs.ftruncateSync(fd, -99));
What is the expected behavior?
The ftruncate POSIX function is described as returning EINVAL when given a negative offset:
https://linux.die.net/man/2/ftruncate
In emscripten we emulate a POSIX environment on top of the Web and on top of node and expect ftruncate to fail in the same way.
We can obviously add a check to our code as a workaround but this does seem like a bug in node.
What do you see instead?
Silently assumed 0
length is what the caller really wants.
Metadata
Metadata
Assignees
Labels
confirmed-bugIssues with confirmed bugs.Issues with confirmed bugs.fsIssues and PRs related to the fs subsystem / file system.Issues and PRs related to the fs subsystem / file system.