1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-04-21 10:26:06 +03:00

Protect against server hijacking error handling (#7811)

If a server returns "HTTP/1.x -8 OK", for example, it can misguide an application developer into freeing less-important memory so the request can be retried and succeed, when the problem is in the server.

_returnCode is never used anywhere else, but it could still contain a negative value returned by a broken server and therefore could cause troubles in the future (if _returnCode is in fact used)
This commit is contained in:
Paulo Cabral Sanz 2021-01-08 02:22:36 -03:00 committed by GitHub
parent adbd23b6e2
commit 98a19ab245
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1125,18 +1125,18 @@ int HTTPClient::handleHeaderResponse()
if(transferEncoding.equalsIgnoreCase(F("chunked"))) {
_transferEncoding = HTTPC_TE_CHUNKED;
} else {
return HTTPC_ERROR_ENCODING;
_returnCode = HTTPC_ERROR_ENCODING;
return _returnCode;
}
} else {
_transferEncoding = HTTPC_TE_IDENTITY;
}
if(_returnCode) {
return _returnCode;
} else {
if(_returnCode <= 0) {
DEBUG_HTTPCLIENT("[HTTP-Client][handleHeaderResponse] Remote host is not an HTTP Server!");
return HTTPC_ERROR_NO_HTTP_SERVER;
_returnCode = HTTPC_ERROR_NO_HTTP_SERVER;
}
return _returnCode;
}
} else {