diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2023-12-05 19:02:14 +0100 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2023-12-05 19:18:23 +0100 |
commit | f9568765d4d3d57de1ec01d85f0a0682920f4d10 (patch) | |
tree | e90215c3ef1a7a4bf8ce6372aecb66b0e35e4017 /src/tpm2-setup/tpm2-setup.c | |
parent | NEWS: finalize for v255-rc4 (diff) | |
download | systemd-f9568765d4d3d57de1ec01d85f0a0682920f4d10.tar.xz systemd-f9568765d4d3d57de1ec01d85f0a0682920f4d10.zip |
variuos: fwrite() does not set errno
The man page doesn't even mention errno. It just says that ferror() should
be used to check for errors. Those writes are unlikely to fail, but if they
do, errno might even be 0. Also, we have fflush_and_check() which does
additional paranoia around errno, because we apparently do not trust that
errno will always be set correctly.
Diffstat (limited to 'src/tpm2-setup/tpm2-setup.c')
-rw-r--r-- | src/tpm2-setup/tpm2-setup.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/tpm2-setup/tpm2-setup.c b/src/tpm2-setup/tpm2-setup.c index be34d166d7..0be7ffc6a5 100644 --- a/src/tpm2-setup/tpm2-setup.c +++ b/src/tpm2-setup/tpm2-setup.c @@ -284,7 +284,8 @@ static int run(int argc, char *argv[]) { if (runtime_key.pkey) { if (memcmp_nn(tpm2_key.fingerprint, tpm2_key.fingerprint_size, runtime_key.fingerprint, runtime_key.fingerprint_size) != 0) - return log_error_errno(SYNTHETIC_ERRNO(ENOTRECOVERABLE), "Saved runtime SRK differs from TPM SRK, refusing."); + return log_error_errno(SYNTHETIC_ERRNO(ENOTRECOVERABLE), + "Saved runtime SRK differs from TPM SRK, refusing."); if (arg_early) { log_info("SRK saved in '%s' matches SRK in TPM2.", runtime_key.path); @@ -351,7 +352,8 @@ static int run(int argc, char *argv[]) { return log_error_errno(r, "Failed to marshal TPM2_PUBLIC key."); if (fwrite(marshalled, 1, marshalled_size, f) != marshalled_size) - return log_error_errno(errno, "Failed to write SRK public key file '%s'.", tpm2b_public_path); + return log_error_errno(SYNTHETIC_ERRNO(EIO), + "Failed to write SRK public key file '%s'.", tpm2b_public_path); if (fchmod(fileno(f), 0444) < 0) return log_error_errno(errno, "Failed to adjust access mode of SRK public key file '%s' to 0444: %m", tpm2b_public_path); |