зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1170076 - Use snprintf instead of sprintf when parsing bluetooth GATT advertisement data. r=shuang
This commit is contained in:
Родитель
1d142a2ed6
Коммит
fc8c6db4a0
|
@ -385,16 +385,20 @@ BluetoothDevice::UpdatePropertiesFromAdvData(const nsTArray<uint8_t>& aAdvData)
|
|||
char uuidStr[36];
|
||||
if (type == GAP_INCOMPLETE_UUID16 || type == GAP_COMPLETE_UUID16) {
|
||||
// Convert 16-bits UUID into string.
|
||||
sprintf(uuidStr, "0000%04x-0000-1000-8000-00805f9b34fb", uuid[0]);
|
||||
} else if (type == GAP_INCOMPLETE_UUID32 || type == GAP_COMPLETE_UUID32) {
|
||||
snprintf(uuidStr, sizeof(uuidStr),
|
||||
"0000%04x-0000-1000-8000-00805f9b34fb", uuid[0]);
|
||||
} else if (type == GAP_INCOMPLETE_UUID32 ||
|
||||
type == GAP_COMPLETE_UUID32) {
|
||||
// Convert 32-bits UUID into string.
|
||||
sprintf(uuidStr, "%04x%04x-0000-1000-8000-00805f9b34fb",
|
||||
uuid[1], uuid[0]);
|
||||
} else if (type == GAP_INCOMPLETE_UUID128 || type == GAP_COMPLETE_UUID128) {
|
||||
snprintf(uuidStr, sizeof(uuidStr),
|
||||
"%04x%04x-0000-1000-8000-00805f9b34fb", uuid[1], uuid[0]);
|
||||
} else if (type == GAP_INCOMPLETE_UUID128 ||
|
||||
type == GAP_COMPLETE_UUID128) {
|
||||
// Convert 128-bits UUID into string.
|
||||
sprintf(uuidStr, "%04x%04x-%04x-%04x-%04x-%04x%04x%04x",
|
||||
uuid[7], uuid[6], uuid[5], uuid[4],
|
||||
uuid[3], uuid[2], uuid[1], uuid[0]);
|
||||
snprintf(uuidStr, sizeof(uuidStr),
|
||||
"%04x%04x-%04x-%04x-%04x-%04x%04x%04x",
|
||||
uuid[7], uuid[6], uuid[5], uuid[4],
|
||||
uuid[3], uuid[2], uuid[1], uuid[0]);
|
||||
}
|
||||
nsString uuidNsString;
|
||||
uuidNsString.AssignLiteral(uuidStr);
|
||||
|
|
Загрузка…
Ссылка в новой задаче