dns: always set variable family in lookup()
authorcjihrig <cjihrig@gmail.com>
Fri, 8 Aug 2014 02:36:56 +0000 (22:36 -0400)
committerTrevor Norris <trev.norris@gmail.com>
Fri, 8 Aug 2014 21:50:49 +0000 (14:50 -0700)
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>
lib/dns.js

index b891c79d524018ac4ca4f95db8e315fc98a562db..288373b45f1abd505e682e4d60e65e898f0ab861 100644 (file)
@@ -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)