Skip to content

Commit

Permalink
module: ignore module path after null character
Browse files Browse the repository at this point in the history
Null char as the first char as the path component
of first argument of require causes a node crash.
Ignoring null and all chars after that in require path.

Fixes: nodejs#13787
  • Loading branch information
zimbabao committed Jun 20, 2017
1 parent 0861c3b commit 01c5127
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/module.js
Original file line number Diff line number Diff line change
Expand Up @@ -511,7 +511,7 @@ Module.prototype.require = function(path) {
assert(path, 'missing path');
assert(typeof path === 'string', 'path must be a string');
// Ignore part of the path after null character if it exists
if (path.indexOf('\u0000') != -1) {
if (path.indexOf('\u0000') !== -1) {
path = path.split('\u0000')[0];
}
return Module._load(path, this, /* isMain */ false);
Expand Down

0 comments on commit 01c5127

Please sign in to comment.