Skip to content

Commit 56ef18f

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 bbd84e6 commit 56ef18f

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
@@ -2047,18 +2047,18 @@ static int my_copy_fd_len_tail(int fd_in, int fd_out, ssize_t nr_bytes_total,
20472047
{
20482048
memset(buf_tail, 0, tail_len);
20492049

2050+
if (my_copy_fd_len(fd_in, fd_out, nr_bytes_total) < 0)
2051+
return -1;
2052+
20502053
if (nr_bytes_total < tail_len)
2051-
return my_copy_fd_len(fd_in, fd_out, nr_bytes_total);
2054+
return 0;
20522055

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

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

2059-
if (write_in_full(fd_out, buf_tail, tail_len) < 0)
2060-
return -1;
2061-
20622062
return 0;
20632063
}
20642064

0 commit comments

Comments
 (0)