linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] shared/gatt-server: Avoid memory corruption
@ 2015-01-23 14:25 Romain Izard
  2015-01-23 14:25 ` [PATCH 2/2] shared/gatt-server: Fix notification & indication packet size Romain Izard
  2015-01-26 15:53 ` [PATCH 1/2] shared/gatt-server: Avoid memory corruption Luiz Augusto von Dentz
  0 siblings, 2 replies; 3+ messages in thread
From: Romain Izard @ 2015-01-23 14:25 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Romain Izard

When sending notification and indication data, the size of the allocated
packet is the smallest of the MTU and the payload size.

The copy procedure uses the payload size in all cases, which can lead to
memory corruption. Use the packet size instead.
---
 src/shared/gatt-server.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/shared/gatt-server.c b/src/shared/gatt-server.c
index b406ed6..dd9c88f 100644
--- a/src/shared/gatt-server.c
+++ b/src/shared/gatt-server.c
@@ -1506,7 +1506,7 @@ bool bt_gatt_server_send_notification(struct bt_gatt_server *server,
 		return false;
 
 	put_le16(handle, pdu);
-	memcpy(pdu + 2, value, length);
+	memcpy(pdu + 2, value, pdu_len - 2);
 
 	result = !!bt_att_send(server->att, BT_ATT_OP_HANDLE_VAL_NOT, pdu,
 						pdu_len, NULL, NULL, NULL);
@@ -1571,7 +1571,7 @@ bool bt_gatt_server_send_indication(struct bt_gatt_server *server,
 	data->user_data = user_data;
 
 	put_le16(handle, pdu);
-	memcpy(pdu + 2, value, length);
+	memcpy(pdu + 2, value, pdu_len - 2);
 
 	result = !!bt_att_send(server->att, BT_ATT_OP_HANDLE_VAL_IND, pdu,
 							pdu_len, conf_cb,
-- 
2.1.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-01-26 15:53 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-01-23 14:25 [PATCH 1/2] shared/gatt-server: Avoid memory corruption Romain Izard
2015-01-23 14:25 ` [PATCH 2/2] shared/gatt-server: Fix notification & indication packet size Romain Izard
2015-01-26 15:53 ` [PATCH 1/2] shared/gatt-server: Avoid memory corruption Luiz Augusto von Dentz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).