From 6ea5d1673145a8e8c554035f88f15ce4610be0fd Mon Sep 17 00:00:00 2001 From: cjihrig Date: Thu, 7 Aug 2014 22:36:56 -0400 Subject: [PATCH] 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 Reviewed-by: Trevor Norris --- lib/dns.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/dns.js b/lib/dns.js index b891c79d524..288373b45f1 100644 --- a/lib/dns.js +++ b/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)