Bug 1154235: Use |snprintf| in Bluetooth utililities, r=btian

The use of |sprintf| is unsafe and generally deprecated. This patch
replaces |sprintf| in the Bluetooth utilities with |snprintf|.
This commit is contained in:
Thomas Zimmermann 2015-04-16 10:48:21 +02:00
Родитель f0aea25638
Коммит ca73054656
1 изменённых файлов: 5 добавлений и 4 удалений

Просмотреть файл

@ -31,10 +31,11 @@ UuidToString(const BluetoothUuid& aUuid, nsAString& aString)
memcpy(&uuid4, &aUuid.mUuid[10], sizeof(uint32_t));
memcpy(&uuid5, &aUuid.mUuid[14], sizeof(uint16_t));
sprintf(uuidStr, "%.8x-%.4x-%.4x-%.4x-%.8x%.4x",
ntohl(uuid0), ntohs(uuid1),
ntohs(uuid2), ntohs(uuid3),
ntohl(uuid4), ntohs(uuid5));
snprintf(uuidStr, sizeof(uuidStr),
"%.8x-%.4x-%.4x-%.4x-%.8x%.4x",
ntohl(uuid0), ntohs(uuid1),
ntohs(uuid2), ntohs(uuid3),
ntohl(uuid4), ntohs(uuid5));
aString.Truncate();
aString.AssignLiteral(uuidStr);