We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent ae73063 commit 4f6282bCopy full SHA for 4f6282b
src/tpm2.c
@@ -5483,9 +5483,16 @@ TPM_RC TPM2_GetProductInfo(uint8_t* info, uint16_t size)
5483
*/
5484
5485
/* start of product info starts at byte 26 */
5486
- if (size > packet.size - 26)
5487
- size = packet.size - 26;
5488
- XMEMCPY(info, &packet.buf[25], size);
+ if (packet.size <= 26) {
+ rc = TPM_RC_SIZE;
+ }
5489
+ else if (size > 0) {
5490
+ size_t payloadSz = (size_t)(packet.size - 26);
5491
+ if (payloadSz > (size_t)size) {
5492
+ payloadSz = (size_t)size;
5493
5494
+ XMEMCPY(info, &packet.buf[25], payloadSz);
5495
5496
}
5497
TPM2_ReleaseLock(ctx);
5498
0 commit comments