OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "ipc/attachment_broker_privileged_win.h" | 5 #include "ipc/attachment_broker_privileged_win.h" |
6 | 6 |
7 #include <windows.h> | 7 #include <windows.h> |
8 | 8 |
9 #include "base/process/process.h" | 9 #include "base/process/process.h" |
10 #include "ipc/attachment_broker_messages.h" | 10 #include "ipc/attachment_broker_messages.h" |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 } | 48 } |
49 | 49 |
50 void AttachmentBrokerPrivilegedWin::OnDuplicateWinHandle( | 50 void AttachmentBrokerPrivilegedWin::OnDuplicateWinHandle( |
51 const IPC::Message& message) { | 51 const IPC::Message& message) { |
52 AttachmentBrokerMsg_DuplicateWinHandle::Param param; | 52 AttachmentBrokerMsg_DuplicateWinHandle::Param param; |
53 if (!AttachmentBrokerMsg_DuplicateWinHandle::Read(&message, ¶m)) | 53 if (!AttachmentBrokerMsg_DuplicateWinHandle::Read(&message, ¶m)) |
54 return; | 54 return; |
55 IPC::internal::HandleAttachmentWin::WireFormat wire_format = | 55 IPC::internal::HandleAttachmentWin::WireFormat wire_format = |
56 base::get<0>(param); | 56 base::get<0>(param); |
57 | 57 |
58 if (wire_format.destination_process == base::kNullProcessId) | 58 if (wire_format.destination_process == base::kNullProcessId) { |
| 59 LogError(NO_DESTINATION); |
59 return; | 60 return; |
| 61 } |
60 | 62 |
61 HandleWireFormat new_wire_format = | 63 HandleWireFormat new_wire_format = |
62 DuplicateWinHandle(wire_format, message.get_sender_pid()); | 64 DuplicateWinHandle(wire_format, message.get_sender_pid()); |
63 RouteDuplicatedHandle(new_wire_format); | 65 RouteDuplicatedHandle(new_wire_format); |
64 } | 66 } |
65 | 67 |
66 void AttachmentBrokerPrivilegedWin::RouteDuplicatedHandle( | 68 void AttachmentBrokerPrivilegedWin::RouteDuplicatedHandle( |
67 const HandleWireFormat& wire_format) { | 69 const HandleWireFormat& wire_format) { |
68 // This process is the destination. | 70 // This process is the destination. |
69 if (wire_format.destination_process == base::Process::Current().Pid()) { | 71 if (wire_format.destination_process == base::Process::Current().Pid()) { |
70 scoped_refptr<BrokerableAttachment> attachment( | 72 scoped_refptr<BrokerableAttachment> attachment( |
71 new internal::HandleAttachmentWin(wire_format)); | 73 new internal::HandleAttachmentWin(wire_format)); |
72 HandleReceivedAttachment(attachment); | 74 HandleReceivedAttachment(attachment); |
73 return; | 75 return; |
74 } | 76 } |
75 | 77 |
76 // Another process is the destination. | 78 // Another process is the destination. |
77 base::ProcessId dest = wire_format.destination_process; | 79 base::ProcessId dest = wire_format.destination_process; |
78 Sender* sender = GetSenderWithProcessId(dest); | 80 Sender* sender = GetSenderWithProcessId(dest); |
79 if (!sender) { | 81 if (!sender) { |
80 // Assuming that this message was not sent from a malicious process, the | 82 // Assuming that this message was not sent from a malicious process, the |
81 // channel endpoint that would have received this message will block | 83 // channel endpoint that would have received this message will block |
82 // forever. | 84 // forever. |
83 LOG(ERROR) << "Failed to deliver brokerable attachment to process with id: " | 85 LOG(ERROR) << "Failed to deliver brokerable attachment to process with id: " |
84 << dest; | 86 << dest; |
| 87 LogError(DESTINATION_NOT_FOUND); |
85 return; | 88 return; |
86 } | 89 } |
87 | 90 |
88 sender->Send(new AttachmentBrokerMsg_WinHandleHasBeenDuplicated(wire_format)); | 91 sender->Send(new AttachmentBrokerMsg_WinHandleHasBeenDuplicated(wire_format)); |
89 } | 92 } |
90 | 93 |
91 AttachmentBrokerPrivilegedWin::HandleWireFormat | 94 AttachmentBrokerPrivilegedWin::HandleWireFormat |
92 AttachmentBrokerPrivilegedWin::DuplicateWinHandle( | 95 AttachmentBrokerPrivilegedWin::DuplicateWinHandle( |
93 const HandleWireFormat& wire_format, | 96 const HandleWireFormat& wire_format, |
94 base::ProcessId source_pid) { | 97 base::ProcessId source_pid) { |
(...skipping 14 matching lines...) Expand all Loading... |
109 FALSE, DUPLICATE_SAME_ACCESS); | 112 FALSE, DUPLICATE_SAME_ACCESS); |
110 | 113 |
111 new_wire_format.handle = (result != 0) ? HandleToLong(new_handle) : 0; | 114 new_wire_format.handle = (result != 0) ? HandleToLong(new_handle) : 0; |
112 } else { | 115 } else { |
113 new_wire_format.handle = 0; | 116 new_wire_format.handle = 0; |
114 } | 117 } |
115 return new_wire_format; | 118 return new_wire_format; |
116 } | 119 } |
117 | 120 |
118 } // namespace IPC | 121 } // namespace IPC |
OLD | NEW |