Skip to content

Commit

Permalink
Merge pull request #176 from arduino-libraries/iContentLength_wraparound
Browse files Browse the repository at this point in the history
Make sure iContentLength doesn't wrap around due to malformed packets
  • Loading branch information
facchinm committed Jul 25, 2024
2 parents 6f2659d + 1a3fb98 commit 25f54e9
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/HttpClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -819,7 +819,11 @@ int HttpClient::readHeader()
case eReadingContentLength:
if (isdigit(c))
{
iContentLength = iContentLength*10 + (c - '0');
long _iContentLength = iContentLength*10 + (c - '0');
// Only apply if the value didn't wrap around
if (_iContentLength > iContentLength) {
iContentLength = _iContentLength;
}
}
else
{
Expand Down

0 comments on commit 25f54e9

Please sign in to comment.