Skip to content

Commit

Permalink
gvfs-helper: do one read in my_copy_fd_len_tail()
Browse files Browse the repository at this point in the history
Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
  • Loading branch information
derrickstolee committed Aug 31, 2022
1 parent cf506d5 commit 32b0299
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions gvfs-helper.c
Original file line number Diff line number Diff line change
Expand Up @@ -2028,18 +2028,18 @@ static int my_copy_fd_len_tail(int fd_in, int fd_out, ssize_t nr_bytes_total,
{
memset(buf_tail, 0, tail_len);

if (my_copy_fd_len(fd_in, fd_out, nr_bytes_total) < 0)
return -1;

if (nr_bytes_total < tail_len)
return my_copy_fd_len(fd_in, fd_out, nr_bytes_total);
return 0;

if (my_copy_fd_len(fd_in, fd_out, (nr_bytes_total - tail_len)) < 0)
return -1;
/* Reset the position to read the tail */
lseek(fd_in, -tail_len, SEEK_CUR);

if (xread(fd_in, (char *)buf_tail, tail_len) != tail_len)
return -1;

if (write_in_full(fd_out, buf_tail, tail_len) < 0)
return -1;

return 0;
}

Expand Down

0 comments on commit 32b0299

Please sign in to comment.