Update to 2.1.1 release

This commit updates the tpm2-tools package to version 2.1.1. It also does
some cleanups such as changing the prefixes to tpm2-tools that is the new
name for the upstream project repository. Since this matches the pkg name
the global pkg_prefix can be removed.

It also removes the downstream patches since these are already present in
the latest upstream release.

resolves: rhbz#1504438

Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
This commit is contained in:
Javier Martinez Canillas 2017-11-01 22:40:42 +01:00
parent 3d1352694e
commit 565cd7e724
No known key found for this signature in database
GPG Key ID: C751E590D63F3D69
5 changed files with 12 additions and 158 deletions

View File

@ -1,31 +0,0 @@
From 5b84837757cab93397cfa5830e69d2b7e7ce0e0c Mon Sep 17 00:00:00 2001
From: Jerry Snitselaar <jsnitsel@redhat.com>
Date: Wed, 18 Oct 2017 21:46:45 -0700
Subject: [PATCH] lib: clean up potential memory leak
In case where sapi_ctx_init fails in sapi_init_from_options, free tcti_ctx.
Signed-off-by: Jerry Snitselaar <jsnitsel@redhat.com>
---
lib/context-util.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/lib/context-util.c b/lib/context-util.c
index 7de22ac..c3034f9 100644
--- a/lib/context-util.c
+++ b/lib/context-util.c
@@ -205,8 +205,10 @@ sapi_init_from_options (common_opts_t *options)
if (tcti_ctx == NULL)
return NULL;
sapi_ctx = sapi_ctx_init (tcti_ctx);
- if (sapi_ctx == NULL)
+ if (sapi_ctx == NULL) {
+ free (tcti_ctx);
return NULL;
+ }
return sapi_ctx;
}
/*
--
2.15.0.rc0

View File

@ -1,87 +0,0 @@
diff -ruN tpm2.0-tools-2.1.0-orig/lib/tpm_kdfa.c tpm2.0-tools-2.1.0/lib/tpm_kdfa.c
--- tpm2.0-tools-2.1.0-orig/lib/tpm_kdfa.c 2017-07-25 01:50:33.000000000 +0800
+++ tpm2.0-tools-2.1.0/lib/tpm_kdfa.c 2017-08-15 10:48:23.063493627 +0800
@@ -51,6 +51,34 @@
/* no return, not possible */
}
+static HMAC_CTX *hmac_alloc()
+{
+ HMAC_CTX *ctx;
+#if OPENSSL_VERSION_NUMBER < 0x1010000fL /* OpenSSL 1.1.0 */
+ ctx = malloc(sizeof(*ctx));
+#else
+ ctx = HMAC_CTX_new();
+#endif
+ if (!ctx)
+ return NULL;
+
+#if OPENSSL_VERSION_NUMBER < 0x1010000fL
+ HMAC_CTX_init(ctx);
+#endif
+
+ return ctx;
+}
+
+static void hmac_del(HMAC_CTX *ctx)
+{
+#if OPENSSL_VERSION_NUMBER < 0x1010000fL
+ HMAC_CTX_cleanup(ctx);
+ free(ctx);
+#else
+ HMAC_CTX_free(ctx);
+#endif
+}
+
TPM_RC tpm_kdfa(TPMI_ALG_HASH hashAlg,
TPM2B *key, char *label, TPM2B *contextU, TPM2B *contextV, UINT16 bits,
TPM2B_MAX_BUFFER *resultKey )
@@ -90,12 +118,17 @@
return TPM_RC_HASH;
}
- HMAC_CTX ctx;
- HMAC_CTX_init(&ctx);
- int rc = HMAC_Init_ex(&ctx, key->buffer, key->size, md, NULL);
+ HMAC_CTX *ctx = hmac_alloc();
+ if (!ctx) {
+ LOG_ERR("HMAC context allocation failed");
+ return TPM_RC_MEMORY;
+ }
+
+ int rc = HMAC_Init_ex(ctx, key->buffer, key->size, md, NULL);
if (!rc) {
LOG_ERR("HMAC Init failed: %s", ERR_error_string(rc, NULL));
- return TPM_RC_MEMORY;
+ rval = TPM_RC_MEMORY;
+ goto err;
}
// TODO Why is this a loop? It appears to only execute once.
@@ -118,7 +151,7 @@
int c;
for(c=0; c < j; c++) {
TPM2B_DIGEST *digest = bufferList[c];
- int rc = HMAC_Update(&ctx, digest->b.buffer, digest->b.size);
+ int rc = HMAC_Update(ctx, digest->b.buffer, digest->b.size);
if (!rc) {
LOG_ERR("HMAC Update failed: %s", ERR_error_string(rc, NULL));
rval = TPM_RC_MEMORY;
@@ -127,7 +160,7 @@
}
unsigned size = sizeof(tmpResult.t.buffer);
- int rc = HMAC_Final(&ctx, tmpResult.t.buffer, &size);
+ int rc = HMAC_Final(ctx, tmpResult.t.buffer, &size);
if (!rc) {
LOG_ERR("HMAC Final failed: %s", ERR_error_string(rc, NULL));
rval = TPM_RC_MEMORY;
@@ -147,7 +180,7 @@
resultKey->t.size = bytes;
err:
- HMAC_CTX_cleanup(&ctx);
+ hmac_del(ctx);
return rval;
}

View File

@ -1,24 +0,0 @@
diff -ru tpm2.0-tools-2.1.0-orig/tools/main.c tpm2.0-tools-2.1.0/tools/main.c
--- tpm2.0-tools-2.1.0-orig/tools/main.c 2017-07-31 14:26:37.436505592 +0800
+++ tpm2.0-tools-2.1.0/tools/main.c 2017-07-31 14:27:12.999707128 +0800
@@ -61,7 +61,7 @@
execute_man (argv[0], envp);
fprintf (stderr,
"failed to load manpage, check your environment / PATH\n");
- /* no break */
+ exit (1);
case 2:
exit (1);
}
diff -ru tpm2.0-tools-2.1.0-orig/tools/tpm2_dump_capability.c tpm2.0-tools-2.1.0/tools/tpm2_dump_capability.c
--- tpm2.0-tools-2.1.0-orig/tools/tpm2_dump_capability.c 2017-07-31 14:26:37.436505592 +0800
+++ tpm2.0-tools-2.1.0/tools/tpm2_dump_capability.c 2017-07-31 14:29:30.831488212 +0800
@@ -595,7 +595,7 @@
case TPM_CAP_COMMANDS:
dump_command_attr_array (capabilities->command.commandAttributes,
capabilities->command.count);
- /* no break */
+ break;
default:
return 1;
}

View File

@ -1,2 +1 @@
SHA512 (tpm2.0-tools-2.1.0.tar.gz) = 5488ffdc42a318fae9a307a333cdbce730a144cea847fe68546367c87689cd675d1376c1a638dc4eefa6231d4d7f7417215cc4eb606e999a757425f5097eb0c4
SHA512 (allow-to-build-with-openssl-1.1.x.patch) = 8f2e9878c7444536b9883fa0c01821686d53f9bedf349fca0893b3266d89f4554aeffc6e164c9f6996d43b6a48c05501b30bfe66fd6726c885c60378a3dfc5b4
SHA512 (tpm2-tools-2.1.1.tar.gz) = f376b6e77d5683746fcee622f603e396193718a3b0c4b57efc4969e489e8d221aba9dba4878d72f20d966434a9c20097bac33f42b9650e95bb7f03fe13dc2cda

View File

@ -1,20 +1,11 @@
Name: tpm2-tools
Version: 2.1.0
Release: 7%{?dist}
Version: 2.1.1
Release: 1%{?dist}
Summary: A TPM2.0 testing tool build upon TPM2.0-TSS
%global pkg_prefix tpm2.0-tools
License: BSD
URL: https://github.com/01org/tpm2.0-tools
Source0: https://github.com/01org/tpm2.0-tools/archive/%{version}.tar.gz#/%{pkg_prefix}-%{version}.tar.gz
# https://github.com/01org/tpm2.0-tools/pull/381
Patch0: gcc7-implict-fallthrough-fix.patch
# https://github.com/01org/tpm2-tools/commit/5cee30cbc3da
Patch1: allow-to-build-with-openssl-1.1.x.patch
# https://github.com/01org/tpm2-tools/pull/567
Patch2: 0001-lib-clean-up-potential-memory-leak.patch
URL: https://github.com/01org/tpm2-tools
Source0: https://github.com/01org/tpm2-tools/archive/%{version}.tar.gz#/%{name}-%{version}.tar.gz
BuildRequires: gcc-c++
BuildRequires: libtool
@ -39,7 +30,7 @@ Requires: tpm2-tss%{?_isa} >= 1.1.0-1%{?dist}
tpm2-tools is a batch of testing tools for tpm2.0. It is based on tpm2-tss.
%prep
%autosetup -p1 -n %{pkg_prefix}-%{version}
%autosetup -p1 -n %{name}-%{version}
./bootstrap
%build
@ -56,6 +47,12 @@ tpm2-tools is a batch of testing tools for tpm2.0. It is based on tpm2-tss.
%{_mandir}/man8/tpm2_*.8.gz
%changelog
* Wed Nov 01 2017 Javier Martinez Canillas <javierm@redhat.com> - 2.1.1-1
- Rename remaining tpm2.0-tools prefixes to tpm2-tools
- Remove global pkg_prefix since now the upstream repo and package names match
- Remove downstream patches since now these are in the latest upstream release
- Update to 2.1.1 release (RHBZ#1504438)
* Thu Oct 19 2017 Jerry Snitselaar <jsnitsel@redhat.com> - 2.1.0-7
- Clean up potential memleak (RHBZ#1503959)