Skip to content

Commit 309c9c1

Browse files
derrickstoleedscho
authored andcommitted
gvfs-helper: do one read in my_copy_fd_len_tail()
Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
1 parent 09758b9 commit 309c9c1

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

gvfs-helper.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2034,18 +2034,18 @@ static int my_copy_fd_len_tail(int fd_in, int fd_out, ssize_t nr_bytes_total,
20342034
{
20352035
memset(buf_tail, 0, tail_len);
20362036

2037+
if (my_copy_fd_len(fd_in, fd_out, nr_bytes_total) < 0)
2038+
return -1;
2039+
20372040
if (nr_bytes_total < tail_len)
2038-
return my_copy_fd_len(fd_in, fd_out, nr_bytes_total);
2041+
return 0;
20392042

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

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

2046-
if (write_in_full(fd_out, buf_tail, tail_len) < 0)
2047-
return -1;
2048-
20492049
return 0;
20502050
}
20512051

0 commit comments

Comments
 (0)