Skip to content

Commit

Permalink
Bluetooth: mgmt: Don't allow to set invalid value to DeviceID source
Browse files Browse the repository at this point in the history
Reply with MGMT_STATUS_INVALID_PARAMS when userspace is trying to set
source with out-of-scope value.

Signed-off-by: Szymon Janc <szymon.janc@tieto.com>
Acked-by: Gustavo Padovan <gustavo@padovan.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
  • Loading branch information
Szymon Janc authored and Gustavo Padovan committed May 9, 2012
1 parent d97dcb6 commit c72d4b8
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion net/bluetooth/mgmt.c
Original file line number Diff line number Diff line change
Expand Up @@ -2532,12 +2532,19 @@ static int set_device_id(struct sock *sk, struct hci_dev *hdev, void *data,
{
struct mgmt_cp_set_device_id *cp = data;
int err;
__u16 source;

BT_DBG("%s", hdev->name);

source = __le16_to_cpu(cp->source);

if (source > 0x0002)
return cmd_status(sk, hdev->id, MGMT_OP_SET_DEVICE_ID,
MGMT_STATUS_INVALID_PARAMS);

hci_dev_lock(hdev);

hdev->devid_source = __le16_to_cpu(cp->source);
hdev->devid_source = source;
hdev->devid_vendor = __le16_to_cpu(cp->vendor);
hdev->devid_product = __le16_to_cpu(cp->product);
hdev->devid_version = __le16_to_cpu(cp->version);
Expand Down

0 comments on commit c72d4b8

Please sign in to comment.