Diff between 3bdc3d0f00ab0440071f319e67676089b3672e54 and 1549e0a614fb38ec3237c79debf85ae653d6dd28

Changed Files

File Additions Deletions Status
profiles/input/device.c +8 -0 modified
profiles/input/device.h +1 -0 modified
profiles/input/server.c +8 -6 modified

Full Patch

diff --git a/profiles/input/device.c b/profiles/input/device.c
index a8d5964..6523161 100644
--- a/profiles/input/device.c
+++ b/profiles/input/device.c
@@ -930,6 +930,14 @@ error:
 	return err;
 }
 
+bool input_device_exists(const bdaddr_t *src, const bdaddr_t *dst)
+{
+	if (find_device(src, dst))
+		return true;
+
+	return false;
+}
+
 int input_device_set_channel(const bdaddr_t *src, const bdaddr_t *dst, int psm,
 								GIOChannel *io)
 {
diff --git a/profiles/input/device.h b/profiles/input/device.h
index 39c642d..da2149c 100644
--- a/profiles/input/device.h
+++ b/profiles/input/device.h
@@ -32,6 +32,7 @@ void input_set_idle_timeout(int timeout);
 int input_device_register(struct btd_service *service);
 void input_device_unregister(struct btd_service *service);
 
+bool input_device_exists(const bdaddr_t *src, const bdaddr_t *dst);
 int input_device_set_channel(const bdaddr_t *src, const bdaddr_t *dst, int psm,
 							GIOChannel *io);
 int input_device_close_channels(const bdaddr_t *src, const bdaddr_t *dst);
diff --git a/profiles/input/server.c b/profiles/input/server.c
index 65631e6..21d4562 100644
--- a/profiles/input/server.c
+++ b/profiles/input/server.c
@@ -168,12 +168,15 @@ static void confirm_event_cb(GIOChannel *chan, gpointer user_data)
 		goto drop;
 	}
 
+	ba2str(&dst, addr);
+
 	if (server->confirm) {
-		char address[18];
+		error("Refusing connection from %s: setup in progress", addr);
+		goto drop;
+	}
 
-		ba2str(&dst, address);
-		error("Refusing connection from %s: setup in progress",
-								address);
+	if (!input_device_exists(&src, &dst)) {
+		error("Refusing connection from %s: unknown device", addr);
 		goto drop;
 	}
 
@@ -184,8 +187,7 @@ static void confirm_event_cb(GIOChannel *chan, gpointer user_data)
 	if (ret != 0)
 		return;
 
-	ba2str(&src, addr);
-	error("input: authorization for %s failed", addr);
+	error("input: authorization for device %s failed", addr);
 
 	g_io_channel_unref(server->confirm);
 	server->confirm = NULL;