From 1a3fb989a5d92575a05b6ac3627de554723709ac Mon Sep 17 00:00:00 2001 From: Martino Facchin Date: Wed, 8 May 2024 17:25:48 +0200 Subject: [PATCH] Make sure iContentLength doesn't wrap around due to malformed packets --- src/HttpClient.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/HttpClient.cpp b/src/HttpClient.cpp index c0f5c27..31909d9 100644 --- a/src/HttpClient.cpp +++ b/src/HttpClient.cpp @@ -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 {