Index: webrtc/p2p/base/relayserver.cc |
diff --git a/webrtc/p2p/base/relayserver.cc b/webrtc/p2p/base/relayserver.cc |
index e098cbcd843b5f5e0d99c2513a9e3dd7c5d704d8..37b3371bf753f25446891bb6c66ffaa30aa46cbf 100644 |
--- a/webrtc/p2p/base/relayserver.cc |
+++ b/webrtc/p2p/base/relayserver.cc |
@@ -26,9 +26,6 @@ namespace cricket { |
// By default, we require a ping every 90 seconds. |
const int MAX_LIFETIME = 15 * 60 * 1000; |
-// The number of bytes in each of the usernames we use. |
-const uint32_t USERNAME_LENGTH = 16; |
- |
// Calls SendTo on the given socket and logs any bad results. |
void Send(rtc::AsyncPacketSocket* socket, const char* bytes, size_t size, |
const rtc::SocketAddress& addr) { |
@@ -263,11 +260,14 @@ void RelayServer::OnExternalPacket( |
return; |
} |
- uint32_t length = |
- std::min(static_cast<uint32_t>(username_attr->length()), USERNAME_LENGTH); |
+ uint32_t length = static_cast<uint32_t>(username_attr->length()); |
std::string username(username_attr->bytes(), length); |
+ // The username is the substring before colon in username_attr |
+ std::string::size_type colonpos = username.find(':'); |
+ if (colonpos != std::string::npos) { |
+ username = username.substr(0, colonpos); |
pthatcher1
2016/05/05 18:07:19
I don't think this is correct.
The place where we
Zhi Huang
2016/05/05 18:27:09
The reason I made these changes is some unit tests
pthatcher1
2016/05/05 20:24:31
I don't see why a length of 9 would cause this cod
Zhi Huang
2016/05/05 23:10:59
I changed code like this:
const uint32_t USERNAME
pthatcher1
2016/05/09 23:59:25
uint32_t length = static_cast<uint32_t>(username_a
|
+ } |
// TODO: Check the HMAC. |
- |
// The binding should already be present. |
BindingMap::iterator biter = bindings_.find(username); |
if (biter == bindings_.end()) { |