Skip to content

Commit 98a19ab

Browse files
authored
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)
1 parent adbd23b commit 98a19ab

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

libraries/ESP8266HTTPClient/src/ESP8266HTTPClient.cpp

+5-5
Original file line numberDiff line numberDiff line change
@@ -1125,18 +1125,18 @@ int HTTPClient::handleHeaderResponse()
11251125
if(transferEncoding.equalsIgnoreCase(F("chunked"))) {
11261126
_transferEncoding = HTTPC_TE_CHUNKED;
11271127
} else {
1128-
return HTTPC_ERROR_ENCODING;
1128+
_returnCode = HTTPC_ERROR_ENCODING;
1129+
return _returnCode;
11291130
}
11301131
} else {
11311132
_transferEncoding = HTTPC_TE_IDENTITY;
11321133
}
11331134

1134-
if(_returnCode) {
1135-
return _returnCode;
1136-
} else {
1135+
if(_returnCode <= 0) {
11371136
DEBUG_HTTPCLIENT("[HTTP-Client][handleHeaderResponse] Remote host is not an HTTP Server!");
1138-
return HTTPC_ERROR_NO_HTTP_SERVER;
1137+
_returnCode = HTTPC_ERROR_NO_HTTP_SERVER;
11391138
}
1139+
return _returnCode;
11401140
}
11411141

11421142
} else {

0 commit comments

Comments
 (0)