bug: chunk_size truncated from 64-bit to 32-bit on send and receive #30

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

The chunk_size field in Config is unsigned long long (64-bit), but config_send() serializes it via send_int() which only sends an int (32-bit on most platforms):

File: src/shared/config.c:113

if (!send_int(file_descriptor, (int)config->chunk_size))

And config_receive() reads it back as int then casts:
File: src/shared/config.c:188

config->chunk_size = (unsigned long long)tmp;

This means chunk sizes larger than 2 GB will be silently truncated, potentially causing data corruption or incorrect chunking behavior on very large transfers.

Fix: Use send_n_data / receive_n_data with sizeof(unsigned long long) instead of send_int/receive_int for the chunk_size field.

Severity: high

The `chunk_size` field in `Config` is `unsigned long long` (64-bit), but `config_send()` serializes it via `send_int()` which only sends an `int` (32-bit on most platforms): **File:** `src/shared/config.c:113` ```c if (!send_int(file_descriptor, (int)config->chunk_size)) ``` And `config_receive()` reads it back as `int` then casts: **File:** `src/shared/config.c:188` ```c config->chunk_size = (unsigned long long)tmp; ``` This means chunk sizes larger than 2 GB will be silently truncated, potentially causing data corruption or incorrect chunking behavior on very large transfers. **Fix:** Use `send_n_data` / `receive_n_data` with `sizeof(unsigned long long)` instead of `send_int`/`receive_int` for the chunk_size field. **Severity:** high
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: TapTap/FastSync#30