diff options
author | Johan Hedberg <johan.hedberg@intel.com> | 2013-07-12 14:04:05 +0300 |
---|---|---|
committer | Johan Hedberg <johan.hedberg@intel.com> | 2013-07-12 14:04:05 +0300 |
commit | 1549e0a614fb38ec3237c79debf85ae653d6dd28 (patch) | |
tree | b875d0e84c172d1cc3f2bdb9b343445cd6d02418 | |
parent | 3bdc3d0f00ab0440071f319e67676089b3672e54 (diff) |
input: Fix rejecting connections from unknown devices
-rw-r--r-- | profiles/input/device.c | 8 | ||||
-rw-r--r-- | profiles/input/device.h | 1 | ||||
-rw-r--r-- | profiles/input/server.c | 14 |
3 files changed, 17 insertions, 6 deletions
diff --git a/profiles/input/device.c b/profiles/input/device.c index a8d596402..652316121 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 39c642d7b..da2149cdc 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 65631e6b8..21d4562b1 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; |