summaryrefslogtreecommitdiffstats
path: root/net/websockets
diff options
context:
space:
mode:
authorjoi@chromium.org <joi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-05-30 17:43:38 +0000
committerjoi@chromium.org <joi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-05-30 17:43:38 +0000
commit70ec310b9aa85aff85c753d0c0be769a28d67324 (patch)
tree51374d9c92a10181b03d5a135a4070eb93678807 /net/websockets
parentaf2e192b4a8d5ff0270b54bda694254e5cd5f8fa (diff)
downloadchromium_src-70ec310b9aa85aff85c753d0c0be769a28d67324.zip
chromium_src-70ec310b9aa85aff85c753d0c0be769a28d67324.tar.gz
chromium_src-70ec310b9aa85aff85c753d0c0be769a28d67324.tar.bz2
Fix RandUint32 to be uniform.
BUG=none TEST=none Review URL: http://codereview.chromium.org/7080011 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@87245 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/websockets')
-rw-r--r--net/websockets/websocket_handshake.cc6
1 files changed, 2 insertions, 4 deletions
diff --git a/net/websockets/websocket_handshake.cc b/net/websockets/websocket_handshake.cc
index 5698730..07c7a85 100644
--- a/net/websockets/websocket_handshake.cc
+++ b/net/websockets/websocket_handshake.cc
@@ -215,10 +215,8 @@ uint32 RandUint32(uint32 min, uint32 max) {
DCHECK(min <= max);
uint64 range = static_cast<int64>(max) - min + 1;
- uint64 number = base::RandUint64();
- // TODO(ukai): fix to be uniform.
- // the distribution of the result of modulo will be biased.
- uint32 result = min + static_cast<uint32>(number % range);
+ uint64 number = base::RandGenerator(range);
+ uint32 result = min + static_cast<uint32>(number);
DCHECK(result >= min && result <= max);
return result;
}