From 15719b9d51a38053575a822888170b344dc55db7 Mon Sep 17 00:00:00 2001 From: Jeff Law Date: Mon, 7 Dec 2020 21:58:29 -0700 Subject: [PATCH] Avoid diagnostic from gcc-11 --- swtpm-gcc11.patch | 18 ++++++++++++++++++ swtpm.spec | 8 ++++++-- 2 files changed, 24 insertions(+), 2 deletions(-) create mode 100644 swtpm-gcc11.patch diff --git a/swtpm-gcc11.patch b/swtpm-gcc11.patch new file mode 100644 index 0000000..eba16fc --- /dev/null +++ b/swtpm-gcc11.patch @@ -0,0 +1,18 @@ +diff --git a/src/swtpm/ctrlchannel.c b/src/swtpm/ctrlchannel.c +index f76a68b..f847960 100644 +--- a/src/swtpm/ctrlchannel.c ++++ b/src/swtpm/ctrlchannel.c +@@ -691,7 +691,12 @@ int ctrlchannel_process_fd(int fd, + + data = (ptm_hdata *)&output.body; + +- data->u.resp.tpm_result = htobe32(res); ++ /* gcc-11 flags this code with a diagnostic. I'm not sure the diagnostic ++ is valid, but regardless, this is reasonable workaround. Essentially ++ we are trying to obfuscate the above cast and store below from the ++ analysis for out of bounds object access diagnostics. */ ++ uint32_t __x = htobe32(res); ++ memcpy (&data->u.resp.tpm_result, &__x, sizeof (__x)); + out_len = sizeof(data->u.resp.tpm_result); + + break; diff --git a/swtpm.spec b/swtpm.spec index 34f0988..0fc97aa 100644 --- a/swtpm.spec +++ b/swtpm.spec @@ -12,10 +12,11 @@ Summary: TPM Emulator Name: swtpm Version: 0.5.1 -Release: 2.%{gitdate}git%{gitshortcommit}%{?dist} +Release: 3.%{gitdate}git%{gitshortcommit}%{?dist} License: BSD Url: http://github.com/stefanberger/swtpm Source0: %{url}/archive/%{gitcommit}/%{name}-%{gitshortcommit}.tar.gz +Patch0: %{name}-gcc11.patch BuildRequires: git-core BuildRequires: automake @@ -89,7 +90,7 @@ Requires: expect gnutls-utils trousers >= 0.3.9 Tools for creating a local CA based on a pkcs11 device %prep -%autosetup -S git -n %{name}-%{gitcommit} +%autosetup -S git -n %{name}-%{gitcommit} -p1 %build @@ -185,6 +186,9 @@ fi %{_datadir}/swtpm/swtpm-create-tpmca %changelog +* Mon Dec 07 2020 Jeff Law - 0.5.1-3.20201117git96f5a04c +- Avoid diagnostic from gcc-11 + * Tue Nov 13 2020 Stefan Berger - 0.5.1-2.20201117git96f5a04c - Another build of v0.5.1 after more fixes