Fix integration issues: ssl_ctx init + test API updates #89
Reference in New Issue
Block a user
Delete Branch "fix/integration-cleanup"
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:\n1. Initialize server->ssl_ctx = NULL in server_create\n2. Update tests for sockaddr_storage API\n3. Update test_file_sendfile.c for file_type indicator
PR Review:
fix/integration-cleanup(shab20e390)Overview
This PR performs a major cleanup and hardening of the transport layer and ancillary modules. It adds IPv4/IPv6 dual-stack support (via
getaddrinfo/sockaddr_storage), asendfile-based zero-copy file transfer path, globstar (**) pattern matching, graceful server shutdown, TLS SNI + hostname verification, exclude/include pattern filtering on the server side, and a comprehensive test suite expansion. 40 files changed, ~1,000 lines added.✅ Positive findings
server_createandclient_connectboth try IPv6 first, fall back to IPv4 viagetaddrinfo+sockaddr_storage.mkdir_rreplacedstrcpywithmemcpyand added bounds checking;str_dupnow usesmemcpy.receive_strenforcesMAX_STRING_SIZE(10 MB);receive_dataenforcesMAX_DATA_SIZE(1 GB).SSL_set_tlsext_host_name) and hostname verification (X509_VERIFY_PARAM_set1_host).SSL_get_verify_resultis checked after handshake.file_save_to_diskblocks absolute symlink targets and..in target; also rejects..indisk_path.file_restore_metadatamasks `S_ISUIDconfig_receivecaps pattern count atMAX_PATTERN_COUNT(10,000) and checks for integer overflow (src/shared/config.c:258-266).server_request_shutdown()+volatile sig_atomic_tflag terminates theacceptloop cleanly onSIGINT/SIGTERM.directory_scanner_create_fulldeep-copies exclude/include patterns and cleans up on allocation failure.data_compressclamps level to[1, 22].data_create_empty(0)malloc(0).test_file_sendfile,test_log,test_multiprocessing,test_transport_tcp,test_transport_ssh,test_transport_tls,test_scanneredge cases). All 22 tests pass.test_file_sendfileandtest_fileskip fork-based tests under valgrind using/proc/self/mapsheuristic.⚠️ Issues found
1.
sendfilemissingEINTRretry (src/shared/file.c:626-631)sendfile(2)can return-1witherrno == EINTRon interruption. This will cause an unnecessary transfer failure. Should retry onEINTR.Severity: Low (rare in practice; signal handler installs are minimal in this codebase).
2. Overly broad path traversal check (
src/shared/file.c:213, 229)Uses
strstrondisk_path. This flags any path containing the substring.., including legitimate names likefoo..bar.txt. While conservative (safe against../), it causes false rejections. A better approach: scan for..as a complete path component (e.g., tokenize by/).Severity: Low (conservative false-positive, not a vulnerability).
3. Bandwidth limiter not thread-safe (
src/shared/protocol.c:15-17)These are not
__thread, so they're shared across threads.bw_tokensis read/written without atomics inbw_throttle(). Pre-existing; not introduced by this PR.Severity: Low-Medium (pre-existing; could cause inaccurate throttling under multithreaded transfers, but not a memory-safety issue).
4.
is_running_under_valgrind()reads at most 4095 bytes (tests/test_utils.h)On a system with an unusually large
/proc/self/maps, thevgpreloadstring could appear after the first 4095 bytes, causing a false negative. In practice,vgpreloadalways appears near the top, so this is unlikely to trigger.Severity: Very Low.
5.
client_connectusesrpafterbreak— but this is safe (src/shared/transport_tcp.c:268)rpis valid because the loop exits viabreakonly whenconnectsucceeded, at which pointrppoints to the currentaddrinfonode. If no connection succeeded, thefd < 0check returns false before this point. No bug — but this is a subtle invariant worth documenting with a comment.Severity: None (correct, but subtle).
✅ Verdict
APPROVED. The PR is well-structured, solidly tested (22/22 passing), and introduces significant hardening (IPv6, TLS hostname verification, SUID/SGID stripping, protocol bounds, config receive overflow protection, graceful shutdown). The issues found are all low-severity:
EINTRinsendfile) and issue #2 (strstr("..")false positives) are worth fixing before merge but are not blockers.Re-review: ALL FIXES VERIFIED ✅
if (errno == EINTR) continue;correctly retries the sendfile loop (lines 643-645 ofsrc/shared/file.c).has_path_traversal()helper validates..only as a path component (lines 203-216), replacing naivestrstr(".."). Used infile_save_to_disk()at lines 221, 229, 245.Verdict: APPROVED
Pull request closed