mirror of
https://github.com/nodejs/node.git
synced 2024-12-01 16:10:02 +01:00
51664fc265
This commit attaches a Symbol to the result of net._normalizeArgs(). This prevents normal arrays from being passed to the internal Socket.prototype.connect() bypass logic. PR-URL: https://github.com/nodejs/node/pull/13069 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
16 lines
471 B
JavaScript
16 lines
471 B
JavaScript
'use strict';
|
|
|
|
// Check that the port number is not NaN when coerced to a number,
|
|
// is an integer and that it falls within the legal range of port numbers.
|
|
function isLegalPort(port) {
|
|
if ((typeof port !== 'number' && typeof port !== 'string') ||
|
|
(typeof port === 'string' && port.trim().length === 0))
|
|
return false;
|
|
return +port === (+port >>> 0) && port <= 0xFFFF;
|
|
}
|
|
|
|
module.exports = {
|
|
isLegalPort,
|
|
normalizedArgsSymbol: Symbol('normalizedArgs')
|
|
};
|