mirror of https://github.com/nodejs/node.git
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>
This commit is contained in:
parent
10fa8e3999
commit
6ea5d16731
|
@ -102,7 +102,7 @@ function onlookup(err, addresses) {
|
||||||
// lookup(hostname, [options,] callback)
|
// lookup(hostname, [options,] callback)
|
||||||
exports.lookup = function lookup(hostname, options, callback) {
|
exports.lookup = function lookup(hostname, options, callback) {
|
||||||
var hints = 0;
|
var hints = 0;
|
||||||
var family = 0;
|
var family = -1;
|
||||||
|
|
||||||
// Parse arguments
|
// Parse arguments
|
||||||
if (typeof options === 'function') {
|
if (typeof options === 'function') {
|
||||||
|
@ -120,6 +120,8 @@ exports.lookup = function lookup(hostname, options, callback) {
|
||||||
hints !== (exports.ADDRCONFIG | exports.V4MAPPED)) {
|
hints !== (exports.ADDRCONFIG | exports.V4MAPPED)) {
|
||||||
throw new TypeError('invalid argument: hints must use valid flags');
|
throw new TypeError('invalid argument: hints must use valid flags');
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
family = options >>> 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (family !== 0 && family !== 4 && family !== 6)
|
if (family !== 0 && family !== 4 && family !== 6)
|
||||||
|
|
Loading…
Reference in New Issue