Skip to content
Merged
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
11 changes: 11 additions & 0 deletions tests/fwtpm_unit_tests.c
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,11 @@
Assert(_x > _y, ("%s > %s", #x, #y), \
("%d <= %d", _x, _y)); \
} while(0)
#define AssertIntLE(x, y) do { \
int _x = (int)(x); int _y = (int)(y); \
Assert(_x <= _y, ("%s <= %s", #x, #y), \
("%d > %d", _x, _y)); \
} while(0)

/* ================================================================== */
/* Packet building helpers */
Expand Down Expand Up @@ -10533,11 +10538,17 @@ static void CreateChildBlobs(FWTPM_CTX* ctx, UINT32 parent,
AssertIntEQ(GetRspRC(gRsp), TPM_RC_SUCCESS);

pos = TPM2_HEADER_SIZE + 4; /* skip parameterSize */
AssertIntLE(pos + 2, rspSize); /* size field present */
*privSz = GetU16BE(gRsp + pos); pos += 2;
AssertIntGT(*privSz, 0);
AssertIntLE(*privSz, sizeof(TPM2B_PRIVATE)); /* fits caller's buffer */
AssertIntLE(pos + *privSz, rspSize); /* payload present */
memcpy(priv, gRsp + pos, *privSz); pos += *privSz;
AssertIntLE(pos + 2, rspSize); /* size field present */
*pubSz = GetU16BE(gRsp + pos);
AssertIntGT(*pubSz, 0);
AssertIntLE(2 + *pubSz, sizeof(TPM2B_PUBLIC)); /* fits caller's buffer */
AssertIntLE(pos + 2 + *pubSz, rspSize); /* payload present */
memcpy(pub, gRsp + pos, 2 + *pubSz); /* keep the size prefix */
}

Expand Down
Loading