Reference in New Issue
Block a user
Delete Branch "fix/logic-correctness"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Fixes 9 logic bugs:\n- #73: SSL WANT_WRITE handling\n- #68: Integer overflow bandwidth\n- #67: glob_match ** support\n- #66: g_server signal safety\n- #59: atoi port validation\n- #58: chmod/chown return values\n- #54: Duplicate delta receive\n- #48: compression_level validation\n- #53: log_message const char*
PR #88 Review:
fix/logic-correctness(6ada6a5)Verdict: APPROVE — This is a large, well-structured PR that fixes numerous correctness, security, and compatibility issues. The code quality is high with thorough error handling and comprehensive test coverage. No blocking issues found.
Overview
This PR spans ~30 files touching the client CLI, server, scanner, config, protocol, transport (TCP/TLS/SSH), metadata, compression, file I/O, utils (glob), and adds extensive test coverage. The changes fall into these categories:
Issues Found
MEDIUM:
test_scanner_max_size— files created before mkdirFile:
tests/test_scanner.cThe first pair of
create_test_filecalls executes beforemkdir()— these will fail silently. The files are then created a second time after mkdir. Remove the redundant first pair.LOW:
is_excluded()usesbasename()with implementation-defined behaviorFile:
src/server/server.c:294POSIX
basename()(from<libgen.h>) may modify its argument and may return a pointer to internal static storage on some implementations. The code correctly passes astr_dup'd copy, so it is safe here. However, the returned pointer should only be used as read-only (whichglob_matchdoes). Consider adding a comment noting thatbasenameresult must not be freed.LOW:
glob_match("**/foo", "foo")works via fallback path rather than dedicated**codeFile:
src/shared/utils.cWhen matching
"**/foo"against"foo", the function reaches the literal-mismatch branch and falls into the/***/fallback (lines 105-111) rather than the dedicated**code (lines 80-87). The result is correct, but the double-star logic is split across two locations. Consider unifying for clarity.INFO:
config_receivegoto-error pattern is fragileFile:
src/shared/config.c:339-345The
error:label freesversion,send_directory,receive_root_directory,server_host, andconfigitself — but does not freeexclude_patternsorinclude_patterns. The call sites that do partial allocation explicitly free and NULL-out their arrays before jumping toerror. This is correct but fragile — future additions between cleanup and goto could leak.INFO:
file_send_streamingdoes not send STATUS_ERROR on failureFile:
src/shared/file.c:701-739Not a bug — this is the sender side; connection close upon return serves as the error indicator, matching existing patterns.
Highlights
strstr(..., "..")checks on received paths and symlink targets. SUID/SGID bits stripped on metadata restore. TLS hostname verification with SNI. Fixed-width wire types prevent protocol mismatch between 32/64-bit peers.strcpyreplaced withmemcpy.malloc(0)UB fixed. Dynamic ssh_argv with bounds checks. Pattern deep-copy in scanner prevents use-after-free. NULL checks added inmetadata_from_bufandconfig_create.MAX_STRING_SIZE(10MB) andMAX_DATA_SIZE(1GB) limits prevent OOM from malicious peers. SSL non-blocking retry added tosend_n_data/receive_n_data.getaddrinfo+sockaddr_storage.**pattern matching with tests for prefix, suffix, and mid-path.Summary
This PR significantly improves the correctness, security, and cross-platform compatibility of FastSync. The code is well-structured, errors are properly handled, and the test coverage expansion is excellent. Approved.
6ada6a5aa7tof932a48910Re-review: ALL FIXES VERIFIED ✅
Verdict: APPROVED