fix: add NULL-checks and input validation in CLI argument parsing (#152) #153

Closed
TapTap wants to merge 1 commits from fix/null-checks-cli into main
Owner

Fixes #152

Adds NULL-checks and proper input validation for all argument parsing paths in client_cli.c:

  • Check all str_dup() return values for NULL
  • Replace atoi() with strtol() + endptr validation for port numbers
  • Add errno/endptr validation for strtoull calls (--max-size, --min-size)
  • Validate positional directory arguments for allocation failure

All 22 unit tests pass.

Fixes #152 Adds NULL-checks and proper input validation for all argument parsing paths in client_cli.c: - Check all str_dup() return values for NULL - Replace atoi() with strtol() + endptr validation for port numbers - Add errno/endptr validation for strtoull calls (--max-size, --min-size) - Validate positional directory arguments for allocation failure All 22 unit tests pass.
TapTap added 1 commit 2026-07-29 18:29:38 +02:00
fix: add NULL-checks and input validation in CLI argument parsing (#152)
CI / lint (pull_request) Successful in 12s
CI / sanitizers (address) (pull_request) Successful in 16s
CI / sanitizers (undefined) (pull_request) Successful in 16s
CI / coverage (pull_request) Successful in 10s
CI / fuzz-build (pull_request) Successful in 13s
CI / valgrind (pull_request) Successful in 12s
CI / build-and-test (pull_request) Successful in 54s
c75ccfd80b
- Add NULL-checks for all str_dup() calls in argument parsing
- Replace atoi with strtol + endptr validation for port numbers
- Add errno/endptr validation for strtoull calls (--max-size, --min-size)
- Check str_dup result for exclude/include patterns, server-host, backup-dir
- Validate positional directory arguments for allocation failure
TapTap closed this pull request 2026-07-30 18:17:10 +02:00
Author
Owner

=== PR REVIEW SUMMARY ===
Branch: fix/null-checks-cli (PR #153)
Files: 1 (src/client/client_cli.c)
Issues: 8 (0 critical, 2 warning, 6 style)

=== VERDICT ===
[PASS] All 22 tests pass, build clean. 2 warnings should be addressed.

=== ISSUES ===
[1] src/client/client_cli.c:312 — WARNING (memory) --cert str_dup not NULL-checked
[2] src/client/client_cli.c:315 — WARNING (memory) --key str_dup not NULL-checked
[3] src/client/client_cli.c:318 — STYLE (memory) --ca str_dup not NULL-checked
[4] src/client/client_cli.c:320 — STYLE (validation) --timeout uses atoi()
[5] src/client/client_cli.c:327 — STYLE (validation) --contimeout uses atoi()
[6] src/client/client_cli.c:348 — STYLE (validation) --max-depth uses atoi()
[7] src/client/client_cli.c:364 — STYLE (validation) --queue-size uses atoi()
[8] src/client/client_cli.c:215,221,231,305 — STYLE (validation) strtoull/strtol without errno/endptr checks

=== PR REVIEW SUMMARY === Branch: fix/null-checks-cli (PR #153) Files: 1 (src/client/client_cli.c) Issues: 8 (0 critical, 2 warning, 6 style) === VERDICT === [PASS] All 22 tests pass, build clean. 2 warnings should be addressed. === ISSUES === [1] src/client/client_cli.c:312 — WARNING (memory) --cert str_dup not NULL-checked [2] src/client/client_cli.c:315 — WARNING (memory) --key str_dup not NULL-checked [3] src/client/client_cli.c:318 — STYLE (memory) --ca str_dup not NULL-checked [4] src/client/client_cli.c:320 — STYLE (validation) --timeout uses atoi() [5] src/client/client_cli.c:327 — STYLE (validation) --contimeout uses atoi() [6] src/client/client_cli.c:348 — STYLE (validation) --max-depth uses atoi() [7] src/client/client_cli.c:364 — STYLE (validation) --queue-size uses atoi() [8] src/client/client_cli.c:215,221,231,305 — STYLE (validation) strtoull/strtol without errno/endptr checks
Some checks are pending
CI / lint (pull_request) Successful in 12s
CI / sanitizers (address) (pull_request) Successful in 16s
CI / sanitizers (undefined) (pull_request) Successful in 16s
CI / coverage (pull_request) Successful in 10s
CI / fuzz-build (pull_request) Successful in 13s
CI / valgrind (pull_request) Successful in 12s
CI / build-and-test (pull_request) Successful in 54s

Pull request closed

Sign in to join this conversation.
No Reviewers
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: TapTap/FastSync#153