Fix compilation errors in the TPM 2 code

Fix compilation errors in the TPM 2 code.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
This commit is contained in:
Stefan Berger 2016-12-21 16:26:19 -05:00
parent 5e64f96378
commit b19b6ed343
7 changed files with 25 additions and 15 deletions

View File

@ -162,9 +162,8 @@ if $LD --help 2>&1 | $GREP '\-z now ' > /dev/null; then
fi
AC_SUBST([HARDENING_CFLAGS])
dnl FIXME: removed -Werror
if test "$test_CFLAGS" != set; then
CFLAGS="$CFLAGS -Wall -Wreturn-type -Wsign-compare"
CFLAGS="$CFLAGS -Wall -Werror -Wreturn-type -Wsign-compare"
fi
AC_CONFIG_FILES(Makefile \

View File

@ -349,8 +349,8 @@
#define CONTEXT_ENCRYPT_ALGORITHM AES
#define NV_CLOCK_UPDATE_INTERVAL 12
#define NUM_POLICY_PCR 1
#define MAX_COMMAND_SIZE 4096
#define MAX_RESPONSE_SIZE 4096
#define MAX_COMMAND_SIZE TPM_BUFFER_MAX
#define MAX_RESPONSE_SIZE TPM_BUFFER_MAX
#define ORDERLY_BITS 8
#define MAX_SYM_DATA 128
#define MAX_RNG_ENTROPY_SIZE 64

View File

@ -335,7 +335,7 @@ UINT16
TPMA_SESSION_Marshal(TPMA_SESSION *source, BYTE **buffer, INT32 *size)
{
UINT16 written = 0;
written += UINT8_Marshal(source, buffer, size);
written += UINT8_Marshal((UINT8 *)source, buffer, size);
return written;
}
@ -345,7 +345,7 @@ UINT16
TPMA_LOCALITY_Marshal(TPMA_LOCALITY *source, BYTE **buffer, INT32 *size)
{
UINT16 written = 0;
written += UINT8_Marshal(source, buffer, size);
written += UINT8_Marshal((UINT8 *)source, buffer, size);
return written;
}
@ -2088,7 +2088,7 @@ UINT16
TPMA_NV_Marshal(TPMA_NV *source, BYTE **buffer, INT32 *size)
{
UINT16 written = 0;
written += UINT32_Marshal(source, buffer, size);
written += UINT32_Marshal((UINT32 *)source, buffer, size);
return written;
}

View File

@ -142,12 +142,14 @@ _plat__NVEnable(
}
else
{
size_t ignore;
// If NVChip file exist, assume the size is correct
fseek(s_NVFile, 0, SEEK_END);
assert(ftell(s_NVFile) == NV_MEMORY_SIZE);
// read NV file data to memory
fseek(s_NVFile, 0, SEEK_SET);
fread(s_NV, NV_MEMORY_SIZE, 1, s_NVFile);
ignore = fread(s_NV, NV_MEMORY_SIZE, 1, s_NVFile);
(void)ignore;
}
#endif
// NV contents have been read and the error checks have been performed. For

View File

@ -72,6 +72,12 @@
canceled */
extern int s_isCanceled;
#include <time.h>
#ifndef __CYGWIN__
typedef struct {
time_t tv_sec; // Seconds - >= 0
long tv_nsec; // Nanoseconds - [0, 999999999]
} timespec_t;
#endif
#ifndef HARDWARE_CLOCK
/* This is the value returned the last time that the system clock was read. This is only relevant
for a simulator or virtual TPM. */

View File

@ -190,6 +190,9 @@ TpmFail(
int code
)
{
#if 0
UINT32 *failFuncp;
#endif
// Save the values that indicate where the error occurred.
// On a 64-bit machine, this may truncate the address of the string
// of the function name where the error occurred.
@ -197,7 +200,7 @@ TpmFail(
s_failFunction = *(UINT32 *)&function;
s_failLine = line;
#else
s_failFunction = (UINT32)NULL;
s_failFunction = (UINT32)0;
s_failLine = 0;
#endif
s_failCode = code;

View File

@ -470,7 +470,7 @@ TPMA_ALGORITHM_Unmarshal(TPMA_ALGORITHM *target, BYTE **buffer, INT32 *size)
TPM_RC rc = TPM_RC_SUCCESS;
if (rc == TPM_RC_SUCCESS) {
rc = UINT32_Unmarshal(target, buffer, size);
rc = UINT32_Unmarshal((UINT32 *)target, buffer, size);
}
if (rc == TPM_RC_SUCCESS) {
if (*target & TPMA_ALGORITHM_reserved) {
@ -488,7 +488,7 @@ TPMA_OBJECT_Unmarshal(TPMA_OBJECT *target, BYTE **buffer, INT32 *size)
TPM_RC rc = TPM_RC_SUCCESS;
if (rc == TPM_RC_SUCCESS) {
rc = UINT32_Unmarshal(target, buffer, size);
rc = UINT32_Unmarshal((UINT32 *)target, buffer, size);
}
if (rc == TPM_RC_SUCCESS) {
if (*target & TPMA_OBJECT_reserved) {
@ -506,7 +506,7 @@ TPMA_SESSION_Unmarshal(TPMA_SESSION *target, BYTE **buffer, INT32 *size)
TPM_RC rc = TPM_RC_SUCCESS;
if (rc == TPM_RC_SUCCESS) {
rc = UINT8_Unmarshal(target, buffer, size);
rc = UINT8_Unmarshal((UINT8 *)target, buffer, size);
}
if (rc == TPM_RC_SUCCESS) {
if (*target & TPMA_SESSION_reserved) {
@ -524,7 +524,7 @@ TPMA_LOCALITY_Unmarshal(TPMA_LOCALITY *target, BYTE **buffer, INT32 *size)
TPM_RC rc = TPM_RC_SUCCESS;
if (rc == TPM_RC_SUCCESS) {
rc = UINT8_Unmarshal(target, buffer, size);
rc = UINT8_Unmarshal((UINT8 *)target, buffer, size);
}
return rc;
}
@ -537,7 +537,7 @@ TPMA_CC_Unmarshal(TPMA_CC *target, BYTE **buffer, INT32 *size)
TPM_RC rc = TPM_RC_SUCCESS;
if (rc == TPM_RC_SUCCESS) {
rc = UINT32_Unmarshal(target, buffer, size);
rc = UINT32_Unmarshal((UINT32 *)target, buffer, size);
}
if (rc == TPM_RC_SUCCESS) {
if (*target & TPMA_CC_reserved) {
@ -4212,7 +4212,7 @@ TPMA_NV_Unmarshal(TPMA_NV *target, BYTE **buffer, INT32 *size)
TPM_RC rc = TPM_RC_SUCCESS;
if (rc == TPM_RC_SUCCESS) {
rc = UINT32_Unmarshal(target, buffer, size);
rc = UINT32_Unmarshal((UINT32 *)target, buffer, size);
}
if (rc == TPM_RC_SUCCESS) {
if (*target & TPMA_NV_RESERVED) {