commit: f5476d2af4cdd3e3a7973e9028b59178bb48b63d
parent 42d1bb319f92c6b029ce986e09662a032438e7db
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date: Fri, 27 Sep 2024 10:23:07 +0200
lib/fs: close manual_copy loop when read returns 0
Diffstat:
1 file changed, 1 insertion(+), 0 deletions(-)
diff --git a/lib/fs.c b/lib/fs.c
@@ -61,6 +61,7 @@ manual_file_copy(int fd_in, int fd_out, off_t len, int flags)
ssize_t nread = read(fd_in, buf, MIN(BUFSIZ, len));
if(nread < 0) return nread;
+ if(nread == 0) return wrote;
ssize_t nwrite = write(fd_out, buf, (size_t)nread);
if(nwrite < 0) return nwrite;