commit: ab0fb955dafeca34d6c7e7f9eced128ee08dd5c5
parent 07e96a8fec3f7fe6b8d20d3756bea86fc74e8029
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date: Fri, 27 Sep 2024 14:51:34 +0200
lib/fs: only exit sendfile loop when it returned 0
Otherwise some large files somehow would end up incomplete.
Diffstat:
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/lib/fs.c b/lib/fs.c
@@ -105,6 +105,7 @@ ssize_t
auto_fd_copy(int fd_in, int fd_out, size_t len)
{
off_t *off = NULL;
+ ssize_t wrote = 0;
while(1)
{
@@ -125,7 +126,10 @@ auto_fd_copy(int fd_in, int fd_out, size_t len)
}
}
- return ret;
+ wrote += ret;
+ len -= ret;
+
+ if(ret == 0) return wrote;
}
return -1;