Skip to content
Open
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
5 changes: 5 additions & 0 deletions http.c
Original file line number Diff line number Diff line change
Expand Up @@ -1266,7 +1266,12 @@ int _mwProcessReadSocket(HttpParam* hp, HttpSocket* phsSocket)
phsSocket->request.pucPayload = malloc(phsSocket->bufferSize);
phsSocket->pucData = phsSocket->request.pucPayload;
// payload length already received

// Fix heap overflow (CVE-2020-29596)
// We make sure that the length of phsSocket->dataLength doesn't exceed request.payloadSize
if (phsSocket->dataLength > phsSocket->request.payloadSize) phsSocket->dataLength = phsSocket->request.payloadSize;
phsSocket->dataLength -= phsSocket->request.headerSize;

// copy already received payload to payload buffer
memcpy(phsSocket->request.pucPayload, phsSocket->buffer + phsSocket->request.headerSize, phsSocket->dataLength);
phsSocket->request.pucPayload[phsSocket->dataLength]=0;
Expand Down