Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Skip to content
Commit 81566800 authored by Arnd Bergmann's avatar Arnd Bergmann Committed by Razziell
Browse files

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: default avatarArnd Bergmann <arnd@arndb.de>
Signed-off-by: default avatarAlbert I <krascgq@outlook.co.id>
parent b64633d9
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment