summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorJoyee Cheung <joyeec9h3@gmail.com>2017-12-25 05:00:24 +0800
committerAnatoli Papirovski <apapirovski@mac.com>2017-12-27 12:47:35 -0500
commit9ec700b073894ad54432db4c4b540e2b61b45325 (patch)
tree58335a78b8c5518a161715ab8aa2ef547042c3e7 /lib
parent03b8ac14e7cb535fc7a82188c666b5a2a38d00bc (diff)
downloadandroid-node-v8-9ec700b073894ad54432db4c4b540e2b61b45325.tar.gz
android-node-v8-9ec700b073894ad54432db4c4b540e2b61b45325.tar.bz2
android-node-v8-9ec700b073894ad54432db4c4b540e2b61b45325.zip
fs: validate path in fs.readFile
PR-URL: https://github.com/nodejs/node/pull/17852 Refs: https://github.com/nodejs/node/pull/17667 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/fs.js3
1 files changed, 3 insertions, 0 deletions
diff --git a/lib/fs.js b/lib/fs.js
index 7741e5838b..e41d0db033 100644
--- a/lib/fs.js
+++ b/lib/fs.js
@@ -389,6 +389,9 @@ fs.readFile = function(path, options, callback) {
req.oncomplete(null, path);
});
return;
+ } else if (typeof path !== 'string' && !(path instanceof Buffer)) {
+ throw new errors.TypeError('ERR_INVALID_ARG_TYPE', 'path',
+ ['string', 'Buffer', 'URL']);
}
binding.open(pathModule.toNamespacedPath(path),