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

Side by Side Diff: ipc/ipc_channel_win.cc

Issue 1320783002: Make SharedMemoryHandle a class on windows. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@ipc_global
Patch Set: Add a safety check. Created 5 years, 3 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
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 "ipc/ipc_channel_win.h" 5 #include "ipc/ipc_channel_win.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 #include <windows.h> 8 #include <windows.h>
9 9
10 #include "base/auto_reset.h" 10 #include "base/auto_reset.h"
(...skipping 554 matching lines...) Expand 10 before | Expand all | Expand 10 after
565 } 565 }
566 566
567 //------------------------------------------------------------------------------ 567 //------------------------------------------------------------------------------
568 // Channel's methods 568 // Channel's methods
569 569
570 // static 570 // static
571 scoped_ptr<Channel> Channel::Create(const IPC::ChannelHandle& channel_handle, 571 scoped_ptr<Channel> Channel::Create(const IPC::ChannelHandle& channel_handle,
572 Mode mode, 572 Mode mode,
573 Listener* listener, 573 Listener* listener,
574 AttachmentBroker* broker) { 574 AttachmentBroker* broker) {
575 return scoped_ptr<Channel>( 575 return scoped_ptr<Channel>(new ChannelWin(channel_handle, mode, listener));
576 new ChannelWin(channel_handle, mode, listener));
577 } 576 }
578 577
579 // static 578 // static
580 bool Channel::IsNamedServerInitialized(const std::string& channel_id) { 579 bool Channel::IsNamedServerInitialized(const std::string& channel_id) {
581 return ChannelWin::IsNamedServerInitialized(channel_id); 580 return ChannelWin::IsNamedServerInitialized(channel_id);
582 } 581 }
583 582
584 // static 583 // static
585 std::string Channel::GenerateVerifiedChannelID(const std::string& prefix) { 584 std::string Channel::GenerateVerifiedChannelID(const std::string& prefix) {
586 // Windows pipes can be enumerated by low-privileged processes. So, we 585 // Windows pipes can be enumerated by low-privileged processes. So, we
587 // append a strong random value after the \ character. This value is not 586 // append a strong random value after the \ character. This value is not
588 // included in the pipe name, but sent as part of the client hello, to 587 // included in the pipe name, but sent as part of the client hello, to
589 // hijacking the pipe name to spoof the client. 588 // hijacking the pipe name to spoof the client.
590 589
591 std::string id = prefix; 590 std::string id = prefix;
592 if (!id.empty()) 591 if (!id.empty())
593 id.append("."); 592 id.append(".");
594 593
595 int secret; 594 int secret;
596 do { // Guarantee we get a non-zero value. 595 do { // Guarantee we get a non-zero value.
597 secret = base::RandInt(0, std::numeric_limits<int>::max()); 596 secret = base::RandInt(0, std::numeric_limits<int>::max());
598 } while (secret == 0); 597 } while (secret == 0);
599 598
600 id.append(GenerateUniqueRandomChannelID()); 599 id.append(GenerateUniqueRandomChannelID());
601 return id.append(base::StringPrintf("\\%d", secret)); 600 return id.append(base::StringPrintf("\\%d", secret));
602 } 601 }
603 602
604 } // namespace IPC 603 } // namespace IPC
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698