[BUG][med] receive_delta_file failure paths don't set *failed -> STATUS_ERROR + STATUS_NEXT protocol desync (double-send / hang) #256

Closed
opened 2026-09-05 12:08:20 +02:00 by TapTap · 1 comment
Owner

Found by bug hunt + code review of dev (9f8b588).

Where: src/shared/file_receive.c:241-248 (new_size > MAX_RECEIVE_FILE_SIZE), :281-288 (data_create failure). Other NULL paths correctly set *failed.

Problem: These two paths send STATUS_ERROR and return NULL WITHOUT *failed=true. Caller receive_incremental_check (474-492) then treats delta as "not attempted", sends STATUS_NEXT and blocks in receive_data_limited waiting for a body the client will never send -> protocol desync, up-to-60s timeout, confusing mid-stream abort.

Fix: Set *failed=true on every return NULL in receive_delta_file after signature is sent (or restructure to an enum).

Unit test required driving the oversized/corrupt delta path.

Found by bug hunt + code review of `dev` (9f8b588). **Where:** src/shared/file_receive.c:241-248 (new_size > MAX_RECEIVE_FILE_SIZE), :281-288 (data_create failure). Other NULL paths correctly set *failed. **Problem:** These two paths send STATUS_ERROR and return NULL WITHOUT *failed=true. Caller receive_incremental_check (474-492) then treats delta as "not attempted", sends STATUS_NEXT and blocks in receive_data_limited waiting for a body the client will never send -> protocol desync, up-to-60s timeout, confusing mid-stream abort. **Fix:** Set *failed=true on every return NULL in receive_delta_file after signature is sent (or restructure to an enum). Unit test required driving the oversized/corrupt delta path.
Author
Owner

Resolved on dev (HEAD f7c6c91).

Fixed on dev via fix/receiver-correctness (14c064a) + hardening commit f7c6c91: *failed now set on every NULL return in receive_delta_file (incl. oversize + data_create paths); incremental oversize branch no longer double-sends STATUS_ERROR.

CI run #461: all jobs green (lint, build-and-test, sanitizers address+undefined, fuzz-build, coverage, valgrind). Unit 25/25, integration 83 passed / 10 skipped / 1 xpassed. Closing.

**Resolved on `dev`** (HEAD f7c6c91). Fixed on dev via fix/receiver-correctness (14c064a) + hardening commit f7c6c91: *failed now set on every NULL return in receive_delta_file (incl. oversize + data_create paths); incremental oversize branch no longer double-sends STATUS_ERROR. CI run #461: all jobs green (lint, build-and-test, sanitizers address+undefined, fuzz-build, coverage, valgrind). Unit 25/25, integration 83 passed / 10 skipped / 1 xpassed. Closing.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: TapTap/FastSync#256