From 39cb3e11bc703d0da8a5a15d271efa6b9284b0eb Mon Sep 17 00:00:00 2001 From: Alex Blasche Date: Tue, 14 Mar 2017 09:13:02 +0100 Subject: 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 Reviewed-by: Oliver Wolff Reviewed-by: Timur Pocheptsov Reviewed-by: Alex Blasche --- src/bluetooth/qbluetoothlocaldevice_bluez.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/bluetooth') 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 -- cgit v1.2.3