summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Blasche <alexander.blasche@qt.io>2017-03-14 09:13:02 +0100
committerAlex Blasche <alexander.blasche@qt.io>2017-03-14 14:11:22 +0000
commit39cb3e11bc703d0da8a5a15d271efa6b9284b0eb (patch)
tree8a66eb93b3582cc5a63adb8417905b9c010dae51
parent39ddda71e477a0011031d7fc114aad5eb3a58ec8 (diff)
Ensure the passkey and pincode for pairing are random
The previous AND operation with 1mio was not random (especially when the hex value was used). Task-number: QTBUG-59392 Change-Id: Id9ba5432c21fa41a9e5af9800a8633ce4f02fba4 Reviewed-by: Tuomas Vaarala <tuomas.vaarala@qt.io> Reviewed-by: Oliver Wolff <oliver.wolff@qt.io> Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io> Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
-rw-r--r--src/bluetooth/qbluetoothlocaldevice_bluez.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/bluetooth/qbluetoothlocaldevice_bluez.cpp b/src/bluetooth/qbluetoothlocaldevice_bluez.cpp
index 8da29a36..c8c5ffbf 100644
--- a/src/bluetooth/qbluetoothlocaldevice_bluez.cpp
+++ b/src/bluetooth/qbluetoothlocaldevice_bluez.cpp
@@ -1164,7 +1164,7 @@ QString QBluetoothLocalDevicePrivate::RequestPinCode(const QDBusObjectPath &in0)
Q_Q(QBluetoothLocalDevice);
qCDebug(QT_BT_BLUEZ) << Q_FUNC_INFO << in0.path();
// seeded in constructor, 6 digit pin
- QString pin = QString::fromLatin1("%1").arg(qrand()&1000000);
+ QString pin = QString::fromLatin1("%1").arg(qrand() % 1000000);
pin = QString::fromLatin1("%1").arg(pin, 6, QLatin1Char('0'));
emit q->pairingDisplayPinCode(address, pin);
@@ -1276,7 +1276,7 @@ uint QBluetoothLocalDevicePrivate::RequestPasskey(const QDBusObjectPath &in0)
{
Q_UNUSED(in0);
qCDebug(QT_BT_BLUEZ) << Q_FUNC_INFO;
- return qrand()&0x1000000;
+ return (qrand() % 1000000);
}
// Bluez 4