Skip to content

Commit bad0c3f

Browse files
committed
Fix finding 417
1 parent c4a126c commit bad0c3f

1 file changed

Lines changed: 9 additions & 13 deletions

File tree

src/tpm2_wrap.c

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5026,9 +5026,8 @@ static int wolfTPM2_NVWriteData(WOLFTPM2_DEV* dev, WOLFTPM2_SESSION* tpmSession,
50265026

50275027
/* Necessary, because NVWrite has two handles, second is NV Index
50285028
* If policy session Name will update via nonceTPM each iteration */
5029-
rc = wolfTPM2_SetAuthHandleName(dev, 0, &nv->handle);
5030-
rc |= wolfTPM2_SetAuthHandleName(dev, 1, &nv->handle);
5031-
if (rc != TPM_RC_SUCCESS) {
5029+
if ((wolfTPM2_SetAuthHandleName(dev, 0, &nv->handle) != 0) ||
5030+
(wolfTPM2_SetAuthHandleName(dev, 1, &nv->handle) != 0)) {
50325031
#ifdef DEBUG_WOLFTPM
50335032
printf("wolfTPM2_NVWriteData: Setting NV index name failed\n");
50345033
#endif
@@ -5152,9 +5151,8 @@ int wolfTPM2_NVReadAuthPolicy(WOLFTPM2_DEV* dev, WOLFTPM2_SESSION* tpmSession,
51525151

51535152
/* Necessary, because NVWrite has two handles, second is NV Index
51545153
* If policy session Name will update via nonceTPM each iteration */
5155-
rc = wolfTPM2_SetAuthHandleName(dev, 0, &nv->handle);
5156-
rc |= wolfTPM2_SetAuthHandleName(dev, 1, &nv->handle);
5157-
if (rc != TPM_RC_SUCCESS) {
5154+
if ((wolfTPM2_SetAuthHandleName(dev, 0, &nv->handle) != 0) ||
5155+
(wolfTPM2_SetAuthHandleName(dev, 1, &nv->handle) != 0)) {
51585156
#ifdef DEBUG_WOLFTPM
51595157
printf("Setting NV index name failed\n");
51605158
#endif
@@ -5367,13 +5365,12 @@ int wolfTPM2_NVIncrement(WOLFTPM2_DEV* dev, WOLFTPM2_NV* nv)
53675365
}
53685366

53695367
/* Necessary, because NVRead has two handles, second is NV Index */
5370-
rc = wolfTPM2_SetAuthHandleName(dev, 0, &nv->handle);
5371-
rc |= wolfTPM2_SetAuthHandleName(dev, 1, &nv->handle);
5372-
if (rc != TPM_RC_SUCCESS) {
5368+
if ((wolfTPM2_SetAuthHandleName(dev, 0, &nv->handle) != 0) ||
5369+
(wolfTPM2_SetAuthHandleName(dev, 1, &nv->handle) != 0)) {
53735370
#ifdef DEBUG_WOLFTPM
53745371
printf("Setting NV index name failed\n");
53755372
#endif
5376-
return rc;
5373+
return TPM_RC_FAILURE;
53775374
}
53785375

53795376
XMEMSET(&in, 0, sizeof(in));
@@ -5415,9 +5412,8 @@ int wolfTPM2_NVWriteLock(WOLFTPM2_DEV* dev, WOLFTPM2_NV* nv)
54155412
}
54165413

54175414
/* Necessary, because NVRead has two handles, second is NV Index */
5418-
rc = wolfTPM2_SetAuthHandleName(dev, 0, &nv->handle);
5419-
rc |= wolfTPM2_SetAuthHandleName(dev, 1, &nv->handle);
5420-
if (rc != TPM_RC_SUCCESS) {
5415+
if ((wolfTPM2_SetAuthHandleName(dev, 0, &nv->handle) != 0) ||
5416+
(wolfTPM2_SetAuthHandleName(dev, 1, &nv->handle) != 0)) {
54215417
#ifdef DEBUG_WOLFTPM
54225418
printf("Setting NV index name failed\n");
54235419
#endif

0 commit comments

Comments
 (0)