diff --git a/examples/attestation/make_credential.c b/examples/attestation/make_credential.c index b411603b..5a9ac64a 100644 --- a/examples/attestation/make_credential.c +++ b/examples/attestation/make_credential.c @@ -99,6 +99,7 @@ int TPM2_MakeCredential_Example(void* userCtx, int argc, char *argv[]) } XMEMSET(&primary, 0, sizeof(primary)); + XMEMSET(&handle, 0, sizeof(handle)); printf("Demo how to create a credential challenge for remote attestation\n"); printf("Credential will be stored in %s\n", output); diff --git a/examples/wrap/wrap_test.c b/examples/wrap/wrap_test.c index 2b22ecdf..564566cd 100644 --- a/examples/wrap/wrap_test.c +++ b/examples/wrap/wrap_test.c @@ -933,7 +933,6 @@ int TPM2_Wrapper_TestArgs(void* userCtx, int argc, char *argv[]) } else if (WOLFTPM_IS_COMMAND_UNAVAILABLE(rc)) { printf("Encrypt/Decrypt: Is not a supported feature due to export controls\n"); - rc = TPM_RC_SUCCESS; /* clear error code */ } else { printf("Encrypt/Decrypt test failed, result not as expected!\n"); diff --git a/src/tpm2_wrap.c b/src/tpm2_wrap.c index fb2237ec..fc8c6c33 100644 --- a/src/tpm2_wrap.c +++ b/src/tpm2_wrap.c @@ -1682,6 +1682,9 @@ int wolfTPM2_StartSession(WOLFTPM2_DEV* dev, WOLFTPM2_SESSION* session, /* key is bindAuthValue || salt */ XMEMSET(&keyIn, 0, sizeof(keyIn)); if (bind && bind->auth.size > 0) { + if (bind->auth.size > (UINT16)sizeof(bind->auth.buffer)) { + return BUFFER_E; + } if ((keyIn.size + bind->auth.size) > (UINT16)sizeof(keyIn.buffer)) { return BUFFER_E; } @@ -1690,6 +1693,9 @@ int wolfTPM2_StartSession(WOLFTPM2_DEV* dev, WOLFTPM2_SESSION* session, keyIn.size += bind->auth.size; } if (session->salt.size > 0) { + if (session->salt.size > (UINT16)sizeof(session->salt.buffer)) { + return BUFFER_E; + } if ((keyIn.size + session->salt.size) > (UINT16)sizeof(keyIn.buffer)) { return BUFFER_E; } @@ -3690,12 +3696,14 @@ int wolfTPM2_EccKey_TpmToWolf(WOLFTPM2_DEV* dev, WOLFTPM2_KEY* tpmKey, /* load public key */ qxSz = tpmKey->pub.publicArea.unique.ecc.x.size; - if (qxSz > sizeof(qx)) { + if (qxSz > sizeof(qx) || + qxSz > sizeof(tpmKey->pub.publicArea.unique.ecc.x.buffer)) { return BUFFER_E; } XMEMCPY(qx, tpmKey->pub.publicArea.unique.ecc.x.buffer, qxSz); qySz = tpmKey->pub.publicArea.unique.ecc.y.size; - if (qySz > sizeof(qy)) { + if (qySz > sizeof(qy) || + qySz > sizeof(tpmKey->pub.publicArea.unique.ecc.y.buffer)) { return BUFFER_E; } XMEMCPY(qy, tpmKey->pub.publicArea.unique.ecc.y.buffer, qySz);