Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/fwtpm/fwtpm_command.c
Original file line number Diff line number Diff line change
Expand Up @@ -8423,7 +8423,8 @@ static TPM_RC FwCmd_StartAuthSession(FWTPM_CTX* ctx, TPM2_Packet* cmd,
}
/* Then append salt if present */
if (rc == 0 && saltSize > 0) {
if (keyInSz + saltSize <= (int)sizeof(keyIn)) {
if (keyInSz + saltSize <= (int)sizeof(keyIn) &&
saltSize <= (int)sizeof(salt)) {
XMEMCPY(keyIn + keyInSz, salt, saltSize);
keyInSz += saltSize;
}
Expand Down
5 changes: 5 additions & 0 deletions src/fwtpm/fwtpm_crypto.c
Original file line number Diff line number Diff line change
Expand Up @@ -2447,6 +2447,11 @@ TPM_RC FwDecryptSeed(FWTPM_CTX* ctx,
TPM2_ForceZero(seedBuf, seedBufSz);
rc = TPM_RC_FAILURE;
}
else if (rc > seedBufSz) {
/* Bound output to caller buffer */
TPM2_ForceZero(seedBuf, seedBufSz);
rc = TPM_RC_FAILURE;
}
else {
*seedSzOut = rc;
rc = 0;
Expand Down
8 changes: 7 additions & 1 deletion src/tpm2_packet.c
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,13 @@ void TPM2_Packet_ParseBytes(TPM2_Packet* packet, byte* buf, int size)
XMEMCPY(buf, &packet->buf[packet->pos], sizeToCopy);
}
}
packet->pos += size;
if (size > 0 && packet->pos + size > packet->size) {
/* Clamp pos on truncated read */
packet->pos = packet->size;
}
else {
packet->pos += size;
}
}
}

Expand Down
Loading