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

Side by Side Diff: sandbox/win/src/sharedmem_ipc_server.cc

Issue 1849323003: Convert //sandbox to use std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fixup nonsfi_sandbox_unittest.cc Created 4 years, 8 months 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 unified diff | Download patch
« no previous file with comments | « sandbox/win/src/service_resolver_unittest.cc ('k') | sandbox/win/src/target_process.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 <stddef.h> 5 #include <stddef.h>
6 #include <stdint.h> 6 #include <stdint.h>
7 7
8 #include <memory>
9
8 #include "base/callback.h" 10 #include "base/callback.h"
9 #include "base/logging.h" 11 #include "base/logging.h"
10 #include "base/memory/scoped_ptr.h"
11 #include "base/stl_util.h" 12 #include "base/stl_util.h"
12 #include "sandbox/win/src/crosscall_params.h" 13 #include "sandbox/win/src/crosscall_params.h"
13 #include "sandbox/win/src/crosscall_server.h" 14 #include "sandbox/win/src/crosscall_server.h"
14 #include "sandbox/win/src/sandbox.h" 15 #include "sandbox/win/src/sandbox.h"
15 #include "sandbox/win/src/sandbox_types.h" 16 #include "sandbox/win/src/sandbox_types.h"
16 #include "sandbox/win/src/sharedmem_ipc_client.h" 17 #include "sandbox/win/src/sharedmem_ipc_client.h"
17 #include "sandbox/win/src/sharedmem_ipc_server.h" 18 #include "sandbox/win/src/sharedmem_ipc_server.h"
18 19
19 namespace { 20 namespace {
20 // This handle must not be closed. 21 // This handle must not be closed.
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 return false; 169 return false;
169 170
170 for (uint32_t i = 0; i < params->GetParamsCount(); i++) { 171 for (uint32_t i = 0; i < params->GetParamsCount(); i++) {
171 uint32_t size; 172 uint32_t size;
172 ArgType type; 173 ArgType type;
173 args[i] = params->GetRawParameter(i, &size, &type); 174 args[i] = params->GetRawParameter(i, &size, &type);
174 if (args[i]) { 175 if (args[i]) {
175 ipc_params->args[i] = type; 176 ipc_params->args[i] = type;
176 switch (type) { 177 switch (type) {
177 case WCHAR_TYPE: { 178 case WCHAR_TYPE: {
178 scoped_ptr<base::string16> data(new base::string16); 179 std::unique_ptr<base::string16> data(new base::string16);
179 if (!params->GetParameterStr(i, data.get())) { 180 if (!params->GetParameterStr(i, data.get())) {
180 args[i] = 0; 181 args[i] = 0;
181 ReleaseArgs(ipc_params, args); 182 ReleaseArgs(ipc_params, args);
182 return false; 183 return false;
183 } 184 }
184 args[i] = data.release(); 185 args[i] = data.release();
185 break; 186 break;
186 } 187 }
187 case UINT32_TYPE: { 188 case UINT32_TYPE: {
188 uint32_t data; 189 uint32_t data;
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 222
222 bool SharedMemIPCServer::InvokeCallback(const ServerControl* service_context, 223 bool SharedMemIPCServer::InvokeCallback(const ServerControl* service_context,
223 void* ipc_buffer, 224 void* ipc_buffer,
224 CrossCallReturn* call_result) { 225 CrossCallReturn* call_result) {
225 // Set the default error code; 226 // Set the default error code;
226 SetCallError(SBOX_ERROR_INVALID_IPC, call_result); 227 SetCallError(SBOX_ERROR_INVALID_IPC, call_result);
227 uint32_t output_size = 0; 228 uint32_t output_size = 0;
228 // Parse, verify and copy the message. The handler operates on a copy 229 // Parse, verify and copy the message. The handler operates on a copy
229 // of the message so the client cannot play dirty tricks by changing the 230 // of the message so the client cannot play dirty tricks by changing the
230 // data in the channel while the IPC is being processed. 231 // data in the channel while the IPC is being processed.
231 scoped_ptr<CrossCallParamsEx> params( 232 std::unique_ptr<CrossCallParamsEx> params(CrossCallParamsEx::CreateFromBuffer(
232 CrossCallParamsEx::CreateFromBuffer(ipc_buffer, 233 ipc_buffer, service_context->channel_size, &output_size));
233 service_context->channel_size,
234 &output_size));
235 if (!params.get()) 234 if (!params.get())
236 return false; 235 return false;
237 236
238 uint32_t tag = params->GetTag(); 237 uint32_t tag = params->GetTag();
239 static_assert(0 == INVALID_TYPE, "incorrect type enum"); 238 static_assert(0 == INVALID_TYPE, "incorrect type enum");
240 IPCParams ipc_params = {0}; 239 IPCParams ipc_params = {0};
241 ipc_params.ipc_tag = tag; 240 ipc_params.ipc_tag = tag;
242 241
243 void* args[kMaxIpcParams]; 242 void* args[kMaxIpcParams];
244 if (!GetArgs(params.get(), &ipc_params, args)) 243 if (!GetArgs(params.get(), &ipc_params, args))
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
421 server_pong->Set(::CreateEventW(NULL, FALSE, FALSE, NULL)); 420 server_pong->Set(::CreateEventW(NULL, FALSE, FALSE, NULL));
422 if (!::DuplicateHandle(::GetCurrentProcess(), server_pong->Get(), 421 if (!::DuplicateHandle(::GetCurrentProcess(), server_pong->Get(),
423 target_process_, client_pong, kDesiredAccess, FALSE, 422 target_process_, client_pong, kDesiredAccess, FALSE,
424 0)) { 423 0)) {
425 return false; 424 return false;
426 } 425 }
427 return true; 426 return true;
428 } 427 }
429 428
430 } // namespace sandbox 429 } // namespace sandbox
OLDNEW
« no previous file with comments | « sandbox/win/src/service_resolver_unittest.cc ('k') | sandbox/win/src/target_process.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698