net: validate non-string host for socket.connect
Signed-off-by: Daeyeon Jeong <daeyeon.dev@gmail.com> PR-URL: https://github.com/nodejs/node/pull/57198 Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
parent
491eb66cdc
commit
c3ed292d17
@ -1311,6 +1311,8 @@ function lookupAndConnect(self, options) {
|
||||
const host = options.host || 'localhost';
|
||||
let { port, autoSelectFamilyAttemptTimeout, autoSelectFamily } = options;
|
||||
|
||||
validateString(host, 'options.host');
|
||||
|
||||
if (localAddress && !isIP(localAddress)) {
|
||||
throw new ERR_INVALID_IP_ADDRESS(localAddress);
|
||||
}
|
||||
|
@ -25,3 +25,15 @@ const net = require('net');
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
{
|
||||
assert.throws(() => {
|
||||
net.createConnection({
|
||||
host: ['192.168.0.1'],
|
||||
port: 8080,
|
||||
});
|
||||
}, {
|
||||
code: 'ERR_INVALID_ARG_TYPE',
|
||||
name: 'TypeError',
|
||||
});
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user