Skip to contentSkip to conversation

Bluetooth: Fix wrong memcpy size on LE start encryption

PATCH Applied [email protected] 2 participants 2 messages Sep 19, 2011

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Bluetooth: Fix wrong memcpy size on LE start encryption

From: Anderson Briglia <[email protected]>

This patch fixes wrong memcpy size when copying rand value to HCI_OP_LE_START_ENC command.
The compiler pretends that the array parameter was declared as a pointer and sizeof reports the size of the pointer. [1]

[1] http://www.c-faq.com/aryptr/aryparmsize.html

---
 net/bluetooth/hci_conn.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
net/bluetooth/hci_conn.c +1 -1
index ea7f031..c2df7bf 100644
@@ -218,7 +218,7 @@ void hci_le_start_enc(struct hci_conn *conn, __le16 ediv, __u8 rand[8],
 	cp.handle = cpu_to_le16(conn->handle);
 	memcpy(cp.ltk, ltk, sizeof(cp.ltk));
 	cp.ediv = ediv;
-	memcpy(cp.rand, rand, sizeof(rand));
+	memcpy(cp.rand, rand, sizeof(cp.rand));
 
 	hci_send_cmd(hdev, HCI_OP_LE_START_ENC, sizeof(cp), &cp);
 }
Signature · 1 line
1.7.4.1
#1 lore raw
Quoted 7 lines · * [email protected] <[email protected]> [2011-09-19…

From: Anderson Briglia <[email protected]>

This patch fixes wrong memcpy size when copying rand value to HCI_OP_LE_START_ENC command.
The compiler pretends that the array parameter was declared as a pointer and sizeof reports the size of the pointer. [1]

Quoted 7 lines

[1] http://www.c-faq.com/aryptr/aryparmsize.html

---
 net/bluetooth/hci_conn.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

Applied, thanks.

Gustavo