diff --git a/libtransmission/file-posix.cc b/libtransmission/file-posix.cc index 968fe8465..d4288b2d4 100644 --- a/libtransmission/file-posix.cc +++ b/libtransmission/file-posix.cc @@ -379,7 +379,7 @@ bool tr_sys_path_copy(char const* src_path, char const* dst_path, tr_error** err while (file_size > 0U) { - size_t const chunk_size = std::min(file_size, uint64_t{ SSIZE_MAX }); + size_t const chunk_size = std::min({ file_size, uint64_t{ SSIZE_MAX }, uint64_t{ INT32_MAX } }); auto const copied = copy_file_range(in, nullptr, out, nullptr, chunk_size, 0); TR_ASSERT(copied == -1 || copied >= 0); /* -1 for error; some non-negative value otherwise. */ @@ -432,7 +432,7 @@ bool tr_sys_path_copy(char const* src_path, char const* dst_path, tr_error** err { while (file_size > 0U) { - size_t const chunk_size = std::min(file_size, uint64_t{ SSIZE_MAX }); + size_t const chunk_size = std::min({ file_size, uint64_t{ SSIZE_MAX }, uint64_t{ INT32_MAX } }); auto const copied = sendfile64(out, in, nullptr, chunk_size); TR_ASSERT(copied == -1 || copied >= 0); /* -1 for error; some non-negative value otherwise. */