dns: fix GetAddrInfo assert
The method GetAddrInfo() is used by more than just dns.lookup(), and in those cases a third argument isn't passed. This caused the following check to abort: assert(args[3]->IsInt32()); Fixes: 4306786 "net: don't prefer IPv4 addresses during resolution" Signed-off-by: Trevor Norris <trev.norris@gmail.com>
This commit is contained in:
parent
430678640c
commit
e643fe4c4b
@ -102,17 +102,14 @@ function onlookup(err, addresses) {
|
||||
// lookup(hostname, [options,] callback)
|
||||
exports.lookup = function lookup(hostname, options, callback) {
|
||||
var hints = 0;
|
||||
var family;
|
||||
var family = 0;
|
||||
|
||||
// Parse arguments
|
||||
if (typeof options === 'function') {
|
||||
callback = options;
|
||||
family = 0;
|
||||
// Allow user to pass falsy values to options, and still pass callback.
|
||||
} else if (typeof callback !== 'function') {
|
||||
throw TypeError('invalid arguments: callback must be passed');
|
||||
} else if (!options) {
|
||||
family = 0;
|
||||
} else if (util.isObject(options)) {
|
||||
hints = options.hints >>> 0;
|
||||
family = options.family >>> 0;
|
||||
@ -123,8 +120,6 @@ 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)
|
||||
|
@ -1014,12 +1014,11 @@ static void GetAddrInfo(const FunctionCallbackInfo<Value>& args) {
|
||||
assert(args[0]->IsObject());
|
||||
assert(args[1]->IsString());
|
||||
assert(args[2]->IsInt32());
|
||||
assert(args[3]->IsInt32());
|
||||
Local<Object> req_wrap_obj = args[0].As<Object>();
|
||||
node::Utf8Value hostname(args[1]);
|
||||
|
||||
int32_t flags = (args[3]->IsInt32()) ? args[3]->Int32Value() : 0;
|
||||
int family;
|
||||
int32_t flags = args[3]->Int32Value();
|
||||
|
||||
switch (args[2]->Int32Value()) {
|
||||
case 0:
|
||||
|
Loading…
x
Reference in New Issue
Block a user