Skip to content

Commit

Permalink
Protect against server hijacking error handling (#7811)
Browse files Browse the repository at this point in the history
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)
  • Loading branch information
paulocsanz authored Jan 8, 2021
1 parent adbd23b commit 98a19ab
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions libraries/ESP8266HTTPClient/src/ESP8266HTTPClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 98a19ab

Please sign in to comment.