]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
Bluetooth: hci_core: Fix possible buffer overflow
authorLuiz Augusto von Dentz <luiz.von.dentz@intel.com>
Wed, 28 Feb 2024 15:49:26 +0000 (10:49 -0500)
committerLuiz Augusto von Dentz <luiz.von.dentz@intel.com>
Wed, 6 Mar 2024 22:26:22 +0000 (17:26 -0500)
struct hci_dev_info has a fixed size name[8] field so in the event that
hdev->name is bigger than that strcpy would attempt to write past its
size, so this fixes this problem by switching to use strscpy.

Fixes: dcda165706b9 ("Bluetooth: hci_core: Fix build warnings")
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
net/bluetooth/hci_core.c

index 6ca4c0df9f9c44f0447fca2bdea32b7fe7e43180..230d2bbb933b226a0c5ded4ee90f8c789292a546 100644 (file)
@@ -908,7 +908,7 @@ int hci_get_dev_info(void __user *arg)
        else
                flags = hdev->flags;
 
-       strcpy(di.name, hdev->name);
+       strscpy(di.name, hdev->name, sizeof(di.name));
        di.bdaddr   = hdev->bdaddr;
        di.type     = (hdev->bus & 0x0f) | ((hdev->dev_type & 0x03) << 4);
        di.flags    = flags;