diff options
author | Laurent Bercot <ska-skaware@skarnet.org> | 2022-07-18 12:39:01 +0000 |
---|---|---|
committer | Laurent Bercot <ska@appnovation.com> | 2022-07-18 12:39:01 +0000 |
commit | 69fb8c62a31e767be1464a7ccfe2a5bac331c4cc (patch) | |
tree | 5d444d670920f6ea7aaef36a426479541fdfb752 /src/libstddjb/fd_catn.c | |
parent | c555cd2ba1682f90fb5344d2865713fcd0f3c3e1 (diff) | |
download | skalibs-69fb8c62a31e767be1464a7ccfe2a5bac331c4cc.tar.xz |
Fix allread errno management
Signed-off-by: Laurent Bercot <ska@appnovation.com>
Diffstat (limited to 'src/libstddjb/fd_catn.c')
-rw-r--r-- | src/libstddjb/fd_catn.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/libstddjb/fd_catn.c b/src/libstddjb/fd_catn.c index 182a054..4f1016e 100644 --- a/src/libstddjb/fd_catn.c +++ b/src/libstddjb/fd_catn.c @@ -14,10 +14,12 @@ off_t fd_catn (int from, int to, off_t n) char buf[BSIZE] ; while (n >= BSIZE) { + size_t v ; ssize_t r = fd_read(from, buf, BSIZE) ; if (r == -1) return w ; if (!r) return (errno = EPIPE, w) ; - if (allwrite(to, buf, r) < r) return w ; + v = allwrite(to, buf, r) ; + if (v < r) return w + v ; n -= r ; w += r ; } |