From 768d657b695e8760a017dbe61de4ed437b80d3b8 Mon Sep 17 00:00:00 2001 From: Stefan Berger Date: Wed, 31 May 2017 13:45:42 -0400 Subject: [PATCH] Fix compilation errors on Debian Jessie 32bit ARM Signed-off-by: Stefan Berger --- src/swtpm/ctrlchannel.c | 2 +- src/swtpm_ioctl/tpm_ioctl.c | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/swtpm/ctrlchannel.c b/src/swtpm/ctrlchannel.c index d01e5a0..2c45d3b 100644 --- a/src/swtpm/ctrlchannel.c +++ b/src/swtpm/ctrlchannel.c @@ -179,7 +179,7 @@ static int ctrlchannel_receive_state(ptm_setstate *pss, ssize_t n, int fd) /* n holds the number of available data bytes */ while (true) { - if (n > remain) { + if (n < 0 || (uint32_t)n > remain) { res = TPM_BAD_PARAMETER; goto err_send_resp; } diff --git a/src/swtpm_ioctl/tpm_ioctl.c b/src/swtpm_ioctl/tpm_ioctl.c index 0c7f5cc..5b93335 100644 --- a/src/swtpm_ioctl/tpm_ioctl.c +++ b/src/swtpm_ioctl/tpm_ioctl.c @@ -49,6 +49,7 @@ * -C cancel an ongoing TPM command */ +#include #include #include #include @@ -303,7 +304,7 @@ static int do_save_state_blob(int fd, bool is_chardev, const char *blobtype, numbytes = write(file_fd, pgs.u.resp.data, devtoh32(is_chardev, pgs.u.resp.length)); - if (numbytes != devtoh32(is_chardev, pgs.u.resp.length)) { + if ((uint32_t)numbytes != devtoh32(is_chardev, pgs.u.resp.length)) { fprintf(stderr, "Could not write to file '%s': %s\n", filename, strerror(errno)); @@ -420,7 +421,7 @@ static int do_load_state_blob(int fd, bool is_chardev, const char *blobtype, had_error = true; break; } - pss.u.req.length = htodev32(is_chardev, numbytes); + pss.u.req.length = htodev32(is_chardev, (uint32_t)numbytes); /* the returnsize is zero on all intermediate packets */ returnsize = ((size_t)numbytes < sizeof(pss.u.req.data)) @@ -863,7 +864,8 @@ int main(int argc, char *argv[]) return EXIT_FAILURE; } /* no tpm_result here */ - printf("ptm capability is 0x%lx\n", (uint64_t)devtoh64(is_chardev, cap)); + printf("ptm capability is 0x%" PRIx64 "\n", + (uint64_t)devtoh64(is_chardev, cap)); } else if (!strcmp(command, "-i")) { init.u.req.init_flags = htodev32(is_chardev, PTM_INIT_FLAG_DELETE_VOLATILE); -- 2.39.5