wolfssh/tests
Mark Atwood e393bcb5d7 fix: harden peer-supplied numeric field parsing
Replace atoi() and strtoull() on peer-controlled numeric fields with
bounded, error-reporting parsers. atoi() has undefined behavior on
overflow and cannot signal malformed input. strtoull() is C99, so it is
unavailable on some ports, and it accepts a leading sign and leading
whitespace that the SCP header does not permit.

- #2881 src/wolfscp.c: add ScpParseUInt64 helper; parse SCP header
  file size / mtime / atime with digit validation and overflow
  rejection against a caller-supplied max, replacing the 3 strtoull
  call sites from de23a694. Also rejects "+1", " 1" and "\t1" on all
  three fields, and "-1" on the unbounded scpMTime and scpATime, which
  had taken the wrapped 0xFFFFFFFFFFFFFFFF. The helper takes the field
  length, dropping the temporary '\n' written over the separating space
  at each call site, and with it the <stdint.h> include de23a694 had
  added for UINT32_MAX.
- #2882 src/wolfterm.c: add parseArg helper using strtol; clamp
  invalid/out-of-range VT100 params to 0, replacing 2 atoi call
  sites (blocks peer "-1" wrapping to 0xFFFFFFFF). A param with bytes
  left over after its digits, such as "12x", clamps to 0 rather than
  parsing as a short value. strtol is C89 and needs no replacement.
  Inside USE_WINDOWS_API, so not built on Linux or macOS. Also drop
  the unused maxIdx from getArgs().

Extend test_ScpGetFileSize and test_ScpGetTimestamp in tests/unit.c for
the fields the new parser rejects but strtoull() accepted: a signed or
whitespace-padded field, an empty field, a field holding a NUL, and the
64-bit maximum and one past it on the timestamps. Drop the strtoull()
and ERANGE references from those test comments.

Issue: F-2881, F-2882
2026-07-27 10:29:05 -06:00
..
api.c Add client-side remote port forwarding 2026-07-23 15:54:30 -06:00
api.h Release v1.4.22 2025-12-29 16:53:33 -08:00
auth.c Run threaded api-test SFTP/SCP tests on Windows 2026-07-22 17:29:27 -05:00
auth.h Add tests for DoUserAuthRequestRsa and DoUserAuthRequestRsaCert 2026-05-27 14:44:10 -07:00
include.am Fix SFTP client states dropping unsent bytes after partial channel send 2026-06-16 11:21:19 -07:00
kex.c added ml-dsa plain key and cert algorithms 2026-07-06 16:51:21 -05:00
kex.h Release v1.4.22 2025-12-29 16:53:33 -08:00
regress.c tests: exercise DoKexDhReply host-key signature verify with corrupted signatures 2026-07-20 17:59:35 -05:00
sftp.c Add a safe mask for peer-supplied mode and extend wolfSSH_SFTP_Open 2026-06-08 10:01:24 -07:00
sftp.h Release v1.4.22 2025-12-29 16:53:33 -08:00
testsuite.c SSHD/Echoserver: Fix memory leaks and public-key lookup 2026-07-17 20:01:44 -05:00
testsuite.h Release v1.4.22 2025-12-29 16:53:33 -08:00
unit.c fix: harden peer-supplied numeric field parsing 2026-07-27 10:29:05 -06:00
unit.h Release v1.4.22 2025-12-29 16:53:33 -08:00