Skip to content

Commit 20a9376

Browse files
authored
Protect against server hijacking error handling
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 43f44e4 commit 20a9376

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

libraries/ESP8266HTTPClient/src/ESP8266HTTPClient.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -1125,17 +1125,17 @@ int HTTPClient::handleHeaderResponse()
11251125
if(transferEncoding.equalsIgnoreCase(F("chunked"))) {
11261126
_transferEncoding = HTTPC_TE_CHUNKED;
11271127
} else {
1128-
return HTTPC_ERROR_ENCODING;
1128+
return (_returnCode = HTTPC_ERROR_ENCODING);
11291129
}
11301130
} else {
11311131
_transferEncoding = HTTPC_TE_IDENTITY;
11321132
}
11331133

1134-
if(_returnCode) {
1134+
if(_returnCode > 0) {
11351135
return _returnCode;
11361136
} else {
11371137
DEBUG_HTTPCLIENT("[HTTP-Client][handleHeaderResponse] Remote host is not an HTTP Server!");
1138-
return HTTPC_ERROR_NO_HTTP_SERVER;
1138+
return (_returnCode = HTTPC_ERROR_NO_HTTP_SERVER);
11391139
}
11401140
}
11411141

0 commit comments

Comments
 (0)