tpm2: sync: Use the ubsan fixes from upstream

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
This commit is contained in:
Stefan Berger 2019-04-12 16:38:08 -04:00 committed by Stefan Berger
parent 236a2fd119
commit 12233f42cf
2 changed files with 6 additions and 13 deletions

View File

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

View File

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