GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — net: validate non-string host for socket.connect · nodejs/node@4762f4a

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • lib
    • net.js
  • test/parallel
    • test-net-connect-options-invalid.js
Expand file treeCollapse file tree
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)
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.