src: validate args length in Access and Close

This is a follow-up of https://github.com/nodejs/node/pull/17914. When
Access and Close functions are called in Sync mode, the number of items
in args is validated. These are the only two places in this file where
this validation doesn't take place.

PR-URL: https://github.com/nodejs/node/pull/18203
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
Sakthipriyan Vairamani (thefourtheye) 2018-01-17 12:22:59 +05:30 committed by Ruben Bridgewater
parent 11a26e1b2e
commit 2a61ce5996
No known key found for this signature in database
GPG Key ID: F07496B3EB3C1762

View File

@ -403,6 +403,7 @@ void Access(const FunctionCallbackInfo<Value>& args) {
AsyncCall(env, args, "access", UTF8, AfterNoArgs,
uv_fs_access, *path, mode);
} else { // access(path, mode, undefined, ctx)
CHECK_EQ(args.Length(), 4);
fs_req_wrap req_wrap;
SyncCall(env, args[3], &req_wrap, "access", uv_fs_access, *path, mode);
}
@ -424,6 +425,7 @@ void Close(const FunctionCallbackInfo<Value>& args) {
AsyncCall(env, args, "close", UTF8, AfterNoArgs,
uv_fs_close, fd);
} else { // close(fd, undefined, ctx)
CHECK_EQ(args.Length(), 3);
fs_req_wrap req_wrap;
SyncCall(env, args[2], &req_wrap, "close", uv_fs_close, fd);
}