From 4174f139b654ab27da75d27c195603a6d99f8a5e Mon Sep 17 00:00:00 2001 From: Voltrex Date: Thu, 10 Jun 2021 02:17:12 +0430 Subject: [PATCH] net: use missing validator The `net` lib module's `lookupAndConnect()` function is missing a validator. PR-URL: https://github.com/nodejs/node/pull/38984 Reviewed-By: Antoine du Hamel Reviewed-By: Zijian Liu Reviewed-By: Darshan Sen Reviewed-By: Luigi Pinca Reviewed-By: Colin Ihrig Reviewed-By: James M Snell Reviewed-By: Zeyu Yang --- lib/net.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/lib/net.js b/lib/net.js index 4b55366f87dae0..899e73f6ff167d 100644 --- a/lib/net.js +++ b/lib/net.js @@ -102,6 +102,7 @@ const { const { isUint8Array } = require('internal/util/types'); const { validateAbortSignal, + validateFunction, validateInt32, validateNumber, validatePort, @@ -1002,10 +1003,8 @@ function lookupAndConnect(self, options) { return; } - if (options.lookup && typeof options.lookup !== 'function') - throw new ERR_INVALID_ARG_TYPE('options.lookup', - 'Function', options.lookup); - + if (options.lookup !== undefined) + validateFunction(options.lookup, 'options.lookup'); if (dns === undefined) dns = require('dns'); const dnsopts = {