diff options
author | Julian Duque <julianduquej@gmail.com> | 2015-04-28 15:15:41 -0500 |
---|---|---|
committer | Julian Duque <julianduquej@gmail.com> | 2015-04-28 17:44:37 -0500 |
commit | f9c681cf627caf89b5c7eaacf154fdefb747c7e0 (patch) | |
tree | 24c8bd21b7e5acdb109bcf93aa3da205e9247daa /src/node_file.cc | |
parent | 509b59ea7c815a27c623773cee6480667f68293c (diff) | |
download | node-new-f9c681cf627caf89b5c7eaacf154fdefb747c7e0.tar.gz |
fs: validate fd on fs.write
PR-URL: #1553
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Diffstat (limited to 'src/node_file.cc')
-rw-r--r-- | src/node_file.cc | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/node_file.cc b/src/node_file.cc index d466acc65a..095710ef37 100644 --- a/src/node_file.cc +++ b/src/node_file.cc @@ -779,7 +779,9 @@ static void Open(const FunctionCallbackInfo<Value>& args) { static void WriteBuffer(const FunctionCallbackInfo<Value>& args) { Environment* env = Environment::GetCurrent(args); - CHECK(args[0]->IsInt32()); + if (!args[0]->IsInt32()) + return env->ThrowTypeError("First argument must be file descriptor"); + CHECK(Buffer::HasInstance(args[1])); int fd = args[0]->Int32Value(); |