OLD | NEW |
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 548 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
559 } | 559 } |
560 | 560 |
561 //------------------------------------------------------------------------------ | 561 //------------------------------------------------------------------------------ |
562 // Channel's methods | 562 // Channel's methods |
563 | 563 |
564 // static | 564 // static |
565 scoped_ptr<Channel> Channel::Create(const IPC::ChannelHandle& channel_handle, | 565 scoped_ptr<Channel> Channel::Create(const IPC::ChannelHandle& channel_handle, |
566 Mode mode, | 566 Mode mode, |
567 Listener* listener, | 567 Listener* listener, |
568 AttachmentBroker* broker) { | 568 AttachmentBroker* broker) { |
569 return scoped_ptr<Channel>( | 569 return scoped_ptr<Channel>(new ChannelWin(channel_handle, mode, listener)); |
570 new ChannelWin(channel_handle, mode, listener)); | |
571 } | 570 } |
572 | 571 |
573 // static | 572 // static |
574 bool Channel::IsNamedServerInitialized(const std::string& channel_id) { | 573 bool Channel::IsNamedServerInitialized(const std::string& channel_id) { |
575 return ChannelWin::IsNamedServerInitialized(channel_id); | 574 return ChannelWin::IsNamedServerInitialized(channel_id); |
576 } | 575 } |
577 | 576 |
578 // static | 577 // static |
579 std::string Channel::GenerateVerifiedChannelID(const std::string& prefix) { | 578 std::string Channel::GenerateVerifiedChannelID(const std::string& prefix) { |
580 // Windows pipes can be enumerated by low-privileged processes. So, we | 579 // Windows pipes can be enumerated by low-privileged processes. So, we |
581 // append a strong random value after the \ character. This value is not | 580 // append a strong random value after the \ character. This value is not |
582 // included in the pipe name, but sent as part of the client hello, to | 581 // included in the pipe name, but sent as part of the client hello, to |
583 // hijacking the pipe name to spoof the client. | 582 // hijacking the pipe name to spoof the client. |
584 | 583 |
585 std::string id = prefix; | 584 std::string id = prefix; |
586 if (!id.empty()) | 585 if (!id.empty()) |
587 id.append("."); | 586 id.append("."); |
588 | 587 |
589 int secret; | 588 int secret; |
590 do { // Guarantee we get a non-zero value. | 589 do { // Guarantee we get a non-zero value. |
591 secret = base::RandInt(0, std::numeric_limits<int>::max()); | 590 secret = base::RandInt(0, std::numeric_limits<int>::max()); |
592 } while (secret == 0); | 591 } while (secret == 0); |
593 | 592 |
594 id.append(GenerateUniqueRandomChannelID()); | 593 id.append(GenerateUniqueRandomChannelID()); |
595 return id.append(base::StringPrintf("\\%d", secret)); | 594 return id.append(base::StringPrintf("\\%d", secret)); |
596 } | 595 } |
597 | 596 |
598 } // namespace IPC | 597 } // namespace IPC |
OLD | NEW |