GeezerVison is showing github.com — dns: fix port validation · nodejs/node@9ceed7a
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: lib/internal/errors.js +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -1569,7 +1569,7 @@ E('ERR_SOCKET_BAD_PORT', (name, port, allowZero = true) => { | 1569 | 1569 | assert(typeof allowZero === 'boolean', | 1570 | 1570 | "The 'allowZero' argument must be of type boolean."); | 1571 | 1571 | 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)}.`; | 1573 | 1573 | }, RangeError); | 1574 | 1574 | E('ERR_SOCKET_BAD_TYPE', | 1575 | 1575 | 'Bad socket type specified. Valid types are: udp4, udp6', TypeError); | |
Collapse file Copy file name to clipboardExpand all lines: test/parallel/test-dns.js +1-6Lines changed: 1 addition & 6 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -310,8 +310,6 @@ dns.lookup('', { | 310 | 310 | const portErr = (port) => { | 311 | 311 | const err = { | 312 | 312 | code: 'ERR_SOCKET_BAD_PORT', | 313 | | - message: | 314 | | - `Port should be >= 0 and < 65536. Received ${port}.`, | 315 | 313 | name: 'RangeError' | 316 | 314 | }; | 317 | 315 |
| @@ -323,10 +321,7 @@ const portErr = (port) => { | 323 | 321 | dns.lookupService('0.0.0.0', port, common.mustNotCall()); | 324 | 322 | }, err); | 325 | 323 | }; | 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); | 330 | 325 |
| 331 | 326 | assert.throws(() => { | 332 | 327 | dns.lookupService('0.0.0.0', 80, null); | |
|