mirror of
https://github.com/stefanberger/swtpm.git
synced 2026-02-05 22:54:09 +00:00
swtpm: Use write_full instead of plain write
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com> Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
This commit is contained in:
parent
2d921e663c
commit
ec355ee80c
@ -183,7 +183,7 @@ static int ctrlchannel_return_state(ptm_getstate *pgs, int fd)
|
||||
iov[1].iov_base, min(iov[1].iov_len, 1024));
|
||||
}
|
||||
|
||||
n = writev(fd, iov, iovcnt);
|
||||
n = writev_full(fd, iov, iovcnt);
|
||||
if (n < 0) {
|
||||
logprintf(STDERR_FILENO,
|
||||
"Error: Could not send response: %s\n", strerror(errno));
|
||||
@ -247,7 +247,7 @@ static int ctrlchannel_receive_state(ptm_setstate *pss, ssize_t n, int fd)
|
||||
|
||||
err_send_resp:
|
||||
pss->u.resp.tpm_result = htobe32(res);
|
||||
n = write(fd, pss, sizeof(pss->u.resp.tpm_result));
|
||||
n = write_full(fd, pss, sizeof(pss->u.resp.tpm_result));
|
||||
if (n < 0) {
|
||||
logprintf(STDERR_FILENO,
|
||||
"Error: Could not send response: %s\n", strerror(errno));
|
||||
@ -864,17 +864,12 @@ int ctrlchannel_process_fd(int fd,
|
||||
send_resp:
|
||||
TPM_PrintAll(" Ctrl Rsp:", " ", output.body, min(out_len, 1024));
|
||||
|
||||
n = write(fd, output.body, out_len);
|
||||
n = write_full(fd, output.body, out_len);
|
||||
if (n < 0) {
|
||||
logprintf(STDERR_FILENO,
|
||||
"Error: Could not send response: %s\n", strerror(errno));
|
||||
close(fd);
|
||||
fd = -1;
|
||||
} else if ((size_t)n != out_len) {
|
||||
logprintf(STDERR_FILENO,
|
||||
"Error: Could not send complete response\n");
|
||||
close(fd);
|
||||
fd = -1;
|
||||
}
|
||||
|
||||
return fd;
|
||||
|
||||
@ -51,6 +51,7 @@
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "logging.h"
|
||||
#include "utils.h"
|
||||
|
||||
#include <libtpms/tpm_library.h>
|
||||
|
||||
@ -245,12 +246,12 @@ static int _logprintf(int fd, const char *format, va_list ap, bool check_indent)
|
||||
|
||||
if (!check_indent || log_check_string(buf) >= 0) {
|
||||
if (log_prefix) {
|
||||
ret = write(fd, log_prefix, strlen(log_prefix));
|
||||
ret = write_full(fd, log_prefix, strlen(log_prefix));
|
||||
if (ret < 0)
|
||||
goto err_exit;
|
||||
len = ret;
|
||||
}
|
||||
ret = write(fd, buf, strlen(buf));
|
||||
ret = write_full(fd, buf, strlen(buf));
|
||||
if (ret < 0)
|
||||
goto err_exit;
|
||||
ret += len;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user