Bluetooth: Fix the creation of hdev->name
authorItay Iellin <ieitayie@gmail.com>
Sat, 7 May 2022 12:32:48 +0000 (08:32 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 15 May 2022 17:54:47 +0000 (19:54 +0200)
commit45c05171d6e35120a967a9b782ba6cba43e74902
treea72c4d4920d2c99f26c8b679950e8f016b50f445
parentf52c4c067aa53f53bfb244a7dfa9c3d90082b7a3
Bluetooth: Fix the creation of hdev->name

commit 103a2f3255a95991252f8f13375c3a96a75011cd upstream.

Set a size limit of 8 bytes of the written buffer to "hdev->name"
including the terminating null byte, as the size of "hdev->name" is 8
bytes. If an id value which is greater than 9999 is allocated,
then the "snprintf(hdev->name, sizeof(hdev->name), "hci%d", id)"
function call would lead to a truncation of the id value in decimal
notation.

Set an explicit maximum id parameter in the id allocation function call.
The id allocation function defines the maximum allocated id value as the
maximum id parameter value minus one. Therefore, HCI_MAX_ID is defined
as 10000.

Signed-off-by: Itay Iellin <ieitayie@gmail.com>
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
include/net/bluetooth/hci_core.h
net/bluetooth/hci_core.c