Files
node/lib
Daijiro Wachi 1677526335 lib: reject string "0" in validatePort when allowZero is false
The allowZero guard compared the raw value with `port === 0`, but
validatePort accepts strings and coerces them with `+port` in every
other clause. Since `'0' === 0` is false, string forms of zero
('0', ' 0 ', '00', '0x0', ...) slipped past the guard when
allowZero was false, while the numeric 0 was correctly rejected.

This is reachable via dgram's send(), connect(), and bind(), which
call validatePort(port, 'Port', false): passing '0' was silently
accepted instead of throwing ERR_SOCKET_BAD_PORT.

Coerce the value with `+port` so the zero check matches the rest of
the validation.

Signed-off-by: Daijiro Wachi <daijiro.wachi@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/64174
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Richard Lau <richard.lau@ibm.com>
2026-07-06 12:40:25 +00:00
..
…
…
…
2026-07-05 08:04:44 +00:00
…
…
2026-04-05 10:12:21 +00:00
2026-06-21 19:42:03 +00:00
2026-05-31 12:49:51 -07:00
…
2025-12-10 16:12:28 +00:00
…
2025-12-22 16:14:46 +00:00
2025-09-04 11:58:50 +00:00
2026-02-21 16:30:23 +00:00
…
2026-04-01 10:09:41 +00:00
2026-06-19 16:07:24 +02:00
…
2026-04-26 19:36:36 +00:00
2026-05-23 18:43:31 +00:00
2025-08-05 13:45:41 +00:00