mirror of
https://github.com/openclaw/openclaw.git
synced 2026-06-07 20:32:54 +00:00
Summary:
- The PR adds a 65,535 upper-bound check to the shared CLI `parsePort` helper, a colocated regression test, and a changelog entry for the linked port-range bug.
- Reproducibility: yes. Source inspection on current main shows `parsePort('99999')` delegates to `parseStrict ... sitive safe integer, so the return would be `99999`; I did not execute it because this review is read-only.
Automerge notes:
- PR branch already contained follow-up commit before automerge: fix(cli): reject out-of-range port numbers in parsePort (#83900)
Validation:
- ClawSweeper review passed for head 9ad0705c44.
- Required merge gates passed before the squash merge.
Prepared head SHA: 9ad0705c44
Review: https://github.com/openclaw/openclaw/pull/84008#issuecomment-4484883200
Co-authored-by: HCL <chenglunhu@gmail.com>
Co-authored-by: clawsweeper <274271284+clawsweeper[bot]@users.noreply.github.com>
Co-authored-by: clawsweeper[bot] <274271284+clawsweeper[bot]@users.noreply.github.com>
Approved-by: takhoffman
Co-authored-by: takhoffman <781889+takhoffman@users.noreply.github.com>
19 lines
678 B
TypeScript
19 lines
678 B
TypeScript
import { parseStrictPositiveInteger } from "../../infra/parse-finite-number.js";
|
|
|
|
// TCP/UDP ports are 16-bit, so 65535 is the max. `parseStrictPositiveInteger`
|
|
// only enforces positivity, so values like 99999 were returned as-is and
|
|
// reached gateway-cli / node-cli bind paths; the OS then surfaced the error
|
|
// instead of the CLI rejecting it cleanly at parse time. See #83900.
|
|
const MAX_TCP_PORT = 65_535;
|
|
|
|
export function parsePort(raw: unknown): number | null {
|
|
if (raw === undefined || raw === null) {
|
|
return null;
|
|
}
|
|
const parsed = parseStrictPositiveInteger(raw);
|
|
if (parsed === undefined || parsed > MAX_TCP_PORT) {
|
|
return null;
|
|
}
|
|
return parsed;
|
|
}
|