diff --git a/lib/dns.js b/lib/dns.js index e77542457b5cd1..e165b1bc0d2f05 100644 --- a/lib/dns.js +++ b/lib/dns.js @@ -243,7 +243,7 @@ function resolver(bindingName) { } -var resolveMap = {}; +var resolveMap = Object.create(null); exports.resolve4 = resolveMap.A = resolver('queryA'); exports.resolve6 = resolveMap.AAAA = resolver('queryAaaa'); exports.resolveCname = resolveMap.CNAME = resolver('queryCname'); diff --git a/test/parallel/test-c-ares.js b/test/parallel/test-c-ares.js index 8c2178ead6a93d..66ae0e0a4adf33 100644 --- a/test/parallel/test-c-ares.js +++ b/test/parallel/test-c-ares.js @@ -27,6 +27,11 @@ assert.throws(function() { dns.resolve('www.google.com', 'HI'); }, /Unknown type/); +// Try calling resolve with an unsupported type that's an object key +assert.throws(function() { + dns.resolve('www.google.com', 'toString'); +}, /Unknown type/); + // Windows doesn't usually have an entry for localhost 127.0.0.1 in // C:\Windows\System32\drivers\etc\hosts // so we disable this test on Windows.