diff --git a/headers/os/bluetooth/LinkKeyUtils.h b/headers/os/bluetooth/LinkKeyUtils.h index 3abbb313d9..56b7d914dd 100644 --- a/headers/os/bluetooth/LinkKeyUtils.h +++ b/headers/os/bluetooth/LinkKeyUtils.h @@ -24,12 +24,11 @@ public: 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 - static char str[50]; + BString str; - 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", 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], diff --git a/headers/os/bluetooth/bdaddrUtils.h b/headers/os/bluetooth/bdaddrUtils.h index 9b86c32dd8..0b1a2bf1a4 100644 --- a/headers/os/bluetooth/bdaddrUtils.h +++ b/headers/os/bluetooth/bdaddrUtils.h @@ -9,6 +9,8 @@ #include #include +#include + #include namespace Bluetooth { @@ -45,12 +47,11 @@ public: memcpy(&dst, &src, sizeof(bdaddr_t)); } - static char* ToString(const bdaddr_t bdaddr) + static BString ToString(const bdaddr_t bdaddr) { - // TODO: not safe - static char str[18]; + BString str; - 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[0]); return str; diff --git a/headers/private/bluetooth/PincodeWindow.h b/headers/private/bluetooth/PincodeWindow.h index c7bb86b843..d39ad7b4db 100644 --- a/headers/private/bluetooth/PincodeWindow.h +++ b/headers/private/bluetooth/PincodeWindow.h @@ -27,7 +27,7 @@ public: PincodeWindow(RemoteDevice* rDevice); virtual void MessageReceived(BMessage *msg); virtual bool QuitRequested(); - void SetBDaddr(const char* address); + void SetBDaddr(BString address); private: void InitUI(); diff --git a/src/kits/bluetooth/UI/PincodeWindow.cpp b/src/kits/bluetooth/UI/PincodeWindow.cpp index 65b1ae5c22..e2757df6c3 100644 --- a/src/kits/bluetooth/UI/PincodeWindow.cpp +++ b/src/kits/bluetooth/UI/PincodeWindow.cpp @@ -187,7 +187,7 @@ bool PincodeWindow::QuitRequested() } -void PincodeWindow::SetBDaddr(const char* address) +void PincodeWindow::SetBDaddr(BString address) { BString label;