summaryrefslogtreecommitdiffstats
path: root/src/corelib/plugin
diff options
context:
space:
mode:
authormread <qt-info@nokia.com>2011-08-24 13:04:02 +0100
committermread <qt-info@nokia.com>2011-08-24 13:04:02 +0100
commitac10a99e642c9005efc7639583fcb726acc169fd (patch)
tree62dd69423a934e14a83cd545c7cacd6cf29bbdd0 /src/corelib/plugin
parent33f65993866e3eb2a80001f1b53f38dbfc7017ce (diff)
Giving QUuid::createUuid() more entropy on Symbian
QUuid::createUuid() uuids have low entropy on Symbian, giving a dangerously high probability of collision. This change adds in more entropy from the kernel tick count to reduce the possibility of collision. Task-number: QTBUG-21072 Reviewed-by: Sami Merila
Diffstat (limited to 'src/corelib/plugin')
-rw-r--r--src/corelib/plugin/quuid.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/corelib/plugin/quuid.cpp b/src/corelib/plugin/quuid.cpp
index af63b7949a..83c6194c62 100644
--- a/src/corelib/plugin/quuid.cpp
+++ b/src/corelib/plugin/quuid.cpp
@@ -901,6 +901,12 @@ QUuid QUuid::createUuid()
uint randNumber = 0;
for (int filled = 0; filled < intbits; filled += randbits)
randNumber |= qrand()<<filled;
+#if defined(Q_OS_SYMBIAN)
+ // Symbian does not have /dev/urandom, so entropy is low.
+ // Add more entropy from the kernel tick count (1ms resolution).
+ // big multipler used to splatter the tick count bits over the whole 32 bits
+ randNumber ^= User::NTickCount() * 0x3b9aca07;
+#endif
*(data+chunks) = randNumber;
}
}