config: OpenSSH parity for numeric parsing (port, timeout, time suffixes)
Summary
This PR tightens libssh's numeric configuration parsing to match OpenSSH behavior in four related areas:
- Port range validation: Rejects values outside
1..65535instead of silently masking with& 0xffffU(soPort 70000no longer becomes4464)."23abc"is also no longer accepted as port 23. - Trailing garbage in numerics:
ssh_config_get_long()now requiresstrtol()to consume the whole token. Invalid formats likePort 2201abc,ConnectTimeout 30abc, andRequiredRSASize 2233abcare now rejected rather than silently truncated. - ConnectTimeout time suffixes + "none": Introduces a new
ssh_config_convtime()that accepts OpenSSH'ss/m/h/d/wsuffixes with accumulation (e.g.,30s30s= 60,1h30m= 5400), caps the total atINT_MAXseconds, and maps the literalnonetoSSH_TIMEOUT_INFINITE. ssh_make_milliseconds()bounds: Caps large timeouts atINT_MAXms (~24.8 days) to prevent integer overflows, and ensures theSSH_TIMEOUT_INFINITEflag is passed through cleanly without being altered.
Verification
All four behaviors were manually verified against OpenSSH via ssh -G.
Checklist
- Commits have
Signed-off-by:with name/author being identical to the commit author - Code modified for feature
- Test suite updated with functionality tests
- Test suite updated with negative tests
- Documentation updated
- The project pipelines timeout is extended at least to 2 hours.
Reviewer's checklist:
- Any issues marked for closing are addressed
- There is a test suite reasonably covering new functionality or modifications
- Function naming, parameters, return values, types, etc., are consistent and according to CONTRIBUTING.md
- This feature/change has adequate documentation added
- No obvious mistakes in the code