Skip to content

Fix integer overflow for large files in AccessManager

Adrian Thiele requested to merge athiele/kio:fix-int-overflow into master

When receiving a file that is 2147483648 bytes (2 GiB) or larger via KDE Connect it would not report transfer progress to the user and treat the transfer as failed as soon as it finished (and thus delete the received file).

The reason is an integer overflow of a signed integer and subsequent implicit conversion to an unsigned long long setting the total size of the transfer action to 2^{64}-1 bytes, which in turn prevents transfer progress signals to propagate to KDE Connect code (The uploadProgress signal never gets emitted in that case).

So we should treat the Content-Length header as an unsigned long long directly to prevent setting a wrong total size.

The fix has been tested by sending a 3 GiB large file from one Linux PC to another and from an android phone to a Linux PC via KDE Connect.

BUG: 452972

Merge request reports