| Index: ipc/ipc_fuzzing_tests.cc
|
| ===================================================================
|
| --- ipc/ipc_fuzzing_tests.cc (revision 98434)
|
| +++ ipc/ipc_fuzzing_tests.cc (working copy)
|
| @@ -11,12 +11,31 @@
|
| #include "base/threading/platform_thread.h"
|
| #include "ipc/ipc_channel.h"
|
| #include "ipc/ipc_channel_proxy.h"
|
| -#include "ipc/ipc_message_utils.h"
|
| -#include "ipc/ipc_message_utils_impl.h"
|
| #include "ipc/ipc_tests.h"
|
| #include "testing/gtest/include/gtest/gtest.h"
|
| #include "testing/multiprocess_func_list.h"
|
|
|
| +// IPC messages for testing ---------------------------------------------------
|
| +
|
| +#define IPC_MESSAGE_IMPL
|
| +#include "ipc/ipc_message_macros.h"
|
| +
|
| +#define IPC_MESSAGE_START TestMsgStart
|
| +
|
| +// Generic message class that is an int followed by a wstring.
|
| +IPC_MESSAGE_CONTROL2(MsgClassIS, int, std::wstring)
|
| +
|
| +// Generic message class that is a wstring followed by an int.
|
| +IPC_MESSAGE_CONTROL2(MsgClassSI, std::wstring, int)
|
| +
|
| +// Message to create a mutex in the IPC server, using the received name.
|
| +IPC_MESSAGE_CONTROL2(MsgDoMutex, std::wstring, int)
|
| +
|
| +// Used to generate an ID for a message that should not exist.
|
| +IPC_MESSAGE_CONTROL0(MsgUnhandled)
|
| +
|
| +// ----------------------------------------------------------------------------
|
| +
|
| TEST(IPCMessageIntegrity, ReadBeyondBufferStr) {
|
| //This was BUG 984408.
|
| uint32 v1 = kuint32max - 1;
|
| @@ -96,46 +115,6 @@
|
| EXPECT_FALSE(ReadParam(&m, &iter, &vec));
|
| }
|
|
|
| -// We don't actually use the messages defined in this file, but we do this
|
| -// to get to the IPC macros.
|
| -#include "ipc/ipc_sync_message_unittest.h"
|
| -
|
| -enum IPCMessageIds {
|
| - UNUSED_IPC_TYPE,
|
| - SERVER_FIRST_IPC_TYPE, // 1st Test message tag.
|
| - SERVER_SECOND_IPC_TYPE, // 2nd Test message tag.
|
| - SERVER_THIRD_IPC_TYPE, // 3rd Test message tag.
|
| - CLIENT_MALFORMED_IPC, // Sent to client if server detects bad message.
|
| - CLIENT_UNHANDLED_IPC // Sent to client if server detects unhanded IPC.
|
| -};
|
| -
|
| -// Generic message class that is an int followed by a wstring.
|
| -class MsgClassIS : public IPC::MessageWithTuple< Tuple2<int, std::wstring> > {
|
| - public:
|
| - enum { ID = SERVER_FIRST_IPC_TYPE };
|
| - MsgClassIS(const int& arg1, const std::wstring& arg2)
|
| - : IPC::MessageWithTuple< Tuple2<int, std::wstring> >(
|
| - MSG_ROUTING_CONTROL, ID, MakeRefTuple(arg1, arg2)) {}
|
| -};
|
| -
|
| -// Generic message class that is a wstring followed by an int.
|
| -class MsgClassSI : public IPC::MessageWithTuple< Tuple2<std::wstring, int> > {
|
| - public:
|
| - enum { ID = SERVER_SECOND_IPC_TYPE };
|
| - MsgClassSI(const std::wstring& arg1, const int& arg2)
|
| - : IPC::MessageWithTuple< Tuple2<std::wstring, int> >(
|
| - MSG_ROUTING_CONTROL, ID, MakeRefTuple(arg1, arg2)) {}
|
| -};
|
| -
|
| -// Message to create a mutex in the IPC server, using the received name.
|
| -class MsgDoMutex : public IPC::MessageWithTuple< Tuple2<std::wstring, int> > {
|
| - public:
|
| - enum { ID = SERVER_THIRD_IPC_TYPE };
|
| - MsgDoMutex(const std::wstring& mutex_name, const int& unused)
|
| - : IPC::MessageWithTuple< Tuple2<std::wstring, int> >(
|
| - MSG_ROUTING_CONTROL, ID, MakeRefTuple(mutex_name, unused)) {}
|
| -};
|
| -
|
| class SimpleListener : public IPC::Channel::Listener {
|
| public:
|
| SimpleListener() : other_(NULL) {
|
| @@ -202,7 +181,7 @@
|
| }
|
|
|
| void ReplyMsgNotHandled(uint32 type_id) {
|
| - RoundtripAckReply(FUZZER_ROUTING_ID, CLIENT_UNHANDLED_IPC, type_id);
|
| + RoundtripAckReply(FUZZER_ROUTING_ID, MsgUnhandled::ID, type_id);
|
| Cleanup();
|
| }
|
|
|
| @@ -249,7 +228,7 @@
|
| }
|
|
|
| bool ExpectMsgNotHandled(uint32 type_id) {
|
| - return ExpectMessage(type_id, CLIENT_UNHANDLED_IPC);
|
| + return ExpectMessage(type_id, MsgUnhandled::ID);
|
| }
|
|
|
| private:
|
|
|