All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] android/hid: Reject connections from unknown devices
@ 2014-08-21 10:04 Jakub Tyszkowski
  2014-08-21 10:04 ` [PATCH 2/2] android/hid: Force encryption for keyboards Jakub Tyszkowski
  0 siblings, 1 reply; 4+ messages in thread
From: Jakub Tyszkowski @ 2014-08-21 10:04 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Jakub Tyszkowski

---
 android/hidhost.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/android/hidhost.c b/android/hidhost.c
index da5f818..07985d8 100644
--- a/android/hidhost.c
+++ b/android/hidhost.c
@@ -1410,6 +1410,20 @@ static void connect_cb(GIOChannel *chan, GError *err, gpointer user_data)
 	ba2str(&dst, address);
 	DBG("Incoming connection from %s on PSM %d", address, psm);
 
+	if (!bt_device_is_bonded(&dst)) {
+		uint8_t hdr = (HID_MSG_CONTROL | HID_VIRTUAL_CABLE_UNPLUG);
+		int sk = g_io_channel_unix_get_fd(chan);
+
+		warn("hidhost: Rejected connection from unknown device %s",
+								address);
+
+		if (write(sk, &hdr, sizeof(hdr)) < 0)
+			error("hidhost: Unable to send virtual cable unplug");
+
+		g_io_channel_shutdown(chan, TRUE, NULL);
+		return;
+	}
+
 	switch (psm) {
 	case L2CAP_PSM_HIDP_CTRL:
 		l = g_slist_find_custom(devices, &dst, device_cmp);
-- 
1.9.1


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

end of thread, other threads:[~2014-08-22  8:25 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-08-21 10:04 [PATCH 1/2] android/hid: Reject connections from unknown devices Jakub Tyszkowski
2014-08-21 10:04 ` [PATCH 2/2] android/hid: Force encryption for keyboards Jakub Tyszkowski
2014-08-21 11:58   ` Luiz Augusto von Dentz
2014-08-22  8:25     ` Tyszkowski Jakub

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.