From 01c5127160c434e9eba2d33ffc4f79fc31b7f81c Mon Sep 17 00:00:00 2001 From: Rajaram Gaunker Date: Tue, 20 Jun 2017 09:38:09 -0700 Subject: [PATCH] module: ignore module path after null character 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: https://github.com/nodejs/node/issues/13787 --- lib/module.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/module.js b/lib/module.js index 60a85524e2132f..44a3d0ff31ab13 100644 --- a/lib/module.js +++ b/lib/module.js @@ -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);