Skip to content

Commit

Permalink
Added node patch for fs.readFile[Sync]() problem with reading /dev/stdin
Browse files Browse the repository at this point in the history
  • Loading branch information
dn0 committed Dec 16, 2017
1 parent b90ebff commit e13350c
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions node.js/Patches/node-1074-fix-readfile-stdin.diff
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
diff -Naur node-v0.10.26.old/lib/fs.js node-v0.10.26/lib/fs.js
--- node-v0.10.26.old/lib/fs.js 2014-02-19 00:34:29.000000000 +0100
+++ node-v0.10.26/lib/fs.js 2017-12-16 00:54:39.000000000 +0100
@@ -209,7 +209,7 @@

fs.fstat(fd, function(er, st) {
if (er) return callback(er);
- size = st.size;
+ size = st.isFile() ? st.size : 0;
if (size === 0) {
// the kernel lies about many files.
// Go ahead and try to read some bytes.
@@ -283,10 +283,12 @@
var flag = options.flag || 'r';
var fd = fs.openSync(path, flag, 438 /*=0666*/);

+ var st;
var size;
var threw = true;
try {
- size = fs.fstatSync(fd).size;
+ st = fs.fstatSync(fd);
+ size = st.isFile() ? st.size : 0;
threw = false;
} finally {
if (threw) fs.closeSync(fd);

0 comments on commit e13350c

Please sign in to comment.