Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(638)

Unified Diff: third_party/crashpad/crashpad/util/win/registration_protocol_win.cc

Issue 2478633002: Update Crashpad to b47bf6c250c6b825dee1c5fbad9152c2c962e828 (Closed)
Patch Set: mac comment 2 Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/crashpad/crashpad/util/win/registration_protocol_win.cc
diff --git a/third_party/crashpad/crashpad/util/win/registration_protocol_win.cc b/third_party/crashpad/crashpad/util/win/registration_protocol_win.cc
index eff27e2855028e1483fb027e5ae9e38837365f88..176384157e1d54844510c6bbead76de3d178ed42 100644
--- a/third_party/crashpad/crashpad/util/win/registration_protocol_win.cc
+++ b/third_party/crashpad/crashpad/util/win/registration_protocol_win.cc
@@ -15,15 +15,18 @@
#include "util/win/registration_protocol_win.h"
#include <windows.h>
+#include <sddl.h>
#include "base/logging.h"
+#include "util/win/exception_handler_server.h"
#include "util/win/scoped_handle.h"
+#include "util/win/scoped_local_alloc.h"
namespace crashpad {
bool SendToCrashHandlerServer(const base::string16& pipe_name,
- const crashpad::ClientToServerMessage& message,
- crashpad::ServerToClientMessage* response) {
+ const ClientToServerMessage& message,
+ ServerToClientMessage* response) {
// Retry CreateFile() in a loop. If the handler isn’t actively waiting in
// ConnectNamedPipe() on a pipe instance because it’s busy doing something
// else, CreateFile() will fail with ERROR_PIPE_BUSY. WaitNamedPipe() waits
@@ -39,7 +42,7 @@ bool SendToCrashHandlerServer(const base::string16& pipe_name,
// around the same time as its client, something external to this code must be
// done to guarantee correct ordering. When the client starts the handler
// itself, CrashpadClient::StartHandler() provides this synchronization.
- for (int tries = 0;;) {
+ for (;;) {
ScopedFileHANDLE pipe(
CreateFile(pipe_name.c_str(),
GENERIC_READ | GENERIC_WRITE,
@@ -49,13 +52,12 @@ bool SendToCrashHandlerServer(const base::string16& pipe_name,
SECURITY_SQOS_PRESENT | SECURITY_IDENTIFICATION,
nullptr));
if (!pipe.is_valid()) {
- if (++tries == 5 || GetLastError() != ERROR_PIPE_BUSY) {
+ if (GetLastError() != ERROR_PIPE_BUSY) {
PLOG(ERROR) << "CreateFile";
return false;
}
- if (!WaitNamedPipe(pipe_name.c_str(), 1000) &&
- GetLastError() != ERROR_SEM_TIMEOUT) {
+ if (!WaitNamedPipe(pipe_name.c_str(), NMPWAIT_WAIT_FOREVER)) {
PLOG(ERROR) << "WaitNamedPipe";
return false;
}
@@ -72,7 +74,7 @@ bool SendToCrashHandlerServer(const base::string16& pipe_name,
BOOL result = TransactNamedPipe(
pipe.get(),
// This is [in], but is incorrectly declared non-const.
- const_cast<crashpad::ClientToServerMessage*>(&message),
+ const_cast<ClientToServerMessage*>(&message),
sizeof(message),
response,
sizeof(*response),
@@ -91,4 +93,47 @@ bool SendToCrashHandlerServer(const base::string16& pipe_name,
}
}
+HANDLE CreateNamedPipeInstance(const std::wstring& pipe_name,
+ bool first_instance) {
+ SECURITY_ATTRIBUTES security_attributes;
+ SECURITY_ATTRIBUTES* security_attributes_pointer = nullptr;
+ ScopedLocalAlloc scoped_sec_desc;
+
+ if (first_instance) {
+ // Pre-Vista does not have integrity levels.
+ const DWORD version = GetVersion();
+ const DWORD major_version = LOBYTE(LOWORD(version));
+ const bool is_vista_or_later = major_version >= 6;
+ if (is_vista_or_later) {
+ // Mandatory Label, no ACE flags, no ObjectType, integrity level
+ // untrusted.
+ const wchar_t kSddl[] = L"S:(ML;;;;;S-1-16-0)";
+
+ PSECURITY_DESCRIPTOR sec_desc;
+ PCHECK(ConvertStringSecurityDescriptorToSecurityDescriptor(
+ kSddl, SDDL_REVISION_1, &sec_desc, nullptr))
+ << "ConvertStringSecurityDescriptorToSecurityDescriptor";
+
+ // Take ownership of the allocated SECURITY_DESCRIPTOR.
+ scoped_sec_desc.reset(sec_desc);
+
+ memset(&security_attributes, 0, sizeof(security_attributes));
+ security_attributes.nLength = sizeof(SECURITY_ATTRIBUTES);
+ security_attributes.lpSecurityDescriptor = sec_desc;
+ security_attributes.bInheritHandle = TRUE;
+ security_attributes_pointer = &security_attributes;
+ }
+ }
+
+ return CreateNamedPipe(
+ pipe_name.c_str(),
+ PIPE_ACCESS_DUPLEX | (first_instance ? FILE_FLAG_FIRST_PIPE_INSTANCE : 0),
+ PIPE_TYPE_MESSAGE | PIPE_READMODE_MESSAGE | PIPE_WAIT,
+ ExceptionHandlerServer::kPipeInstances,
+ 512,
+ 512,
+ 0,
+ security_attributes_pointer);
+}
+
} // namespace crashpad

Powered by Google App Engine
This is Rietveld 408576698