Add limit on request redirects (fixes issue #3001)

This commit is contained in:
Cristian Amarie 2020-08-13 18:45:26 +00:00 committed by Marshall Greenblatt
parent a5d88d697a
commit 11f37bc6eb
1 changed files with 6 additions and 0 deletions

View File

@ -229,6 +229,7 @@ class InterceptedRequest : public network::mojom::URLLoader,
const uint32_t options_; const uint32_t options_;
bool input_stream_previously_failed_ = false; bool input_stream_previously_failed_ = false;
bool request_was_redirected_ = false; bool request_was_redirected_ = false;
int redirect_limit_ = net::URLRequest::kMaxRedirects;
// To avoid sending multiple OnReceivedError callbacks. // To avoid sending multiple OnReceivedError callbacks.
bool sent_error_callback_ = false; bool sent_error_callback_ = false;
@ -485,6 +486,11 @@ void InterceptedRequest::OnReceiveRedirect(
needs_callback = true; needs_callback = true;
} }
if (--redirect_limit_ == 0) {
SendErrorAndCompleteImmediately(net::ERR_TOO_MANY_REDIRECTS);
return;
}
net::RedirectInfo new_redirect_info; net::RedirectInfo new_redirect_info;
// When we redirect via ContinueToHandleOverrideHeaders the |redirect_info| // When we redirect via ContinueToHandleOverrideHeaders the |redirect_info|