electron/patches/common/chromium/crashpad_http_status.patch
Milan Burda d56617e5d0 chore: avoid appending git version to the exported patches (#15389)
* chore: avoid appending git version to the exported patches

* fix no-eol at end of v8 patch
2018-10-26 12:52:59 +05:30

86 lines
4.5 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Jeremy Apthorp <nornagon@nornagon.net>
Date: Thu, 18 Oct 2018 17:06:46 -0700
Subject: crashpad_http_status.patch
backport of crashpad f540abb506
diff --git a/third_party/crashpad/crashpad/util/net/http_transport.h b/third_party/crashpad/crashpad/util/net/http_transport.h
index f91a55612a2ffc2f4a78ff48ceba6174adc58cbf..acd4e442462b031dd304f303cdaa3664f5cffb64 100644
--- a/third_party/crashpad/crashpad/util/net/http_transport.h
+++ b/third_party/crashpad/crashpad/util/net/http_transport.h
@@ -90,7 +90,7 @@ class HTTPTransport {
//! if the response body is not required.
//!
//! \return Whether or not the request was successful, defined as returning
- //! a HTTP status 200 (OK) code.
+ //! a HTTP status code in the range 200-203 (inclusive).
virtual bool ExecuteSynchronously(std::string* response_body) = 0;
protected:
diff --git a/third_party/crashpad/crashpad/util/net/http_transport_mac.mm b/third_party/crashpad/crashpad/util/net/http_transport_mac.mm
index 8d5f78cc6efc8b8e349958f51c78921a8c163c4e..a433bb357da5865144ade7d3663b1c9b36199f8e 100644
--- a/third_party/crashpad/crashpad/util/net/http_transport_mac.mm
+++ b/third_party/crashpad/crashpad/util/net/http_transport_mac.mm
@@ -293,7 +293,7 @@ bool HTTPTransportMac::ExecuteSynchronously(std::string* response_body) {
return false;
}
NSInteger http_status = [http_response statusCode];
- if (http_status != 200) {
+ if (http_status < 200 || http_status > 203) {
LOG(ERROR) << base::StringPrintf("HTTP status %ld",
implicit_cast<long>(http_status));
return false;
diff --git a/third_party/crashpad/crashpad/util/net/http_transport_socket.cc b/third_party/crashpad/crashpad/util/net/http_transport_socket.cc
index f0e2dc14a8a487b5960d700be57100c9bed4f271..34d8deeb5c25f6b49fd0acadce67a3816869d3da 100644
--- a/third_party/crashpad/crashpad/util/net/http_transport_socket.cc
+++ b/third_party/crashpad/crashpad/util/net/http_transport_socket.cc
@@ -457,10 +457,18 @@ bool ReadResponseLine(Stream* stream) {
LOG(ERROR) << "ReadLine";
return false;
}
- static constexpr const char kHttp10[] = "HTTP/1.0 200 ";
- static constexpr const char kHttp11[] = "HTTP/1.1 200 ";
- return StartsWith(response_line, kHttp10, strlen(kHttp10)) ||
- StartsWith(response_line, kHttp11, strlen(kHttp11));
+ static constexpr const char kHttp10[] = "HTTP/1.0 ";
+ static constexpr const char kHttp11[] = "HTTP/1.1 ";
+ if (!(StartsWith(response_line, kHttp10, strlen(kHttp10)) ||
+ StartsWith(response_line, kHttp11, strlen(kHttp11))) ||
+ response_line.size() < strlen(kHttp10) + 3 ||
+ response_line.at(strlen(kHttp10) + 3) != ' ') {
+ return false;
+ }
+ unsigned int http_status = 0;
+ return base::StringToUint(response_line.substr(strlen(kHttp10), 3),
+ &http_status) &&
+ http_status >= 200 && http_status <= 203;
}
bool ReadResponseHeaders(Stream* stream, HTTPHeaders* headers) {
diff --git a/third_party/crashpad/crashpad/util/net/http_transport_test.cc b/third_party/crashpad/crashpad/util/net/http_transport_test.cc
index 7b5f41dfd1e18b212d7dd349cff8f4396e20dbc3..d73dc99217e08f7c84ded50868cbef02141a6b9b 100644
--- a/third_party/crashpad/crashpad/util/net/http_transport_test.cc
+++ b/third_party/crashpad/crashpad/util/net/http_transport_test.cc
@@ -137,7 +137,7 @@ class HTTPTransportTestFixture : public MultiprocessExec {
std::string response_body;
bool success = transport->ExecuteSynchronously(&response_body);
- if (response_code_ == 200) {
+ if (response_code_ >= 200 && response_code_ <= 203) {
EXPECT_TRUE(success);
std::string expect_response_body = random_string + "\r\n";
EXPECT_EQ(response_body, expect_response_body);
diff --git a/third_party/crashpad/crashpad/util/net/http_transport_win.cc b/third_party/crashpad/crashpad/util/net/http_transport_win.cc
index 18d343ccef0396ee6679f4b5fd8316c3109003f4..2919bc11d0ba4bf84a11e146bf2961b830db35fe 100644
--- a/third_party/crashpad/crashpad/util/net/http_transport_win.cc
+++ b/third_party/crashpad/crashpad/util/net/http_transport_win.cc
@@ -375,7 +375,7 @@ bool HTTPTransportWin::ExecuteSynchronously(std::string* response_body) {
return false;
}
- if (status_code != 200) {
+ if (status_code < 200 || status_code > 203) {
LOG(ERROR) << base::StringPrintf("HTTP status %lu", status_code);
return false;
}