diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2014-12-01 20:43:19 -0500 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2014-12-09 21:36:08 -0500 |
commit | 553acb7b6b8d4f16a4747b1f978e8b7888fbfb2c (patch) | |
tree | b9a473c853c616b256ed3ea1dc5f8e9c7838b289 /src/shared/copy.c | |
parent | cb01aedc3b4ba70859267159fe716253e3551ec6 (diff) |
treewide: sanitize loop_write
loop_write() didn't follow the usual systemd rules and returned status
partially in errno and required extensive checks from callers. Some of
the callers dealt with this properly, but many did not, treating
partial writes as successful. Simplify things by conforming to usual rules.
Diffstat (limited to 'src/shared/copy.c')
-rw-r--r-- | src/shared/copy.c | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/src/shared/copy.c b/src/shared/copy.c index abb7fbc52b..b8b1ba1866 100644 --- a/src/shared/copy.c +++ b/src/shared/copy.c @@ -63,7 +63,7 @@ int copy_bytes(int fdf, int fdt, off_t max_bytes) { /* As a fallback just copy bits by hand */ { char buf[m]; - ssize_t k; + int r; n = read(fdf, buf, m); if (n < 0) @@ -71,12 +71,9 @@ int copy_bytes(int fdf, int fdt, off_t max_bytes) { if (n == 0) /* EOF */ break; - errno = 0; - k = loop_write(fdt, buf, n, false); - if (k < 0) - return k; - if (k != n) - return errno ? -errno : -EIO; + r = loop_write(fdt, buf, n, false); + if (r < 0) + return r; } |