Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 4762f4a

Browse filesBrowse files
daeyeontargos
authored andcommitted
net: validate non-string host for socket.connect
Signed-off-by: Daeyeon Jeong <daeyeon.dev@gmail.com> PR-URL: #57198 Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent 1c271b1 commit 4762f4a
Copy full SHA for 4762f4a

File tree

Expand file treeCollapse file tree

2 files changed

+14
-0
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

2 files changed

+14
-0
lines changed
Open diff view settings
Collapse file

‎lib/net.js‎

Copy file name to clipboardExpand all lines: lib/net.js
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1311,6 +1311,8 @@ function lookupAndConnect(self, options) {
13111311
const host = options.host || 'localhost';
13121312
let { port, autoSelectFamilyAttemptTimeout, autoSelectFamily } = options;
13131313

1314+
validateString(host, 'options.host');
1315+
13141316
if (localAddress && !isIP(localAddress)) {
13151317
throw new ERR_INVALID_IP_ADDRESS(localAddress);
13161318
}
Collapse file

‎test/parallel/test-net-connect-options-invalid.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-net-connect-options-invalid.js
+12Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,15 @@ const net = require('net');
2525
});
2626
});
2727
}
28+
29+
{
30+
assert.throws(() => {
31+
net.createConnection({
32+
host: ['192.168.0.1'],
33+
port: 8080,
34+
});
35+
}, {
36+
code: 'ERR_INVALID_ARG_TYPE',
37+
name: 'TypeError',
38+
});
39+
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.