Skip to content

Commit

Permalink
fs: add error code on null byte paths
Browse files Browse the repository at this point in the history
This commit adds a code field to the error returned by
nullCheck().

Fixes: #517
PR-URL: #519
Reviewed-By: Ben Noordhuis <[email protected]>
  • Loading branch information
cjihrig committed Jan 19, 2015
1 parent e2558f0 commit 03ee4d8
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/fs.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ function assertEncoding(encoding) {
function nullCheck(path, callback) {
if (('' + path).indexOf('\u0000') !== -1) {
var er = new Error('Path must be a string without null bytes.');
er.code = 'ENOENT';
if (!callback)
throw er;
process.nextTick(function() {
Expand Down
1 change: 1 addition & 0 deletions test/parallel/test-fs-null-bytes.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ function check(async, sync) {
var argsSync = Array.prototype.slice.call(arguments, 2);
var argsAsync = argsSync.concat(function(er) {
assert(er && er.message.match(expected));
assert.equal(er.code, 'ENOENT');
});

if (sync)
Expand Down

0 comments on commit 03ee4d8

Please sign in to comment.