add_dev() does not imply a particular string length for the name and the
description, so it is OK just to increase the buffer size to make the
description fit. While at it, use sizeof() for snprintf() and unsigned
props for the unsigned structure members from <bluetooth/hci.h>.
./pcap-bt-linux.c: In function ‘bt_findalldevs’:
./pcap-bt-linux.c:115:58: warning: ‘%d’ directive output may be truncated writing between 1 and 10 bytes into a region of size 5 [-Wformat-truncation=]
pcap_snprintf(dev_descr, 30, "Bluetooth adapter number %d", i);
^~
./pcap-bt-linux.c:115:32: note: directive argument in the range [0,
2147483646]
pcap_snprintf(dev_descr, 30, "Bluetooth adapter number %d", i);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
{
struct hci_dev_list_req *dev_list;
struct hci_dev_req *dev_req;
{
struct hci_dev_list_req *dev_list;
struct hci_dev_req *dev_req;
+ int sock;
+ unsigned i;
int ret = 0;
sock = socket(AF_BLUETOOTH, SOCK_RAW, BTPROTO_HCI);
int ret = 0;
sock = socket(AF_BLUETOOTH, SOCK_RAW, BTPROTO_HCI);
dev_req = dev_list->dev_req;
for (i = 0; i < dev_list->dev_num; i++, dev_req++) {
dev_req = dev_list->dev_req;
for (i = 0; i < dev_list->dev_num; i++, dev_req++) {
- char dev_name[20], dev_descr[30];
+ char dev_name[20], dev_descr[40];
- pcap_snprintf(dev_name, 20, BT_IFACE"%d", dev_req->dev_id);
- pcap_snprintf(dev_descr, 30, "Bluetooth adapter number %d", i);
+ pcap_snprintf(dev_name, sizeof(dev_name), BT_IFACE"%u", dev_req->dev_id);
+ pcap_snprintf(dev_descr, sizeof(dev_descr), "Bluetooth adapter number %u", i);
/*
* Bluetooth is a wireless technology.
/*
* Bluetooth is a wireless technology.