feature: no network timeout handling — operations can hang indefinitely #36

Closed
opened 2026-07-20 14:58:09 +02:00 by TapTap · 0 comments
Owner

FastSync has no configurable timeouts for any network operations:

  1. src/shared/transport_tcp.c: No setsockopt(SO_RCVTIMEO) or setsockopt(SO_SNDTIMEO) is set on sockets. connect() has no timeout wrapper.
  2. src/shared/transport_ssh.c: The read() on the exec pipe (line 135) has no timeout.
  3. src/shared/protocol.c: All read()/write() calls can block indefinitely.
  4. src/server/server.c: accept() blocks without timeout.

This means:

  • If the remote server disappears mid-transfer, the client hangs forever
  • If network partitions occur, file descriptors are never released
  • A malicious server can hold client connections open indefinitely (DoS)
  • No --timeout or --contimeout CLI options exist (unlike rsync)

Suggested Fix:

  1. Add SO_RCVTIMEO/SO_SNDTIMEO to client sockets
  2. Add connect timeout via O_NONBLOCK + select()/poll()
  3. Add --timeout CLI option with default (e.g., 0 = no timeout, like rsync)

Location: src/shared/transport_tcp.c, src/shared/protocol.c, src/server/server.c

Severity: medium

FastSync has no configurable timeouts for any network operations: 1. **`src/shared/transport_tcp.c`**: No `setsockopt(SO_RCVTIMEO)` or `setsockopt(SO_SNDTIMEO)` is set on sockets. `connect()` has no timeout wrapper. 2. **`src/shared/transport_ssh.c`**: The `read()` on the exec pipe (line 135) has no timeout. 3. **`src/shared/protocol.c`**: All `read()`/`write()` calls can block indefinitely. 4. **`src/server/server.c`**: `accept()` blocks without timeout. This means: - If the remote server disappears mid-transfer, the client hangs forever - If network partitions occur, file descriptors are never released - A malicious server can hold client connections open indefinitely (DoS) - No `--timeout` or `--contimeout` CLI options exist (unlike rsync) **Suggested Fix:** 1. Add SO_RCVTIMEO/SO_SNDTIMEO to client sockets 2. Add connect timeout via `O_NONBLOCK` + `select()`/`poll()` 3. Add `--timeout` CLI option with default (e.g., 0 = no timeout, like rsync) **Location:** `src/shared/transport_tcp.c`, `src/shared/protocol.c`, `src/server/server.c` **Severity:** medium
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: TapTap/FastSync#36