diff options
author | Evan Lucas <evanlucas@me.com> | 2016-01-26 08:15:53 -0600 |
---|---|---|
committer | James M Snell <jasnell@gmail.com> | 2016-02-01 09:36:57 -0800 |
commit | f3be421c1cea01e7745906f36286c7b8fa607cb7 (patch) | |
tree | ec524d5478da6d127340e3f79af750918f86774a /test/parallel/test-dns.js | |
parent | 089d84f8fa2f31252b7312bfaf87070733e3f315 (diff) | |
download | android-node-v8-f3be421c1cea01e7745906f36286c7b8fa607cb7.tar.gz android-node-v8-f3be421c1cea01e7745906f36286c7b8fa607cb7.tar.bz2 android-node-v8-f3be421c1cea01e7745906f36286c7b8fa607cb7.zip |
dns: coerce port to number in lookupService
Previously, port could be any number in dns.lookupService. This change
throws a TypeError if port is outside the range of 0-65535. It also
coerces the port to a number.
PR-URL: https://github.com/nodejs/node/pull/4883
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Brian White <mscdex@mscdex.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Minwoo Jung <jmwsoft@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'test/parallel/test-dns.js')
-rw-r--r-- | test/parallel/test-dns.js | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/test/parallel/test-dns.js b/test/parallel/test-dns.js index 84b74e022a..d473ae8d95 100644 --- a/test/parallel/test-dns.js +++ b/test/parallel/test-dns.js @@ -154,10 +154,26 @@ assert.throws(function() { dns.lookupService('fasdfdsaf', 0, noop); }, /"host" argument needs to be a valid IP address/); -assert.throws(function() { +assert.doesNotThrow(function() { dns.lookupService('0.0.0.0', '0', noop); -}, /"port" argument must be a number, got "0"/); +}); assert.doesNotThrow(function() { dns.lookupService('0.0.0.0', 0, noop); }); + +assert.throws(function() { + dns.lookupService('0.0.0.0', null, noop); +}, /"port" should be >= 0 and < 65536, got "null"/); + +assert.throws(function() { + dns.lookupService('0.0.0.0', undefined, noop); +}, /"port" should be >= 0 and < 65536, got "undefined"/); + +assert.throws(function() { + dns.lookupService('0.0.0.0', 65538, noop); +}, /"port" should be >= 0 and < 65536, got "65538"/); + +assert.throws(function() { + dns.lookupService('0.0.0.0', 'test', noop); +}, /"port" should be >= 0 and < 65536, got "test"/); |