diff options
author | joi@chromium.org <joi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-05-30 17:43:38 +0000 |
---|---|---|
committer | joi@chromium.org <joi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-05-30 17:43:38 +0000 |
commit | 70ec310b9aa85aff85c753d0c0be769a28d67324 (patch) | |
tree | 51374d9c92a10181b03d5a135a4070eb93678807 /net/websockets | |
parent | af2e192b4a8d5ff0270b54bda694254e5cd5f8fa (diff) | |
download | chromium_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.cc | 6 |
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; } |