bluetooth: fix hci name overflow
gcc-8 warns that the index of the hci device could overflow the eight
character array:
net/bluetooth/hci_core.c: In function 'hci_register_dev':
net/bluetooth/hci_core.c:3093:26: error: '%d' directive writing between 1 and 10 bytes into a region of size 5 [-Werror=format-overflow=]
sprintf(hdev->name, "hci%d", id);
^~
net/bluetooth/hci_core.c:3093:22: note: directive argument in the range [0, 2147483647]
sprintf(hdev->name, "hci%d", id);
^~~~~~~
net/bluetooth/hci_core.c:3093:2: note: 'sprintf' output between 5 and 14 bytes into a destination of size 8
sprintf(hdev->name, "hci%d", id);
This uses snprintf() to enforce a valid string, and limits the range of
the integer to 0..9999. In practice this should not matter as we would
not be able connect more than 9999 bluetooth hci's simultaneously.
Signed-off-by:
Arnd Bergmann <arnd@arndb.de>
Signed-off-by:
Albert I <krascgq@outlook.co.id>
Loading
Please register or sign in to comment