summaryrefslogtreecommitdiff
path: root/src/advertising.c
diff options
context:
space:
mode:
authorMatt Schulte <schultetwin1@gmail.com>2018-02-06 23:48:56 -0800
committerLuiz Augusto von Dentz <luiz.von.dentz@intel.com>2018-02-13 14:21:55 +0200
commit2fa53e0fb60db4e560ce230e7a4ea82ffe79c13f (patch)
tree187e66763195465ef5662095719f2eb8898987f5 /src/advertising.c
parent0412f3843b3cef2ab6645d1a2193713c0c3f139b (diff)
downloadbluez-2fa53e0fb60db4e560ce230e7a4ea82ffe79c13f.tar.gz
advertising: only parse adv from adv interfaces
client_proxy_added is called for every interface on an object passed in to the dbus RegisterAdvertisement method. This can cause a NULL dereference to occur and a failure status in the reply on dbus RegisterAdvertisement method calls. The fix is to return early from client_proxy_added if the proxy interface is not org.bluez.LEAdvertisement1. If this early return is not there, two different error paths could occur. 1) client_proxy_added is first called with the org.bluez.LEAdvertisement1 interface and then with another interface. The second call will fail the parse_advertisement call and possibly cause a NULL dereference on the dbus_message_unref if add_client_complete has already occurred. 2) client_proxy_added is first called with an unknown interface and then org.bluez.LEAdvertisement1. The first call will cause parse_advertisement to fail and a failure to be replied to the client calling RegisterAdvertisement. The advertisement may be successfully registered on the second client_proxy_added call but a NULL dereference will occur on the call to dbus_message_new_method_return in add_client_complete.
Diffstat (limited to 'src/advertising.c')
-rw-r--r--src/advertising.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/advertising.c b/src/advertising.c
index f17a1f5c5..38d2a2d1f 100644
--- a/src/advertising.c
+++ b/src/advertising.c
@@ -780,6 +780,11 @@ static void client_proxy_added(GDBusProxy *proxy, void *data)
{
struct btd_adv_client *client = data;
DBusMessage *reply;
+ const char *interface;
+
+ interface = g_dbus_proxy_get_interface(proxy);
+ if (g_str_equal(interface, LE_ADVERTISEMENT_IFACE) == FALSE)
+ return;
reply = parse_advertisement(client);
if (!reply)