From a55577bd2a0e6fea33ea3c5a51f34f7d81a74cde Mon Sep 17 00:00:00 2001 From: Stefan Berger Date: Wed, 11 Jul 2018 12:17:16 -0400 Subject: [PATCH] rev148: Rework RUNTIME_SIZE_CHECKS Signed-off-by: Stefan Berger --- src/tpm2/Manufacture.c | 2 +- src/tpm2/TpmBuildSwitches.h | 17 ++++++++++------- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/tpm2/Manufacture.c b/src/tpm2/Manufacture.c index 460b8e56..728e7dc4 100644 --- a/src/tpm2/Manufacture.c +++ b/src/tpm2/Manufacture.c @@ -83,7 +83,7 @@ TPM_Manufacture( ) { TPM_SU orderlyShutdown; -#ifdef RUNTIME_SIZE_CHECKS +#if RUNTIME_SIZE_CHECKS // Call the function to verify the sizes of values that result from different // compile options. TpmSizeChecks(); diff --git a/src/tpm2/TpmBuildSwitches.h b/src/tpm2/TpmBuildSwitches.h index a7b3835c..af1d74a1 100644 --- a/src/tpm2/TpmBuildSwitches.h +++ b/src/tpm2/TpmBuildSwitches.h @@ -173,13 +173,16 @@ #ifndef COMPILER_CHECKS //# define COMPILER_CHECKS #endif -/* Some of the values (such as sizes) are the result of different options set in - Implementation.h. The combination might not be consistent. A function is defined - (TpmSizeChecks()) that is used to verify the sizes at run time. To enable the function, define - this parameter. */ -#ifndef RUNTIME_SIZE_CHECKS -#define RUNTIME_SIZE_CHECKS -#endif +// Some of the values (such as sizes) are the result of different options set in +// Implementation.h. The combination might not be consistent. A function is defined +// (TpmSizeChecks()) that is used to verify the sizes at run time. To enable the function, define +// this parameter. +# if !(defined RUNTIME_SIZE_CHECKS) \ + || ((RUNTIME_SIZE_CHECKS != NO) && (RUNTIME_SIZE_CHECKS != YES)) +# undef RUNTIME_SIZE_CHECKS +# define RUNTIME_SIZE_CHECKS NO // Default: Either YES or NO +# endif + /* If doing debug, can set the DRBG to print out the intermediate test values. Before enabling this, make sure that the dbgDumpMemBlock() function has been added someplace (preferably, somewhere in