Skip to content

Commit

Permalink
fix integer overflow in ReadVarBytes (#100)
Browse files Browse the repository at this point in the history
* fix integer overflow in ReadVarBytes by changing to uint32_t as originally intended.
  • Loading branch information
v0id-re authored Sep 18, 2023
1 parent f74c0d9 commit c3c41c0
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions TPMCmd/Simulator/src/TcpServer.c
Original file line number Diff line number Diff line change
Expand Up @@ -562,10 +562,10 @@ bool ReadUINT32(SOCKET s, uint32_t* val)
//*** ReadVarBytes()
// Get a uint32-length-prepended binary array. Note that the 4-byte length is
// in network byte order (big-endian).
bool ReadVarBytes(SOCKET s, char* buffer, uint32_t* BytesReceived, int MaxLen)
bool ReadVarBytes(SOCKET s, char* buffer, uint32_t* BytesReceived, uint32_t MaxLen)
{
int length;
bool res;
uint32_t length;
bool res;
//
res = ReadBytes(s, (char*)&length, 4);
if(!res)
Expand All @@ -574,7 +574,7 @@ bool ReadVarBytes(SOCKET s, char* buffer, uint32_t* BytesReceived, int MaxLen)
*BytesReceived = length;
if(length > MaxLen)
{
printf("Buffer too big. Client says %d\n", length);
printf("Buffer too big. Client says %u\n", length);
return false;
}
if(length == 0)
Expand Down

0 comments on commit c3c41c0

Please sign in to comment.