fs: add error code on null byte paths
This commit adds a code field to the error returned by nullCheck(). Fixes: https://github.com/iojs/io.js/issues/517 PR-URL: https://github.com/iojs/io.js/pull/519 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
This commit is contained in:
parent
e2558f02df
commit
03ee4d8547
@ -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() {
|
||||
|
@ -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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user