Skip to content

Commit 25f54e9

Browse files
authored
Merge pull request #176 from arduino-libraries/iContentLength_wraparound
Make sure iContentLength doesn't wrap around due to malformed packets
2 parents 6f2659d + 1a3fb98 commit 25f54e9

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/HttpClient.cpp

+5-1
Original file line numberDiff line numberDiff line change
@@ -819,7 +819,11 @@ int HttpClient::readHeader()
819819
case eReadingContentLength:
820820
if (isdigit(c))
821821
{
822-
iContentLength = iContentLength*10 + (c - '0');
822+
long _iContentLength = iContentLength*10 + (c - '0');
823+
// Only apply if the value didn't wrap around
824+
if (_iContentLength > iContentLength) {
825+
iContentLength = _iContentLength;
826+
}
823827
}
824828
else
825829
{

0 commit comments

Comments
 (0)