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/journal/journalctl.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/journal/journalctl.c')
-rw-r--r-- | src/journal/journalctl.c | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/src/journal/journalctl.c b/src/journal/journalctl.c index 3cec9a0c84..b2f6966fca 100644 --- a/src/journal/journalctl.c +++ b/src/journal/journalctl.c @@ -1406,17 +1406,15 @@ static int setup_keys(void) { h.fsprg_secpar = htole16(FSPRG_RECOMMENDED_SECPAR); h.fsprg_state_size = htole64(state_size); - l = loop_write(fd, &h, sizeof(h), false); - if (l < 0 || (size_t) l != sizeof(h)) { - log_error_errno(EIO, "Failed to write header: %m"); - r = -EIO; + r = loop_write(fd, &h, sizeof(h), false); + if (r < 0) { + log_error_errno(r, "Failed to write header: %m"); goto finish; } - l = loop_write(fd, state, state_size, false); - if (l < 0 || (size_t) l != state_size) { - log_error_errno(EIO, "Failed to write state: %m"); - r = -EIO; + r = loop_write(fd, state, state_size, false); + if (r < 0) { + log_error_errno(r, "Failed to write state: %m"); goto finish; } |