The same truncation happens in the reverse direction on line 188:
config->chunk_size=(unsignedlonglong)tmp;// tmp is int
And similarly for delta_block_size on lines 123 and 203.
Impact
If the user specifies --chunk-size 3000000000 (3GB, well within unsigned long long range), the value is silently truncated to a negative or garbage int before being sent over the wire. The receiving side gets an incorrect chunk size.
While the default chunk size (10MB) and most practical values fit in int, this is a latent correctness bug that violates the principle that the full unsigned long long range should be supported.
Location
src/shared/config.c:113, 123, 188, 203
Suggested Fix
Instead of send_int/receive_int, use send_n_data/receive_n_data with sizeof(unsigned long long) to transmit these 64-bit values correctly:
This issue was automatically generated by the issue-creator agent.
## Description
In `src/shared/config.c` line 113, `config_send()` casts `config->chunk_size` (an `unsigned long long`) to `int` for transmission:
```c
if (!send_int(file_descriptor, (int)config->chunk_size))
```
The same truncation happens in the reverse direction on line 188:
```c
config->chunk_size = (unsigned long long)tmp; // tmp is int
```
And similarly for `delta_block_size` on lines 123 and 203.
## Impact
If the user specifies `--chunk-size 3000000000` (3GB, well within `unsigned long long` range), the value is silently truncated to a negative or garbage `int` before being sent over the wire. The receiving side gets an incorrect chunk size.
While the default chunk size (10MB) and most practical values fit in `int`, this is a latent correctness bug that violates the principle that the full `unsigned long long` range should be supported.
## Location
`src/shared/config.c:113, 123, 188, 203`
## Suggested Fix
Instead of `send_int`/`receive_int`, use `send_n_data`/`receive_n_data` with `sizeof(unsigned long long)` to transmit these 64-bit values correctly:
```c
// Sender:
if (!send_n_data(file_descriptor, &config->chunk_size, sizeof(config->chunk_size)))
return false;
// Receiver:
if (!receive_n_data(file_descriptor, &config->chunk_size, sizeof(config->chunk_size)))
goto error;
```
## Severity
High
## Category
Bug
---
_This issue was automatically generated by the issue-creator agent._
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Description
In
src/shared/config.cline 113,config_send()castsconfig->chunk_size(anunsigned long long) tointfor transmission:The same truncation happens in the reverse direction on line 188:
And similarly for
delta_block_sizeon lines 123 and 203.Impact
If the user specifies
--chunk-size 3000000000(3GB, well withinunsigned long longrange), the value is silently truncated to a negative or garbageintbefore being sent over the wire. The receiving side gets an incorrect chunk size.While the default chunk size (10MB) and most practical values fit in
int, this is a latent correctness bug that violates the principle that the fullunsigned long longrange should be supported.Location
src/shared/config.c:113, 123, 188, 203Suggested Fix
Instead of
send_int/receive_int, usesend_n_data/receive_n_datawithsizeof(unsigned long long)to transmit these 64-bit values correctly:Severity
High
Category
Bug
This issue was automatically generated by the issue-creator agent.