Browse Source

dns: always set variable family in lookup()

Regression occurred that prevented the variable "family" from being set
properly when the lookup() function's "options" parameter was passed a
number instead of an object.

Also included a sanity check by setting the default value of "family" to
a value that will not pass verification.

Fixes: e643fe4 "dns: fix GetAddrInfo assert"
Reviewed-by: Alexis Campailla <alexis@janeasystems.com>
Reviewed-by: Trevor Norris <trev.norris@gmail.com>
v0.11.14-release
cjihrig 11 years ago
committed by Trevor Norris
parent
commit
6ea5d16731
  1. 4
      lib/dns.js

4
lib/dns.js

@ -102,7 +102,7 @@ function onlookup(err, addresses) {
// lookup(hostname, [options,] callback)
exports.lookup = function lookup(hostname, options, callback) {
var hints = 0;
var family = 0;
var family = -1;
// Parse arguments
if (typeof options === 'function') {
@ -120,6 +120,8 @@ exports.lookup = function lookup(hostname, options, callback) {
hints !== (exports.ADDRCONFIG | exports.V4MAPPED)) {
throw new TypeError('invalid argument: hints must use valid flags');
}
} else {
family = options >>> 0;
}
if (family !== 0 && family !== 4 && family !== 6)

Loading…
Cancel
Save