From aa69e4762d2e2ac495cea1a5553936944f369092 Mon Sep 17 00:00:00 2001 From: Daiki Ueno Date: Tue, 25 Jan 2022 07:30:43 +0100 Subject: [PATCH] Work around type mismatches on 32-bit platforms Signed-off-by: Daiki Ueno --- keylime-agent-rust-types.patch | 63 ++++++++++++++++++++++++++++++++++ keylime-agent-rust.spec | 1 + 2 files changed, 64 insertions(+) create mode 100644 keylime-agent-rust-types.patch diff --git a/keylime-agent-rust-types.patch b/keylime-agent-rust-types.patch new file mode 100644 index 0000000..0c1783b --- /dev/null +++ b/keylime-agent-rust-types.patch @@ -0,0 +1,63 @@ +diff --git a/src/common.rs b/src/common.rs +index b44cf39..e38385e 100644 +--- a/src/common.rs ++++ b/src/common.rs +@@ -252,7 +252,7 @@ pub(crate) fn chownroot(path: String) -> Result { + } + + // change directory owner to root +- if libc::chown(path.as_bytes().as_ptr() as *const i8, 0, 0) != 0 { ++ if libc::chown(path.as_bytes().as_ptr() as *const _, 0, 0) != 0 { + error!("Failed to change file {} owner.", path); + return Err(Error::Permission); + } +diff --git a/src/main.rs b/src/main.rs +index 4631836..d7598d7 100644 +--- a/src/main.rs ++++ b/src/main.rs +@@ -18,7 +18,7 @@ + missing_copy_implementations, + missing_debug_implementations, + missing_docs, +- trivial_casts, ++ //trivial_casts, + trivial_numeric_casts, + unused_allocation, + unused_comparisons, +diff --git a/src/tpm.rs b/src/tpm.rs +index f6ae1bb..dbcc848 100644 +--- a/src/tpm.rs ++++ b/src/tpm.rs +@@ -117,12 +117,12 @@ pub(crate) fn create_ek( + + fn unmarshal_tpms_attest(val: &[u8]) -> Result { + let mut resp = TPMS_ATTEST::default(); +- let mut offset = 0u64; ++ let mut offset = 0; + + unsafe { + let res = Tss2_MU_TPMS_ATTEST_Unmarshal( + val[..].as_ptr(), +- val.len() as u64, ++ val.len() as _, + &mut offset, + &mut resp, + ); +@@ -140,7 +140,7 @@ fn unmarshal_tpms_attest(val: &[u8]) -> Result { + macro_rules! create_marshal_fn { + ($func:ident, $tpmobj:ty, $marshal:ident) => { + fn $func(t: $tpmobj) -> Vec { +- let mut offset = 0u64; ++ let mut offset = 0; + let size = std::mem::size_of::<$tpmobj>(); + + let mut tpm_vec = Vec::with_capacity(size); +@@ -148,7 +148,7 @@ macro_rules! create_marshal_fn { + let res = $marshal( + &t, + tpm_vec.as_mut_ptr(), +- tpm_vec.capacity() as u64, ++ tpm_vec.capacity() as _, + &mut offset, + ); + if res != 0 { diff --git a/keylime-agent-rust.spec b/keylime-agent-rust.spec index e720b74..a1c19b4 100644 --- a/keylime-agent-rust.spec +++ b/keylime-agent-rust.spec @@ -55,6 +55,7 @@ Source0: %{url}/archive/%{commit}/rust-keylime-%{version}.tar.gz # cargo vendor # tar jcf rust-keylime-%%{version}-vendor.tar.xz vendor Source1: rust-keylime-%{version}-vendor.tar.xz +Patch1: keylime-agent-rust-types.patch ExclusiveArch: %{rust_arches}