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 b5baaa6

Browse filesBrowse files
aduh95RafaelGSS
authored andcommitted
dns: fix port validation
Previously the error message generation would throw if the port was of type `"symbol"`. PR-URL: #45135 Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Mohammed Keyvanzadeh <mohammadkeyvanzade94@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Juan José Arboleda <soyjuanarbol@gmail.com>
1 parent 8cda730 commit b5baaa6
Copy full SHA for b5baaa6

File tree

Expand file treeCollapse file tree

2 files changed

+2
-7
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

2 files changed

+2
-7
lines changed
Open diff view settings
Collapse file

‎lib/internal/errors.js‎

Copy file name to clipboardExpand all lines: lib/internal/errors.js
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1569,7 +1569,7 @@ E('ERR_SOCKET_BAD_PORT', (name, port, allowZero = true) => {
15691569
assert(typeof allowZero === 'boolean',
15701570
"The 'allowZero' argument must be of type boolean.");
15711571
const operator = allowZero ? '>=' : '>';
1572-
return `${name} should be ${operator} 0 and < 65536. Received ${port}.`;
1572+
return `${name} should be ${operator} 0 and < 65536. Received ${determineSpecificType(port)}.`;
15731573
}, RangeError);
15741574
E('ERR_SOCKET_BAD_TYPE',
15751575
'Bad socket type specified. Valid types are: udp4, udp6', TypeError);
Collapse file

‎test/parallel/test-dns.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-dns.js
+1-6Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -310,8 +310,6 @@ dns.lookup('', {
310310
const portErr = (port) => {
311311
const err = {
312312
code: 'ERR_SOCKET_BAD_PORT',
313-
message:
314-
`Port should be >= 0 and < 65536. Received ${port}.`,
315313
name: 'RangeError'
316314
};
317315

@@ -323,10 +321,7 @@ const portErr = (port) => {
323321
dns.lookupService('0.0.0.0', port, common.mustNotCall());
324322
}, err);
325323
};
326-
portErr(null);
327-
portErr(undefined);
328-
portErr(65538);
329-
portErr('test');
324+
[null, undefined, 65538, 'test', NaN, Infinity, Symbol(), 0n, true, false, '', () => {}, {}].forEach(portErr);
330325

331326
assert.throws(() => {
332327
dns.lookupService('0.0.0.0', 80, null);

0 commit comments

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