| OLD | NEW |
| 1 // Copyright 2014 The Crashpad Authors. All rights reserved. | 1 // Copyright 2014 The Crashpad Authors. All rights reserved. |
| 2 // | 2 // |
| 3 // Licensed under the Apache License, Version 2.0 (the "License"); | 3 // Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 // you may not use this file except in compliance with the License. | 4 // you may not use this file except in compliance with the License. |
| 5 // You may obtain a copy of the License at | 5 // You may obtain a copy of the License at |
| 6 // | 6 // |
| 7 // http://www.apache.org/licenses/LICENSE-2.0 | 7 // http://www.apache.org/licenses/LICENSE-2.0 |
| 8 // | 8 // |
| 9 // Unless required by applicable law or agreed to in writing, software | 9 // Unless required by applicable law or agreed to in writing, software |
| 10 // distributed under the License is distributed on an "AS IS" BASIS, | 10 // distributed under the License is distributed on an "AS IS" BASIS, |
| (...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 254 std::swap(child_port_, child_port); | 254 std::swap(child_port_, child_port); |
| 255 return child_port; | 255 return child_port; |
| 256 } | 256 } |
| 257 | 257 |
| 258 kern_return_t ChildPortHandshake::HandleChildPortCheckIn( | 258 kern_return_t ChildPortHandshake::HandleChildPortCheckIn( |
| 259 child_port_server_t server, | 259 child_port_server_t server, |
| 260 const child_port_token_t token, | 260 const child_port_token_t token, |
| 261 mach_port_t port, | 261 mach_port_t port, |
| 262 mach_msg_type_name_t right_type, | 262 mach_msg_type_name_t right_type, |
| 263 const mach_msg_trailer_t* trailer, | 263 const mach_msg_trailer_t* trailer, |
| 264 bool* destroy_complex_request) { | 264 bool* destroy_request) { |
| 265 DCHECK_EQ(child_port_, kMachPortNull); | 265 DCHECK_EQ(child_port_, kMachPortNull); |
| 266 | 266 |
| 267 if (token != token_) { | 267 if (token != token_) { |
| 268 // If the token’s not correct, someone’s attempting to spoof the legitimate | 268 // If the token’s not correct, someone’s attempting to spoof the legitimate |
| 269 // client. | 269 // client. |
| 270 LOG(WARNING) << "ignoring incorrect token"; | 270 LOG(WARNING) << "ignoring incorrect token"; |
| 271 *destroy_complex_request = true; | 271 *destroy_request = true; |
| 272 } else { | 272 } else { |
| 273 checked_in_ = true; | 273 checked_in_ = true; |
| 274 | 274 |
| 275 if (right_type == MACH_MSG_TYPE_PORT_RECEIVE) { | 275 if (right_type == MACH_MSG_TYPE_PORT_RECEIVE) { |
| 276 // The message needs to carry a send right or a send-once right. This | 276 // The message needs to carry a send right or a send-once right. This |
| 277 // isn’t a strict requirement of the protocol, but users of this class | 277 // isn’t a strict requirement of the protocol, but users of this class |
| 278 // expect a send right or a send-once right, both of which can be managed | 278 // expect a send right or a send-once right, both of which can be managed |
| 279 // by base::mac::ScopedMachSendRight. It is invalid to store a receive | 279 // by base::mac::ScopedMachSendRight. It is invalid to store a receive |
| 280 // right in that scoper. | 280 // right in that scoper. |
| 281 LOG(WARNING) << "ignoring MACH_MSG_TYPE_PORT_RECEIVE"; | 281 LOG(WARNING) << "ignoring MACH_MSG_TYPE_PORT_RECEIVE"; |
| 282 *destroy_complex_request = true; | 282 *destroy_request = true; |
| 283 } else { | 283 } else { |
| 284 // Communicate the child port back to the RunServer(). | 284 // Communicate the child port back to the RunServer(). |
| 285 // *destroy_complex_request is left at false, because RunServer() needs | 285 // *destroy_request is left at false, because RunServer() needs the right |
| 286 // the right to remain intact. It gives ownership of the right to its | 286 // to remain intact. It gives ownership of the right to its caller. |
| 287 // caller. | |
| 288 child_port_ = port; | 287 child_port_ = port; |
| 289 } | 288 } |
| 290 } | 289 } |
| 291 | 290 |
| 292 // This is a MIG simpleroutine, there is no reply message. | 291 // This is a MIG simpleroutine, there is no reply message. |
| 293 return MIG_NO_REPLY; | 292 return MIG_NO_REPLY; |
| 294 } | 293 } |
| 295 | 294 |
| 296 // static | 295 // static |
| 297 void ChildPortHandshake::RunClient(int pipe_read, | 296 void ChildPortHandshake::RunClient(int pipe_read, |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 340 bootstrap_look_up(bootstrap_port, service_name.c_str(), &server_port); | 339 bootstrap_look_up(bootstrap_port, service_name.c_str(), &server_port); |
| 341 BOOTSTRAP_CHECK(kr == BOOTSTRAP_SUCCESS, kr) << "bootstrap_look_up"; | 340 BOOTSTRAP_CHECK(kr == BOOTSTRAP_SUCCESS, kr) << "bootstrap_look_up"; |
| 342 base::mac::ScopedMachSendRight server_port_owner(server_port); | 341 base::mac::ScopedMachSendRight server_port_owner(server_port); |
| 343 | 342 |
| 344 // Check in with the server. | 343 // Check in with the server. |
| 345 kr = child_port_check_in(server_port, token, port, right_type); | 344 kr = child_port_check_in(server_port, token, port, right_type); |
| 346 MACH_CHECK(kr == KERN_SUCCESS, kr) << "child_port_check_in"; | 345 MACH_CHECK(kr == KERN_SUCCESS, kr) << "child_port_check_in"; |
| 347 } | 346 } |
| 348 | 347 |
| 349 } // namespace crashpad | 348 } // namespace crashpad |
| OLD | NEW |