Skip to content

Commit d465155

Browse files
committed
Fix the TPM2_TIS_Write correctly
1 parent 5a70253 commit d465155

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/tpm2_tis.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -237,8 +237,10 @@ int TPM2_TIS_Write(TPM2_CTX* ctx, word32 addr, const byte* value,
237237
txBuf[2] = (addr>>8) & 0xFF;
238238
txBuf[3] = (addr) & 0xFF;
239239
XMEMCPY(&txBuf[TPM_TIS_HEADER_SZ], value, len);
240-
XMEMSET(&txBuf[TPM_TIS_HEADER_SZ + len - 1], 0,
241-
sizeof(txBuf) - TPM_TIS_HEADER_SZ - len);
240+
if (len < MAX_SPI_FRAMESIZE) {
241+
XMEMSET(&txBuf[TPM_TIS_HEADER_SZ + len], 0,
242+
sizeof(txBuf) - TPM_TIS_HEADER_SZ - len);
243+
}
242244
XMEMSET(rxBuf, 0, sizeof(rxBuf));
243245

244246
rc = ctx->ioCb(ctx, txBuf, rxBuf, len + TPM_TIS_HEADER_SZ, ctx->userCtx);

0 commit comments

Comments
 (0)