From 1dd38afaf15ef3b9d5922138ffc72d0d105b8492 Mon Sep 17 00:00:00 2001 From: Derrick Stolee Date: Mon, 16 Dec 2019 13:12:32 -0500 Subject: [PATCH] gvfs-helper: do one read in my_copy_fd_len_tail() Signed-off-by: Derrick Stolee --- gvfs-helper.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/gvfs-helper.c b/gvfs-helper.c index c7ab63263c..c5a0012277 100644 --- a/gvfs-helper.c +++ b/gvfs-helper.c @@ -2039,18 +2039,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 (nr_bytes_total < tail_len) - return my_copy_fd_len(fd_in, fd_out, nr_bytes_total); - - if (my_copy_fd_len(fd_in, fd_out, (nr_bytes_total - tail_len)) < 0) + if (my_copy_fd_len(fd_in, fd_out, nr_bytes_total) < 0) return -1; + if (nr_bytes_total < tail_len) + return 0; + + /* 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; }