Avoid diagnostic from gcc-11

This commit is contained in:
Jeff Law 2020-12-07 21:58:29 -07:00
parent 7bb245e958
commit 15719b9d51
2 changed files with 24 additions and 2 deletions

18
swtpm-gcc11.patch Normal file
View File

@ -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;

View File

@ -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 <law@redhat.com> - 0.5.1-3.20201117git96f5a04c
- Avoid diagnostic from gcc-11
* Tue Nov 13 2020 Stefan Berger <stefanb@linux.ibm.com> - 0.5.1-2.20201117git96f5a04c
- Another build of v0.5.1 after more fixes