Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fs: ensure nullCheck() callback is a function #887

Closed
wants to merge 1 commit into from
Closed

fs: ensure nullCheck() callback is a function #887

wants to merge 1 commit into from

Conversation

cjihrig
Copy link
Contributor

@cjihrig cjihrig commented Feb 19, 2015

Currently, nullCheck() will attempt to invoke any truthy value as a function if the path argument contains a null character. This commit validates that the callback is actually a function before trying to invoke it. fs.access() was vulnerable to this bug, as nullCheck() was called prior to type checking its
callback.

@@ -57,6 +57,10 @@ assert.throws(function() {
fs.access(__filename, fs.F_OK);
}, /callback must be a function/);

assert.throws(function() {
fs.access('foo\u0000bar', fs.F_OK, {});
}, /callback must be a function/);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

test/parallel/test-fs-null-bytes.js is arguably a better place for this but I'll leave that up to you.

@bnoordhuis
Copy link
Member

LGTM with a suggestion.

Currently, nullCheck() will attempt to invoke any truthy value
as a function if the path argument contains a null character.
This commit validates that the callback is actually a function
before trying to invoke it. fs.access() was vulnerable to this
bug, as nullCheck() was called prior to type checking its
callback.
cjihrig added a commit that referenced this pull request Feb 19, 2015
Currently, nullCheck() will attempt to invoke any truthy value
as a function if the path argument contains a null character.
This commit validates that the callback is actually a function
before trying to invoke it. fs.access() was vulnerable to this
bug, as nullCheck() was called prior to type checking its
callback.

PR-URL: #887
Reviewed-By: Ben Noordhuis <[email protected]>
@cjihrig
Copy link
Contributor Author

cjihrig commented Feb 19, 2015

Incorporated feedback and landed in ecef871.

@cjihrig cjihrig closed this Feb 19, 2015
@cjihrig cjihrig deleted the access branch February 19, 2015 16:28
@rvagg rvagg mentioned this pull request Feb 20, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants