summaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorukai@chromium.org <ukai@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-04-20 06:07:50 +0000
committerukai@chromium.org <ukai@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-04-20 06:07:50 +0000
commitac47361fe9b233becd518dc403436436f834cbc9 (patch)
tree00f90d5194bea6d267bf0072ad8550b8d49b16f6 /net
parente08b2652afb31bad466bc69d1f1aa3b80298361f (diff)
downloadchromium_src-ac47361fe9b233becd518dc403436436f834cbc9.zip
chromium_src-ac47361fe9b233becd518dc403436436f834cbc9.tar.gz
chromium_src-ac47361fe9b233becd518dc403436436f834cbc9.tar.bz2
Fix websocket key generation algorithm.
http://html5.org/tools/web-apps-tracker?from=5054&to=5055 changed the order to insert random character and space in key. BUG=none TEST=none Review URL: http://codereview.chromium.org/1631023 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@45015 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net')
-rw-r--r--net/websockets/websocket_handshake.cc10
1 files changed, 5 insertions, 5 deletions
diff --git a/net/websockets/websocket_handshake.cc b/net/websockets/websocket_handshake.cc
index 6f660bc..5adfa67 100644
--- a/net/websockets/websocket_handshake.cc
+++ b/net/websockets/websocket_handshake.cc
@@ -278,11 +278,7 @@ void WebSocketHandshake::Parameter::GenerateSecWebSocketKey(
*number = rand_(0, max);
uint32 product = *number * space;
- std::string s = StringPrintf("%010u", product);
- for (uint32 i = 0; i < space; i++) {
- int pos = rand_(1, s.length() - 1);
- s = s.substr(0, pos) + " " + s.substr(pos);
- }
+ std::string s = StringPrintf("%u", product);
int n = rand_(1, 12);
for (int i = 0; i < n; i++) {
int pos = rand_(0, s.length());
@@ -290,6 +286,10 @@ void WebSocketHandshake::Parameter::GenerateSecWebSocketKey(
s = s.substr(0, pos).append(1, randomCharacterInSecWebSocketKey[chpos]) +
s.substr(pos);
}
+ for (uint32 i = 0; i < space; i++) {
+ int pos = rand_(1, s.length() - 1);
+ s = s.substr(0, pos) + " " + s.substr(pos);
+ }
*key = s;
}