From 12233f42cf7bf1da87a48c3040222eeb5464f010 Mon Sep 17 00:00:00 2001 From: Stefan Berger Date: Fri, 12 Apr 2019 16:38:08 -0400 Subject: [PATCH] tpm2: sync: Use the ubsan fixes from upstream Signed-off-by: Stefan Berger --- src/tpm2/Entity.c | 9 +++------ src/tpm2/crypto/openssl/CryptEccMain.c | 10 +++------- 2 files changed, 6 insertions(+), 13 deletions(-) diff --git a/src/tpm2/Entity.c b/src/tpm2/Entity.c index 30e4f1e1..38c1ca57 100644 --- a/src/tpm2/Entity.c +++ b/src/tpm2/Entity.c @@ -3,7 +3,7 @@ /* Accessing properties for handles of various types */ /* Written by Ken Goldman */ /* IBM Thomas J. Watson Research Center */ -/* $Id: Entity.c 1259 2018-07-10 19:11:09Z kgoldman $ */ +/* $Id: Entity.c 1462 2019-04-10 18:13:35Z kgoldman $ */ /* */ /* Licenses and Notices */ /* */ @@ -55,7 +55,7 @@ /* arising in any way out of use or reliance upon this specification or any */ /* information herein. */ /* */ -/* (c) Copyright IBM Corp. and others, 2016 - 2018 */ +/* (c) Copyright IBM Corp. and others, 2016 - 2019 */ /* */ /********************************************************************************/ @@ -299,10 +299,7 @@ EntityGetAuthValue( break; } // Copy the authValue - if (!pAuth) /* libtpms changed begin (ubsan) */ - MemoryCopy2B(&auth->b, NULL, sizeof(auth->t.buffer)); - else - MemoryCopy2B(&auth->b, &pAuth->b, sizeof(auth->t.buffer)); /* libtpms changed end */ + MemoryCopy2B((TPM2B *)auth, (TPM2B *)pAuth, sizeof(auth->t.buffer)); MemoryRemoveTrailingZeros(auth); return auth->t.size; } diff --git a/src/tpm2/crypto/openssl/CryptEccMain.c b/src/tpm2/crypto/openssl/CryptEccMain.c index 3cc78586..bb6c6ced 100644 --- a/src/tpm2/crypto/openssl/CryptEccMain.c +++ b/src/tpm2/crypto/openssl/CryptEccMain.c @@ -3,7 +3,7 @@ /* */ /* Written by Ken Goldman */ /* IBM Thomas J. Watson Research Center */ -/* $Id: CryptEccMain.c 1370 2018-11-02 19:39:07Z kgoldman $ */ +/* $Id: CryptEccMain.c 1462 2019-04-10 18:13:35Z kgoldman $ */ /* */ /* Licenses and Notices */ /* */ @@ -55,7 +55,7 @@ /* arising in any way out of use or reliance upon this specification or any */ /* information herein. */ /* */ -/* (c) Copyright IBM Corp. and others, 2016 - 2018 */ +/* (c) Copyright IBM Corp. and others, 2016 - 2019 */ /* */ /********************************************************************************/ @@ -338,12 +338,8 @@ CryptGenerateR( for(iterations = 1; iterations < 1000000;) { int i; - const TPM2B *buf = NULL; /* libtpms changed begin (ubsan) */ - - if (name) - buf = &name->b; /* libtpms changed end */ CryptKDFa(CONTEXT_INTEGRITY_HASH_ALG, &gr.commitNonce.b, COMMIT_STRING, - buf /* libtpms */, &cntr.b, n.t.size * 8, r->t.buffer, &iterations, FALSE); + (TPM2B *)name, &cntr.b, n.t.size * 8, r->t.buffer, &iterations, FALSE); // "random" value must be less than the prime if(UnsignedCompareB(r->b.size, r->b.buffer, n.t.size, n.t.buffer) >= 0) continue;