Fix copyfile() regression introduced in 4e9b5c13

Caught in release cycle.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
Joachim Wiberg
2023-04-08 05:55:48 +02:00
parent e44aaa4fd5
commit ac7b4194cf
+8 -3
View File
@@ -71,8 +71,10 @@ static int adjust_target(const char *src, char **dst)
return isdir;
}
/* Actual copy loop, used by both copyfile() and fcopyfile()
* breaks loop on error and EOF */
/*
* Actual copy loop, used by both copyfile() and fcopyfile() breaks loop
* on error and EOF
*/
static ssize_t do_copy(int in, int out, size_t num, char *buffer, size_t len)
{
ssize_t ret = 0, size = -1;
@@ -89,8 +91,11 @@ static ssize_t do_copy(int in, int out, size_t num, char *buffer, size_t len)
break;
}
if (ret > 0)
if (ret > 0) {
if (size == -1)
size = 0;
size += write(out, buffer, ret);
}
num -= count;
} while (num > 0);