# HG changeset patch # User Olli Pettay # Date 1276841785 -10800 # Node ID 1be59c7b12744ce4fe898e38fd88295b71bdd718 # Parent 7dcad6b2356dcd66665227a801f8601885f98e7e Bug 562681, because of Windows, use rand(), not random() diff --git a/content/base/src/nsWebSocket.cpp b/content/base/src/nsWebSocket.cpp --- a/content/base/src/nsWebSocket.cpp +++ b/content/base/src/nsWebSocket.cpp @@ -786,7 +786,7 @@ } while (!headersToSend.IsEmpty()) { - PRUint8 headerPosToSendNow = random() % headersToSend.Length(); + PRUint8 headerPosToSendNow = rand() % headersToSend.Length(); eRequestHeader headerToSendNow = static_cast(headersToSend[headerPosToSendNow]); @@ -1330,9 +1330,9 @@ { PRUint32 i; - PRUint32 spaces = random() % 12 + 1; + PRUint32 spaces = rand() % 12 + 1; PRUint32 max = PR_UINT32_MAX / spaces; - PRUint32 number = random() % max; + PRUint32 number = rand() % max; PRUint32 product = number * spaces; nsCAutoString key; @@ -1342,13 +1342,13 @@ // Insert between one and twelve random characters from the ranges // U+0021 to U+002F and U+003A to U+007E into the key at random // positions. - PRUint32 numberOfCharsToInsert = random() % 12 + 1; + PRUint32 numberOfCharsToInsert = rand() % 12 + 1; for (i = 0; i < numberOfCharsToInsert; ++i) { - PRUint32 posToInsert = random() % key.Length(); + PRUint32 posToInsert = rand() % key.Length(); char charToInsert = - random() % 2 == 0 ? - static_cast(0x21 + (random() % (0x2F - 0x21 + 1))) : - static_cast(0x3A + (random() % (0x7E - 0x3A + 1))); + rand() % 2 == 0 ? + static_cast(0x21 + (rand() % (0x2F - 0x21 + 1))) : + static_cast(0x3A + (rand() % (0x7E - 0x3A + 1))); key.Insert(charToInsert, posToInsert); } @@ -1356,7 +1356,7 @@ // Insert /spaces/ U+0020 SPACE characters into the key at random // positions other than the start or end of the string. for (i = 0; i < spaces; ++i) { - PRUint32 posToInsert = random() % (key.Length() - 1) + 1; + PRUint32 posToInsert = rand() % (key.Length() - 1) + 1; key.Insert(static_cast(0x20), posToInsert); } @@ -1387,7 +1387,7 @@ for (i = 0; i < 8; ++i) { // get a byte between 1 and 255. 0x00 was discarted to prevent possible // issues in ws servers. - key_3 += static_cast(random() % 0xff + 1); + key_3 += static_cast(rand() % 0xff + 1); } // since we have the keys, we calculate the server md5 challenge response,