diff --git a/headers/os/bluetooth/LinkKeyUtils.h b/headers/os/bluetooth/LinkKeyUtils.h
index 3abbb31..5b7dbf2 100644
a
|
b
|
public:
|
26 | 26 | |
27 | 27 | static char* ToString(const linkkey_t lk) |
28 | 28 | { |
29 | | // TODO: not safe |
30 | | static char str[50]; |
| 29 | int LEN = 51; |
| 30 | static char str[LEN]; |
| 31 | int ret = 0; |
31 | 32 | |
32 | | sprintf(str, "%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:" |
| 33 | ret = snprintf(str, (size_t)LEN, |
| 34 | "%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:" |
33 | 35 | "%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X", |
34 | 36 | lk.l[0], lk.l[1], lk.l[2], lk.l[3], lk.l[4], lk.l[5], |
35 | 37 | lk.l[6], lk.l[7], lk.l[8], lk.l[9], lk.l[10], lk.l[11], |
36 | 38 | lk.l[12], lk.l[13], lk.l[14], lk.l[15]); |
| 39 | |
| 40 | if (ret <= 0) { |
| 41 | snprintf(str, (size_t)LEN, |
| 42 | "%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:" |
| 43 | "%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X", |
| 44 | 0, 0, 0, 0, 0, 0, |
| 45 | 0, 0, 0, 0, 0, 0, |
| 46 | 0, 0, 0, 0); |
| 47 | } |
37 | 48 | |
38 | 49 | return str; |
39 | 50 | } |
diff --git a/headers/os/bluetooth/bdaddrUtils.h b/headers/os/bluetooth/bdaddrUtils.h
index 9b86c32..2038a6a 100644
a
|
b
|
public:
|
47 | 47 | |
48 | 48 | static char* ToString(const bdaddr_t bdaddr) |
49 | 49 | { |
50 | | // TODO: not safe |
51 | | static char str[18]; |
52 | | |
53 | | sprintf(str,"%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X",bdaddr.b[5], |
54 | | bdaddr.b[4], bdaddr.b[3], bdaddr.b[2], bdaddr.b[1], |
55 | | bdaddr.b[0]); |
| 50 | int LEN = 19; |
| 51 | static char str[LEN]; |
| 52 | int ret = 0; |
| 53 | ret = snprintf(str, (size_t)LEN, |
| 54 | "%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X", |
| 55 | bdaddr.b[5], bdaddr.b[4], bdaddr.b[3], |
| 56 | bdaddr.b[2], bdaddr.b[1], bdaddr.b[0]); |
| 57 | if (ret <= 0) { |
| 58 | snprintf(str, (size_t)LEN, |
| 59 | "%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X", |
| 60 | 0, 0, 0, 0, 0, 0); |
| 61 | } |
56 | 62 | return str; |
57 | 63 | } |