| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -157,7 +157,8 @@ function lookup(hostname, options, callback) { | |||
| 157 | 157 | validateFunction(callback, 'callback'); | |
| 158 | 158 | ||
| 159 | 159 | validateOneOf(options, 'family', validFamilies); | |
| 160 | - family = options; | ||
| 160 | + // Coerce -0 to +0. | ||
| 161 | + family = options + 0; | ||
| 161 | 162 | } else if (options !== undefined && typeof options !== 'object') { | |
| 162 | 163 | validateFunction(arguments.length === 2 ? options : callback, 'callback'); | |
| 163 | 164 | throw new ERR_INVALID_ARG_TYPE('options', ['integer', 'object'], options); | |
@@ -179,7 +180,8 @@ function lookup(hostname, options, callback) { | |||
| 179 | 180 | break; | |
| 180 | 181 | default: | |
| 181 | 182 | validateOneOf(options.family, 'options.family', validFamilies); | |
| 182 | - family = options.family; | ||
| 183 | + // Coerce -0 to +0. | ||
| 184 | + family = options.family + 0; | ||
| 183 | 185 | break; | |
| 184 | 186 | } | |
| 185 | 187 | } | |
@@ -274,7 +276,8 @@ function lookupService(address, port, callback) { | |||
| 274 | 276 | ||
| 275 | 277 | validateFunction(callback, 'callback'); | |
| 276 | 278 | ||
| 277 | - port = +port; | ||
| 279 | + // Coerce -0 to +0. | ||
| 280 | + port = +port + 0; | ||
| 278 | 281 | ||
| 279 | 282 | const req = new GetNameInfoReqWrap(); | |
| 280 | 283 | req.callback = callback; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -206,7 +206,8 @@ function lookup(hostname, options) { | |||
| 206 | 206 | ||
| 207 | 207 | if (typeof options === 'number') { | |
| 208 | 208 | validateOneOf(options, 'family', validFamilies); | |
| 209 | - family = options; | ||
| 209 | + // Coerce -0 to +0. | ||
| 210 | + family = options + 0; | ||
| 210 | 211 | } else if (options !== undefined && typeof options !== 'object') { | |
| 211 | 212 | throw new ERR_INVALID_ARG_TYPE('options', ['integer', 'object'], options); | |
| 212 | 213 | } else { | |
@@ -217,7 +218,8 @@ function lookup(hostname, options) { | |||
| 217 | 218 | } | |
| 218 | 219 | if (options?.family != null) { | |
| 219 | 220 | validateOneOf(options.family, 'options.family', validFamilies); | |
| 220 | - family = options.family; | ||
| 221 | + // Coerce -0 to +0. | ||
| 222 | + family = options.family + 0; | ||
| 221 | 223 | } | |
| 222 | 224 | if (options?.all != null) { | |
| 223 | 225 | validateBoolean(options.all, 'options.all'); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -45,14 +45,18 @@ const { | |||
| 45 | 45 | } = require('internal/v8/startup_snapshot'); | |
| 46 | 46 | ||
| 47 | 47 | function validateTimeout(options) { | |
| 48 | - const { timeout = -1 } = { ...options }; | ||
| 48 | + let { timeout = -1 } = { ...options }; | ||
| 49 | 49 | validateInt32(timeout, 'options.timeout', -1); | |
| 50 | + // Coerce -0 to +0. | ||
| 51 | + timeout += 0; | ||
| 50 | 52 | return timeout; | |
| 51 | 53 | } | |
| 52 | 54 | ||
| 53 | 55 | function validateMaxTimeout(options) { | |
| 54 | - const { maxTimeout = 0 } = { ...options }; | ||
| 56 | + let { maxTimeout = 0 } = { ...options }; | ||
| 55 | 57 | validateUint32(maxTimeout, 'options.maxTimeout'); | |
| 58 | + // Coerce -0 to +0. | ||
| 59 | + maxTimeout += 0; | ||
| 56 | 60 | return maxTimeout; | |
| 57 | 61 | } | |
| 58 | 62 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,14 @@ | |||
| 1 | + 'use strict'; | ||
| 2 | + | ||
| 3 | + const common = require('../common'); | ||
| 4 | + | ||
| 5 | + const dns = require('dns'); | ||
| 6 | + | ||
| 7 | + dns.lookup('localhost', -0, common.mustCall()); | ||
| 8 | + dns.lookup('localhost', { family: -0 }, common.mustCall()); | ||
| 9 | + dns.lookupService('127.0.0.1', -0, common.mustCall()); | ||
| 10 | + | ||
| 11 | + new dns.Resolver({ timeout: -0 }); | ||
| 12 | + new dns.Resolver({ maxTimeout: -0 }); | ||
| 13 | + | ||
| 14 | + dns.promises.lookup('localhost', { family: -0 }).then(common.mustCall()); | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments