Skip to content

Commit 6f584af

Browse files
committed
dns: Use object without protoype for map
Currently we use `{}` for the `lookup` function to find the relevant resolver to the dns.resolve function. It is preferable to use an object without a Object.prototype, currently for example you can do something like: ```js dns.resolve("google.com", "toString", console.log); ``` And get `[Object undefined]` logged and the callback would never be called. This is unexpected and strange behavior in my opinion. In addition, if someone adds a property to `Object.prototype` might also create unexpected results. This pull request fixes it, with it an appropriate error is thrown.
1 parent 8baaa25 commit 6f584af

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

lib/dns.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ function resolver(bindingName) {
243243
}
244244

245245

246-
var resolveMap = {};
246+
var resolveMap = Object.create(null);
247247
exports.resolve4 = resolveMap.A = resolver('queryA');
248248
exports.resolve6 = resolveMap.AAAA = resolver('queryAaaa');
249249
exports.resolveCname = resolveMap.CNAME = resolver('queryCname');

0 commit comments

Comments
 (0)