]> git.proxmox.com Git - swtpm.git/commitdiff
Fix compilation errors on Debian Jessie 32bit ARM
authorStefan Berger <stefanb@linux.vnet.ibm.com>
Wed, 31 May 2017 17:45:42 +0000 (13:45 -0400)
committerStefan Berger <stefanb@linux.vnet.ibm.com>
Wed, 31 May 2017 17:45:44 +0000 (13:45 -0400)
Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
src/swtpm/ctrlchannel.c
src/swtpm_ioctl/tpm_ioctl.c

index d01e5a074a04bd103bf3d5a14567c83f8262f5d1..2c45d3be28a9be38c84d2e670780b3ef20334596 100644 (file)
@@ -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;
         }
index 0c7f5cc545b411e3bb19a038f4fdb15ee3f4ffc4..5b9333591b527c416ba15b8e8c331af222c94e93 100644 (file)
@@ -49,6 +49,7 @@
  *     -C cancel an ongoing TPM command
  */
 
+#include <inttypes.h>
 #include <stdio.h>
 #include <string.h>
 #include <stdlib.h>
@@ -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);