mirror of
https://github.com/chromium/crashpad.git
synced 2025-03-17 16:43:53 +00:00
MachMessageServer::Interface implementations: minor cleanups.
R=rsesek@chromium.org Review URL: https://codereview.chromium.org/799463003
This commit is contained in:
parent
dc22dc405d
commit
554e75422c
@ -261,14 +261,14 @@ kern_return_t ChildPortHandshake::HandleChildPortCheckIn(
|
|||||||
mach_port_t port,
|
mach_port_t port,
|
||||||
mach_msg_type_name_t right_type,
|
mach_msg_type_name_t right_type,
|
||||||
const mach_msg_trailer_t* trailer,
|
const mach_msg_trailer_t* trailer,
|
||||||
bool* destroy_complex_request) {
|
bool* destroy_request) {
|
||||||
DCHECK_EQ(child_port_, kMachPortNull);
|
DCHECK_EQ(child_port_, kMachPortNull);
|
||||||
|
|
||||||
if (token != token_) {
|
if (token != token_) {
|
||||||
// If the token’s not correct, someone’s attempting to spoof the legitimate
|
// If the token’s not correct, someone’s attempting to spoof the legitimate
|
||||||
// client.
|
// client.
|
||||||
LOG(WARNING) << "ignoring incorrect token";
|
LOG(WARNING) << "ignoring incorrect token";
|
||||||
*destroy_complex_request = true;
|
*destroy_request = true;
|
||||||
} else {
|
} else {
|
||||||
checked_in_ = true;
|
checked_in_ = true;
|
||||||
|
|
||||||
@ -279,12 +279,11 @@ kern_return_t ChildPortHandshake::HandleChildPortCheckIn(
|
|||||||
// by base::mac::ScopedMachSendRight. It is invalid to store a receive
|
// by base::mac::ScopedMachSendRight. It is invalid to store a receive
|
||||||
// right in that scoper.
|
// right in that scoper.
|
||||||
LOG(WARNING) << "ignoring MACH_MSG_TYPE_PORT_RECEIVE";
|
LOG(WARNING) << "ignoring MACH_MSG_TYPE_PORT_RECEIVE";
|
||||||
*destroy_complex_request = true;
|
*destroy_request = true;
|
||||||
} else {
|
} else {
|
||||||
// Communicate the child port back to the RunServer().
|
// Communicate the child port back to the RunServer().
|
||||||
// *destroy_complex_request is left at false, because RunServer() needs
|
// *destroy_request is left at false, because RunServer() needs the right
|
||||||
// the right to remain intact. It gives ownership of the right to its
|
// to remain intact. It gives ownership of the right to its caller.
|
||||||
// caller.
|
|
||||||
child_port_ = port;
|
child_port_ = port;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -137,7 +137,7 @@ class ChildPortHandshake : public ChildPortServer::Interface {
|
|||||||
mach_port_t port,
|
mach_port_t port,
|
||||||
mach_msg_type_name_t right_type,
|
mach_msg_type_name_t right_type,
|
||||||
const mach_msg_trailer_t* trailer,
|
const mach_msg_trailer_t* trailer,
|
||||||
bool* destroy_complex_request) override;
|
bool* destroy_request) override;
|
||||||
|
|
||||||
//! \brief Runs the client.
|
//! \brief Runs the client.
|
||||||
//!
|
//!
|
||||||
|
@ -97,16 +97,18 @@ bool ChildPortServer::MachMessageServerFunction(
|
|||||||
destroy_complex_request);
|
destroy_complex_request);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
SetMIGReplyError(out_header, MIG_BAD_ID);
|
default: {
|
||||||
return false;
|
SetMIGReplyError(out_header, MIG_BAD_ID);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::set<mach_msg_id_t> ChildPortServer::MachMessageServerRequestIDs() {
|
std::set<mach_msg_id_t> ChildPortServer::MachMessageServerRequestIDs() {
|
||||||
const mach_msg_id_t request_ids[] = {kMachMessageIDChildPortCheckIn};
|
const mach_msg_id_t request_ids[] = {kMachMessageIDChildPortCheckIn};
|
||||||
return std::set<mach_msg_id_t>(
|
return std::set<mach_msg_id_t>(&request_ids[0],
|
||||||
&request_ids[0], &request_ids[arraysize(request_ids)]);
|
&request_ids[arraysize(request_ids)]);
|
||||||
}
|
}
|
||||||
|
|
||||||
mach_msg_size_t ChildPortServer::MachMessageServerRequestSize() {
|
mach_msg_size_t ChildPortServer::MachMessageServerRequestSize() {
|
||||||
|
@ -17,6 +17,8 @@
|
|||||||
|
|
||||||
#include <mach/mach.h>
|
#include <mach/mach.h>
|
||||||
|
|
||||||
|
#include <set>
|
||||||
|
|
||||||
#include "base/basictypes.h"
|
#include "base/basictypes.h"
|
||||||
#include "util/mach/child_port_types.h"
|
#include "util/mach/child_port_types.h"
|
||||||
#include "util/mach/mach_message_server.h"
|
#include "util/mach/mach_message_server.h"
|
||||||
@ -45,7 +47,7 @@ class ChildPortServer : public MachMessageServer::Interface {
|
|||||||
mach_port_t port,
|
mach_port_t port,
|
||||||
mach_msg_type_name_t right_type,
|
mach_msg_type_name_t right_type,
|
||||||
const mach_msg_trailer_t* trailer,
|
const mach_msg_trailer_t* trailer,
|
||||||
bool* destroy_complex_request) = 0;
|
bool* destroy_request) = 0;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
~Interface() {}
|
~Interface() {}
|
||||||
|
@ -94,7 +94,7 @@ class MockChildPortServerInterface : public ChildPortServer::Interface {
|
|||||||
mach_port_t port,
|
mach_port_t port,
|
||||||
mach_msg_type_name_t right_type,
|
mach_msg_type_name_t right_type,
|
||||||
const mach_msg_trailer_t* trailer,
|
const mach_msg_trailer_t* trailer,
|
||||||
bool* destroy_complex_request));
|
bool* destroy_request));
|
||||||
};
|
};
|
||||||
|
|
||||||
TEST(ChildPortServer, MockChildPortCheckIn) {
|
TEST(ChildPortServer, MockChildPortCheckIn) {
|
||||||
@ -106,10 +106,10 @@ TEST(ChildPortServer, MockChildPortCheckIn) {
|
|||||||
EXPECT_EQ(expect_request_ids, server.MachMessageServerRequestIDs());
|
EXPECT_EQ(expect_request_ids, server.MachMessageServerRequestIDs());
|
||||||
|
|
||||||
ChildPortCheckInRequest request;
|
ChildPortCheckInRequest request;
|
||||||
EXPECT_LE(request.Head.msgh_size, server.MachMessageServerRequestSize());
|
EXPECT_EQ(request.Head.msgh_size, server.MachMessageServerRequestSize());
|
||||||
|
|
||||||
MIGReply reply;
|
MIGReply reply;
|
||||||
EXPECT_LE(sizeof(reply), server.MachMessageServerReplySize());
|
EXPECT_EQ(sizeof(reply), server.MachMessageServerReplySize());
|
||||||
|
|
||||||
EXPECT_CALL(server_interface,
|
EXPECT_CALL(server_interface,
|
||||||
HandleChildPortCheckIn(kServerLocalPort,
|
HandleChildPortCheckIn(kServerLocalPort,
|
||||||
@ -121,12 +121,12 @@ TEST(ChildPortServer, MockChildPortCheckIn) {
|
|||||||
.WillOnce(Return(MIG_NO_REPLY))
|
.WillOnce(Return(MIG_NO_REPLY))
|
||||||
.RetiresOnSaturation();
|
.RetiresOnSaturation();
|
||||||
|
|
||||||
bool destroy_complex_request = false;
|
bool destroy_request = false;
|
||||||
EXPECT_TRUE(server.MachMessageServerFunction(
|
EXPECT_TRUE(server.MachMessageServerFunction(
|
||||||
reinterpret_cast<mach_msg_header_t*>(&request),
|
reinterpret_cast<mach_msg_header_t*>(&request),
|
||||||
reinterpret_cast<mach_msg_header_t*>(&reply),
|
reinterpret_cast<mach_msg_header_t*>(&reply),
|
||||||
&destroy_complex_request));
|
&destroy_request));
|
||||||
EXPECT_FALSE(destroy_complex_request);
|
EXPECT_FALSE(destroy_request);
|
||||||
|
|
||||||
reply.Verify();
|
reply.Verify();
|
||||||
}
|
}
|
||||||
|
@ -476,10 +476,12 @@ bool ExcServer<Traits>::MachMessageServerFunction(
|
|||||||
sizeof(out_reply->new_state[0]) * out_reply->new_stateCnt;
|
sizeof(out_reply->new_state[0]) * out_reply->new_stateCnt;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
SetMIGReplyError(out_header, MIG_BAD_ID);
|
default: {
|
||||||
return false;
|
SetMIGReplyError(out_header, MIG_BAD_ID);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//! \brief A server interface for the `exc` or `mach_exc` Mach subsystems,
|
//! \brief A server interface for the `exc` or `mach_exc` Mach subsystems,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user