Bluetooth: fix thread safety issue.

Fixes #11428.
This commit is contained in:
Adrien Destugues
2016-02-14 14:07:21 +01:00
parent fb94ed118a
commit a5a3b2d9a3
4 changed files with 10 additions and 10 deletions
+3 -4
View File
@@ -24,12 +24,11 @@ public:
return (linkkey_t){{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}}; return (linkkey_t){{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}};
} }
static char* ToString(const linkkey_t lk) static BString ToString(const linkkey_t lk)
{ {
// TODO: not safe BString str;
static char str[50];
sprintf(str, "%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:" str.SetToFormat("%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:"
"%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X", "%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X",
lk.l[0], lk.l[1], lk.l[2], lk.l[3], lk.l[4], lk.l[5], lk.l[0], lk.l[1], lk.l[2], lk.l[3], lk.l[4], lk.l[5],
lk.l[6], lk.l[7], lk.l[8], lk.l[9], lk.l[10], lk.l[11], lk.l[6], lk.l[7], lk.l[8], lk.l[9], lk.l[10], lk.l[11],
+5 -4
View File
@@ -9,6 +9,8 @@
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include <String.h>
#include <bluetooth/bluetooth.h> #include <bluetooth/bluetooth.h>
namespace Bluetooth { namespace Bluetooth {
@@ -45,12 +47,11 @@ public:
memcpy(&dst, &src, sizeof(bdaddr_t)); memcpy(&dst, &src, sizeof(bdaddr_t));
} }
static char* ToString(const bdaddr_t bdaddr) static BString ToString(const bdaddr_t bdaddr)
{ {
// TODO: not safe BString str;
static char str[18];
sprintf(str,"%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X",bdaddr.b[5], str.SetToFormat("%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X",bdaddr.b[5],
bdaddr.b[4], bdaddr.b[3], bdaddr.b[2], bdaddr.b[1], bdaddr.b[4], bdaddr.b[3], bdaddr.b[2], bdaddr.b[1],
bdaddr.b[0]); bdaddr.b[0]);
return str; return str;
+1 -1
View File
@@ -27,7 +27,7 @@ public:
PincodeWindow(RemoteDevice* rDevice); PincodeWindow(RemoteDevice* rDevice);
virtual void MessageReceived(BMessage *msg); virtual void MessageReceived(BMessage *msg);
virtual bool QuitRequested(); virtual bool QuitRequested();
void SetBDaddr(const char* address); void SetBDaddr(BString address);
private: private:
void InitUI(); void InitUI();
+1 -1
View File
@@ -187,7 +187,7 @@ bool PincodeWindow::QuitRequested()
} }
void PincodeWindow::SetBDaddr(const char* address) void PincodeWindow::SetBDaddr(BString address)
{ {
BString label; BString label;