mdbx: avoids infinite copy_file_range-loop when file is unexpectedly truncated.

Change-Id: I5a542a49fa4ac9ced8ca60266a084d52d3618804
This commit is contained in:
Leonid Yuriev 2019-07-07 18:41:36 +03:00
parent 30ac62ceec
commit 41de36e93d

View File

@ -11652,8 +11652,8 @@ static int __cold mdbx_env_copy_asis(MDBX_env *env, MDBX_txn *read_txn,
off_t out_offset = in_offset;
ssize_t bytes_copied = copy_file_range(
env->me_fd, &in_offset, fd, &out_offset, data_bytes - in_offset, 0);
if (bytes_copied < 0) {
rc = errno;
if (unlikely(bytes_copied <= 0)) {
rc = bytes_copied ? errno : MDBX_ENODATA;
break;
}
}