Skip to content

Commit 5a70253

Browse files
committed
A few more minor Coverity fixes.
1 parent 27d1a22 commit 5a70253

File tree

3 files changed

+11
-3
lines changed

3 files changed

+11
-3
lines changed

examples/attestation/make_credential.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ int TPM2_MakeCredential_Example(void* userCtx, int argc, char *argv[])
9999
}
100100

101101
XMEMSET(&primary, 0, sizeof(primary));
102+
XMEMSET(&handle, 0, sizeof(handle));
102103

103104
printf("Demo how to create a credential challenge for remote attestation\n");
104105
printf("Credential will be stored in %s\n", output);

examples/wrap/wrap_test.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -933,7 +933,6 @@ int TPM2_Wrapper_TestArgs(void* userCtx, int argc, char *argv[])
933933
}
934934
else if (WOLFTPM_IS_COMMAND_UNAVAILABLE(rc)) {
935935
printf("Encrypt/Decrypt: Is not a supported feature due to export controls\n");
936-
rc = TPM_RC_SUCCESS; /* clear error code */
937936
}
938937
else {
939938
printf("Encrypt/Decrypt test failed, result not as expected!\n");

src/tpm2_wrap.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1682,6 +1682,9 @@ int wolfTPM2_StartSession(WOLFTPM2_DEV* dev, WOLFTPM2_SESSION* session,
16821682
/* key is bindAuthValue || salt */
16831683
XMEMSET(&keyIn, 0, sizeof(keyIn));
16841684
if (bind && bind->auth.size > 0) {
1685+
if (bind->auth.size > (UINT16)sizeof(bind->auth.buffer)) {
1686+
return BUFFER_E;
1687+
}
16851688
if ((keyIn.size + bind->auth.size) > (UINT16)sizeof(keyIn.buffer)) {
16861689
return BUFFER_E;
16871690
}
@@ -1690,6 +1693,9 @@ int wolfTPM2_StartSession(WOLFTPM2_DEV* dev, WOLFTPM2_SESSION* session,
16901693
keyIn.size += bind->auth.size;
16911694
}
16921695
if (session->salt.size > 0) {
1696+
if (session->salt.size > (UINT16)sizeof(session->salt.buffer)) {
1697+
return BUFFER_E;
1698+
}
16931699
if ((keyIn.size + session->salt.size) > (UINT16)sizeof(keyIn.buffer)) {
16941700
return BUFFER_E;
16951701
}
@@ -3690,12 +3696,14 @@ int wolfTPM2_EccKey_TpmToWolf(WOLFTPM2_DEV* dev, WOLFTPM2_KEY* tpmKey,
36903696

36913697
/* load public key */
36923698
qxSz = tpmKey->pub.publicArea.unique.ecc.x.size;
3693-
if (qxSz > sizeof(qx)) {
3699+
if (qxSz > sizeof(qx) ||
3700+
qxSz > sizeof(tpmKey->pub.publicArea.unique.ecc.x.buffer)) {
36943701
return BUFFER_E;
36953702
}
36963703
XMEMCPY(qx, tpmKey->pub.publicArea.unique.ecc.x.buffer, qxSz);
36973704
qySz = tpmKey->pub.publicArea.unique.ecc.y.size;
3698-
if (qySz > sizeof(qy)) {
3705+
if (qySz > sizeof(qy) ||
3706+
qySz > sizeof(tpmKey->pub.publicArea.unique.ecc.y.buffer)) {
36993707
return BUFFER_E;
37003708
}
37013709
XMEMCPY(qy, tpmKey->pub.publicArea.unique.ecc.y.buffer, qySz);

0 commit comments

Comments
 (0)