diff options
author | dmaclach@chromium.org <dmaclach@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-08-25 14:14:05 +0000 |
---|---|---|
committer | dmaclach@chromium.org <dmaclach@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-08-25 14:14:05 +0000 |
commit | 3c52425b21e996264a0302e45fc75e623a029e12 (patch) | |
tree | 64158d2d9c2c8a90fac36c2088ba0de76a14a735 | |
parent | 130ee907aaf46c2161d956725cbd23c26bad4895 (diff) | |
download | chromium_src-3c52425b21e996264a0302e45fc75e623a029e12.zip chromium_src-3c52425b21e996264a0302e45fc75e623a029e12.tar.gz chromium_src-3c52425b21e996264a0302e45fc75e623a029e12.tar.bz2 |
There are times on the Mac when pipe names of 0 length may occur. Let the caller handle
the error instead of aborting here.
BUG=75518
TEST=BUILD
Review URL: http://codereview.chromium.org/7743001
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@98225 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | ipc/ipc_channel_posix.cc | 4 | ||||
-rw-r--r-- | ipc/ipc_channel_posix_unittest.cc | 20 |
2 files changed, 21 insertions, 3 deletions
diff --git a/ipc/ipc_channel_posix.cc b/ipc/ipc_channel_posix.cc index fe60691..8cda88b 100644 --- a/ipc/ipc_channel_posix.cc +++ b/ipc/ipc_channel_posix.cc @@ -144,10 +144,9 @@ COMPILE_ASSERT(sizeof(((sockaddr_un*)0)->sun_path) >= kMaxPipeNameLength, bool CreateServerUnixDomainSocket(const std::string& pipe_name, int* server_listen_fd) { DCHECK(server_listen_fd); - DCHECK_GT(pipe_name.length(), 0u); - DCHECK_LT(pipe_name.length(), kMaxPipeNameLength); if (pipe_name.length() == 0 || pipe_name.length() >= kMaxPipeNameLength) { + DLOG(ERROR) << "pipe_name.length() == " << pipe_name.length(); return false; } @@ -315,7 +314,6 @@ Channel::ChannelImpl::ChannelImpl(const IPC::ChannelHandle& channel_handle, if (!CreatePipe(channel_handle)) { // The pipe may have been closed already. const char *modestr = (mode_ & MODE_SERVER_FLAG) ? "server" : "client"; - // The pipe may have been closed already. LOG(WARNING) << "Unable to create pipe named \"" << channel_handle.name << "\" in " << modestr << " mode"; } diff --git a/ipc/ipc_channel_posix_unittest.cc b/ipc/ipc_channel_posix_unittest.cc index 14ecc608..9d9c70a 100644 --- a/ipc/ipc_channel_posix_unittest.cc +++ b/ipc/ipc_channel_posix_unittest.cc @@ -281,6 +281,26 @@ TEST_F(IPCChannelPosixTest, ResetState) { ASSERT_FALSE(channel.HasAcceptedConnection()); } +TEST_F(IPCChannelPosixTest, BadChannelName) { + // Test empty name + IPC::ChannelHandle handle(""); + IPC::Channel channel(handle, IPC::Channel::MODE_NAMED_SERVER, NULL); + ASSERT_FALSE(channel.Connect()); + + // Test name that is too long. + const char *kTooLongName = "This_is_a_very_long_name_to_proactively_implement" + "client-centered_synergy_through_top-line" + "platforms_Phosfluorescently_disintermediate_" + "clicks-and-mortar_best_practices_without_" + "future-proof_growth_strategies_Continually" + "pontificate_proactive_potentialities_before" + "leading-edge_processes"; + EXPECT_GE(strlen(kTooLongName), IPC::kMaxPipeNameLength); + IPC::ChannelHandle handle2(kTooLongName); + IPC::Channel channel2(handle2, IPC::Channel::MODE_NAMED_SERVER, NULL); + EXPECT_FALSE(channel2.Connect()); +} + TEST_F(IPCChannelPosixTest, MultiConnection) { // Test setting up a connection to an external process, and then have // another external process attempt to connect to us. |